5 #define QUICKTIME_FASTJPG_HANDLE_RST(rst_int, rst_cnt) \
7 if(((rst_int) && (rst_cnt == 0))) \
9 jpeg_info->jpg_h_bbuf = 0; \
10 jpeg_info->jpg_h_bnum = 0; \
11 if(jpeg_info->marker == 0) jpeg_info->marker = quicktime_fastjpg_check_for_marker(jpeg_info); \
12 if(jpeg_info->marker) \
14 if(jpeg_info->marker == M_EOI) \
16 jpeg_info->jpg_saw_EOI = 1; \
20 if(jpeg_info->marker == M_SOS) quicktime_fastjpg_readSOS(jpeg_info); \
22 if(!((jpeg_info->marker >= M_RST0) && (jpeg_info->marker <= M_RST7))) \
24 printf("QUICKTIME_FASTJPG_HANDLE_RST: unexp marker(%x)\n", jpeg_info->marker); \
27 jpeg_info->marker = 0; \
29 jpeg_info->jpg_comps[0].dc = jpeg_info->jpg_comps[1].dc = jpeg_info->jpg_comps[2].dc = 0; \
36 #define QUICKTIME_FASTJPG_TEST_MARKER \
37 while(jpeg_info->marker) \
39 if(jpeg_info->marker == M_EOI) \
41 jpeg_info->jpg_saw_EOI = 1; \
42 jpeg_info->marker = 0; \
45 if(jpeg_info->marker == M_SOS) \
47 quicktime_fastjpg_readSOS(jpeg_info); \
48 jpeg_info->marker = 0; \
51 if((jpeg_info->marker >= M_RST0) && (jpeg_info->marker <= M_RST7)) \
53 jpeg_info->jpg_comps[0].dc = jpeg_info->jpg_comps[1].dc = jpeg_info->jpg_comps[2].dc = 0; \
54 rst_skip = rst_count; \
55 rst_count = jpeg_info->jpg_rst_interval; \
56 jpeg_info->marker = 0; \
57 jpeg_info->jpg_h_bbuf = 0; \
58 jpeg_info->jpg_h_bnum = 0; \
60 else /* Unknown or unexpected Marker */ \
62 printf("QUICKTIME_FASTJPG_TEST_MARKER: unexp marker(%x)\n", jpeg_info->marker); \
63 jpeg_info->marker = quicktime_fastjpg_skip_to_next_rst(jpeg_info); /* hopefully a RST marker */ \
67 #define QUICKTIME_FASTJPG_HBBUF_FILL8_1(hbbuf, hbnum) \
72 if(jpeg_info->marker) tmp__ = 0x00; \
75 tmp__ = *(jpeg_info->chunk++); \
76 jpeg_info->chunk_size--; \
79 while(tmp__ == 0xff) \
81 t1_ = *(jpeg_info->chunk++); \
82 jpeg_info->chunk_size--; \
83 if(t1_ == 0x00) break; \
84 else if(t1_ == 0xff) continue; \
87 jpeg_info->marker = t1_; \
95 #define QUICKTIME_FASTJPG_HUFF_DECODE(huff_hdr, htbl, hbnum, hbbuf, result) \
97 while(hbnum < 16) { QUICKTIME_FASTJPG_HBBUF_FILL8_1(hbbuf, hbnum); } \
98 tmp_ = (hbbuf >> (hbnum - 8)) & 0xff; \
99 hcode_ = (htbl)[tmp_]; \
102 hbnum -= (hcode_ >> 8); \
103 (result) = hcode_ & 0xff; \
108 tmp_ = (hbbuf >> (hbnum - 16)) & 0xffff; /* get 16 bits */ \
109 shift_ = 16 - minbits_; \
110 hcode_ = tmp_ >> shift_; \
112 while(hcode_ > huff_hdr->maxcode[minbits_]) \
116 hcode_ = tmp_ >> shift_; \
121 printf("QUICKTIME_FASTJPG_HUFF_DECODE error\n"); \
127 hcode_ -= huff_hdr->mincode[minbits_]; \
128 result = huff_hdr->vals[(huff_hdr->valptr[minbits_] + hcode_)]; \
134 #define QUICKTIME_FASTJPG_HUFF_MASK(s) ((1 << (s)) - 1)
136 #define QUICKTIME_FASTJPG_GET_BITS(n, hbnum, hbbuf, result) \
141 QUICKTIME_FASTJPG_HBBUF_FILL8_1(hbbuf, hbnum); \
143 (result) = ((hbbuf >> hbnum) & QUICKTIME_FASTJPG_HUFF_MASK(n)); \
146 #define QUICKTIME_FASTJPG_HUFF_EXTEND(val, sz) \
147 ((val) < (1 << ((sz) - 1)) ? (val) + (((-1) << (sz)) + 1) : (val))
149 #define QUICKTIME_MCU_ARGS \
150 quicktime_jpeg_t *jpeg_info, \
151 unsigned char **row_pointers, \
154 unsigned long mcu_row_size, \
155 unsigned long ip_size, \
156 quicktime_mjpa_buffs *yuvbufs, \
160 #define QUICKTIME_MCU_VARS \
162 unsigned char *yptr, *uptr, *vptr; \
163 long *YTab = jpeg_info->yuvtabs.YUV_Y_tab; \
164 long *UBTab = jpeg_info->yuvtabs.YUV_UB_tab; \
165 long *VRTab = jpeg_info->yuvtabs.YUV_VR_tab; \
166 long *UGTab = jpeg_info->yuvtabs.YUV_UG_tab; \
167 long *VGTab = jpeg_info->yuvtabs.YUV_VG_tab; \
168 unsigned char *ybuf = yuvbufs->ybuf; \
169 unsigned char *ubuf = yuvbufs->ubuf; \
170 unsigned char *vbuf = yuvbufs->vbuf;
172 #define QUICKTIME_MCU111111_MID_VARS \
174 unsigned char *yp, *up, *vp; \
177 #define QUICKTIME_MCU111111_MID_DECL \
178 ip = *row_pointers; \
185 #define QUICKTIME_MCU_INNER_VARS \
194 #define QUICKTIME_MCU_INNER_INIT \
195 u0 = (unsigned long)*up++; \
196 v0 = (unsigned long)*vp++; \
199 cg = UGTab[u0] + VGTab[v0];
201 #define QUICKTIME_MCU4H_INNER_TAIL(inc1, inc2) \
211 if(!(skip & 1)) /* 2 4 6 */ \
214 #define QUICKTIME_MCU_LIMITRANGE(x) \
215 (((x) < 0) ? 0 : (((x) > 255) ? 255 : (x)));
217 #define QUICKTIME_MCU_YUV_TO_RGB(y, cr, cg, cb, ip) \
219 *ip++ = (unsigned char)QUICKTIME_MCU_LIMITRANGE((y_long + cr) >> 6); \
220 *ip++ = (unsigned char)QUICKTIME_MCU_LIMITRANGE((y_long + cg) >> 6); \
221 *ip++ = (unsigned char)QUICKTIME_MCU_LIMITRANGE((y_long + cb) >> 6);
224 #define QUICKTIME_MCU221111_MID_VARS \
225 unsigned char *ip0, *ip1; \
226 unsigned char *yp, *up, *vp; \
230 #define QUICKTIME_MCU221111_MID_DECL \
231 if(frame_height <= 0) return 0; \
232 if(yi == 4) yptr += 64; \
233 ip0 = *row_pointers; \
234 row_pointers += interlaced ? 2 : 1; \
235 ip1 = *row_pointers; \
236 row_pointers += interlaced ? 2 : 1; \
243 #define QUICKTIME_MCU2H_INNER_TAIL(inc1, inc2) \
245 if(skip == 4) yp += inc1; \
255 #define QUICKTIME_MCU1H_INNER_TAIL(inc) \