00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00033 #ifndef AVCODEC_MJPEG_H
00034 #define AVCODEC_MJPEG_H
00035
00036 #include "avcodec.h"
00037 #include "put_bits.h"
00038
00039
00040
00041 typedef enum {
00042
00043 SOF0 = 0xc0,
00044 SOF1 = 0xc1,
00045 SOF2 = 0xc2,
00046 SOF3 = 0xc3,
00047
00048 SOF5 = 0xc5,
00049 SOF6 = 0xc6,
00050 SOF7 = 0xc7,
00051 JPG = 0xc8,
00052 SOF9 = 0xc9,
00053 SOF10 = 0xca,
00054 SOF11 = 0xcb,
00055
00056 SOF13 = 0xcd,
00057 SOF14 = 0xce,
00058 SOF15 = 0xcf,
00059
00060 DHT = 0xc4,
00061
00062 DAC = 0xcc,
00063
00064
00065 RST0 = 0xd0,
00066 RST1 = 0xd1,
00067 RST2 = 0xd2,
00068 RST3 = 0xd3,
00069 RST4 = 0xd4,
00070 RST5 = 0xd5,
00071 RST6 = 0xd6,
00072 RST7 = 0xd7,
00073
00074 SOI = 0xd8,
00075 EOI = 0xd9,
00076 SOS = 0xda,
00077 DQT = 0xdb,
00078 DNL = 0xdc,
00079 DRI = 0xdd,
00080 DHP = 0xde,
00081 EXP = 0xdf,
00082
00083 APP0 = 0xe0,
00084 APP1 = 0xe1,
00085 APP2 = 0xe2,
00086 APP3 = 0xe3,
00087 APP4 = 0xe4,
00088 APP5 = 0xe5,
00089 APP6 = 0xe6,
00090 APP7 = 0xe7,
00091 APP8 = 0xe8,
00092 APP9 = 0xe9,
00093 APP10 = 0xea,
00094 APP11 = 0xeb,
00095 APP12 = 0xec,
00096 APP13 = 0xed,
00097 APP14 = 0xee,
00098 APP15 = 0xef,
00099
00100 JPG0 = 0xf0,
00101 JPG1 = 0xf1,
00102 JPG2 = 0xf2,
00103 JPG3 = 0xf3,
00104 JPG4 = 0xf4,
00105 JPG5 = 0xf5,
00106 JPG6 = 0xf6,
00107 SOF48 = 0xf7,
00108 LSE = 0xf8,
00109 JPG9 = 0xf9,
00110 JPG10 = 0xfa,
00111 JPG11 = 0xfb,
00112 JPG12 = 0xfc,
00113 JPG13 = 0xfd,
00114
00115 COM = 0xfe,
00116
00117 TEM = 0x01,
00118
00119
00120 } JPEG_MARKER;
00121
00122 static inline void put_marker(PutBitContext *p, int code)
00123 {
00124 put_bits(p, 8, 0xff);
00125 put_bits(p, 8, code);
00126 }
00127
00128 #define PREDICT(ret, topleft, top, left, predictor)\
00129 switch(predictor){\
00130 case 0: ret= 0; break;\
00131 case 1: ret= left; break;\
00132 case 2: ret= top; break;\
00133 case 3: ret= topleft; break;\
00134 case 4: ret= left + top - topleft; break;\
00135 case 5: ret= left + ((top - topleft)>>1); break;\
00136 case 6: ret= top + ((left - topleft)>>1); break;\
00137 default:\
00138 case 7: ret= (left + top)>>1; break;\
00139 }
00140
00141 extern const uint8_t ff_mjpeg_bits_dc_luminance[];
00142 extern const uint8_t ff_mjpeg_val_dc[];
00143
00144 extern const uint8_t ff_mjpeg_bits_dc_chrominance[];
00145
00146 extern const uint8_t ff_mjpeg_bits_ac_luminance[];
00147 extern const uint8_t ff_mjpeg_val_ac_luminance[];
00148
00149 extern const uint8_t ff_mjpeg_bits_ac_chrominance[];
00150 extern const uint8_t ff_mjpeg_val_ac_chrominance[];
00151
00152 void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
00153 const uint8_t *bits_table,
00154 const uint8_t *val_table);
00155
00156 #endif