Mercurial > libavcodec.hg
comparison dv.c @ 725:eac6c71ef30f libavcodec
simplified parsing - added MMX idct support
author | bellard |
---|---|
date | Fri, 04 Oct 2002 07:49:00 +0000 |
parents | 50f7e3bef20f |
children | a91203b34e71 |
comparison
equal
deleted
inserted
replaced
724:caa4c757a47d | 725:eac6c71ef30f |
---|---|
34 int width, height; | 34 int width, height; |
35 UINT8 *current_picture[3]; /* picture structure */ | 35 UINT8 *current_picture[3]; /* picture structure */ |
36 int linesize[3]; | 36 int linesize[3]; |
37 DCTELEM block[5*6][64] __align8; | 37 DCTELEM block[5*6][64] __align8; |
38 UINT8 dv_zigzag[2][64]; | 38 UINT8 dv_zigzag[2][64]; |
39 UINT8 idct_permutation[64]; | |
39 /* XXX: move it to static storage ? */ | 40 /* XXX: move it to static storage ? */ |
40 UINT8 dv_shift[2][2][22][64]; | 41 UINT8 dv_shift[2][22][64]; |
41 void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block); | 42 void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block); |
42 } DVVideoDecodeContext; | 43 } DVVideoDecodeContext; |
43 | 44 |
44 #include "dvdata.h" | 45 #include "dvdata.h" |
45 | 46 |
47 /* XXX: also include quantization */ | 48 /* XXX: also include quantization */ |
48 static RL_VLC_ELEM *dv_rl_vlc[1]; | 49 static RL_VLC_ELEM *dv_rl_vlc[1]; |
49 | 50 |
50 static void dv_build_unquantize_tables(DVVideoDecodeContext *s) | 51 static void dv_build_unquantize_tables(DVVideoDecodeContext *s) |
51 { | 52 { |
52 int i, e, q; | 53 int i, q, j; |
53 | 54 |
54 /* NOTE: max left shift is 6 */ | 55 /* NOTE: max left shift is 6 */ |
55 for(e = 0; e < 2; e++) { | 56 for(q = 0; q < 22; q++) { |
56 for(q = 0; q < 22; q++) { | 57 /* 88 unquant */ |
57 /* 88 unquant */ | 58 for(i = 1; i < 64; i++) { |
58 for(i = 1; i < 64; i++) { | 59 /* 88 table */ |
59 /* 88 table */ | 60 j = s->idct_permutation[i]; |
60 s->dv_shift[0][e][q][i] = | 61 s->dv_shift[0][q][j] = |
61 dv_quant_shifts[q][dv_88_areas[i]] + e + 1; | 62 dv_quant_shifts[q][dv_88_areas[i]] + 1; |
62 } | 63 } |
63 | 64 |
64 /* 248 unquant */ | 65 /* 248 unquant */ |
65 for(i = 1; i < 64; i++) { | 66 for(i = 1; i < 64; i++) { |
66 /* 248 table */ | 67 /* 248 table */ |
67 s->dv_shift[1][e][q][i] = | 68 s->dv_shift[1][q][i] = |
68 dv_quant_shifts[q][dv_248_areas[i]] + e + 1; | 69 dv_quant_shifts[q][dv_248_areas[i]] + 1; |
69 } | |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 static int dvvideo_decode_init(AVCodecContext *avctx) | 74 static int dvvideo_decode_init(AVCodecContext *avctx) |
75 { | 75 { |
76 DVVideoDecodeContext *s = avctx->priv_data; | 76 DVVideoDecodeContext *s = avctx->priv_data; |
77 MpegEncContext s2; | |
77 static int done; | 78 static int done; |
78 | 79 |
79 if (!done) { | 80 if (!done) { |
80 int i; | 81 int i; |
81 | 82 |
106 dv_rl_vlc[0][i].len = len; | 107 dv_rl_vlc[0][i].len = len; |
107 dv_rl_vlc[0][i].level = level; | 108 dv_rl_vlc[0][i].level = level; |
108 dv_rl_vlc[0][i].run = run; | 109 dv_rl_vlc[0][i].run = run; |
109 } | 110 } |
110 } | 111 } |
112 | |
113 /* ugly way to get the idct & scantable */ | |
114 /* XXX: fix it */ | |
115 memset(&s2, 0, sizeof(MpegEncContext)); | |
116 s2.flags = avctx->flags; | |
117 s2.avctx = avctx; | |
118 // s2->out_format = FMT_MJPEG; | |
119 s2.width = 8; | |
120 s2.height = 8; | |
121 if (MPV_common_init(&s2) < 0) | |
122 return -1; | |
123 | |
124 s->idct_put[0] = s2.idct_put; | |
125 memcpy(s->idct_permutation, s2.idct_permutation, 64); | |
126 memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64); | |
127 | |
128 /* XXX: use MMX also for idct248 */ | |
129 s->idct_put[1] = simple_idct248_put; | |
130 memcpy(s->dv_zigzag[1], dv_248_zigzag, 64); | |
131 | |
132 MPV_common_end(&s2); | |
133 | |
111 /* XXX: do it only for constant case */ | 134 /* XXX: do it only for constant case */ |
112 dv_build_unquantize_tables(s); | 135 dv_build_unquantize_tables(s); |
113 { | 136 |
114 /* XXX: fix that : use mmx when possible */ | |
115 s->idct_put[0] = simple_idct_put; | |
116 s->idct_put[1] = simple_idct248_put; | |
117 | |
118 memcpy(s->dv_zigzag[0], ff_zigzag_direct, 64); | |
119 memcpy(s->dv_zigzag[1], dv_248_zigzag, 64); | |
120 } | |
121 return 0; | 137 return 0; |
122 } | 138 } |
123 | 139 |
124 //#define VLC_DEBUG | 140 //#define VLC_DEBUG |
125 | 141 |
126 typedef struct MBInfo { | 142 typedef struct BlockInfo { |
127 const UINT8 *shift_table[6]; | 143 const UINT8 *shift_table; |
128 const UINT8 *scan_table[6]; | 144 const UINT8 *scan_table; |
129 UINT8 pos[6]; /* position in block */ | 145 UINT8 pos; /* position in block */ |
130 UINT8 eob_reached[6]; /* true if EOB has been reached */ | 146 UINT8 eob_reached; /* true if EOB has been reached */ |
131 UINT8 dct_mode[6]; | 147 UINT8 dct_mode; |
132 UINT8 partial_bit_count[6]; | 148 UINT8 partial_bit_count; |
133 UINT16 partial_bit_buffer[6]; | 149 UINT16 partial_bit_buffer; |
134 UINT8 bit_buffer[80 + 4]; /* allow some slack */ | 150 int shift_offset; |
135 int bits_left; | 151 } BlockInfo; |
136 } MBInfo; | |
137 | 152 |
138 /* block size in bits */ | 153 /* block size in bits */ |
139 const static UINT16 block_sizes[6] = { | 154 const static UINT16 block_sizes[6] = { |
140 112, 112, 112, 112, 80, 80 | 155 112, 112, 112, 112, 80, 80 |
141 }; | 156 }; |
144 #error only works with ALT_BITSTREAM_READER | 159 #error only works with ALT_BITSTREAM_READER |
145 #endif | 160 #endif |
146 | 161 |
147 /* decode ac coefs */ | 162 /* decode ac coefs */ |
148 static void dv_decode_ac(DVVideoDecodeContext *s, | 163 static void dv_decode_ac(DVVideoDecodeContext *s, |
149 MBInfo *mb, INT16 *block, int j, int last_index) | 164 BlockInfo *mb, INT16 *block, int last_index) |
150 { | 165 { |
151 int last_re_index; | 166 int last_re_index; |
152 const UINT8 *scan_table = mb->scan_table[j]; | 167 int shift_offset = mb->shift_offset; |
153 const UINT8 *shift_table = mb->shift_table[j]; | 168 const UINT8 *scan_table = mb->scan_table; |
154 int pos = mb->pos[j]; | 169 const UINT8 *shift_table = mb->shift_table; |
170 int pos = mb->pos; | |
155 int level, pos1, sign, run; | 171 int level, pos1, sign, run; |
156 int partial_bit_count; | 172 int partial_bit_count; |
157 | 173 |
158 OPEN_READER(re, &s->gb); | 174 OPEN_READER(re, &s->gb); |
159 | 175 |
160 #ifdef VLC_DEBUG | 176 #ifdef VLC_DEBUG |
161 printf("start %d\n", j); | 177 printf("start\n"); |
162 #endif | 178 #endif |
163 | 179 |
164 /* if we must parse a partial vlc, we do it here */ | 180 /* if we must parse a partial vlc, we do it here */ |
165 partial_bit_count = mb->partial_bit_count[j]; | 181 partial_bit_count = mb->partial_bit_count; |
166 if (partial_bit_count > 0) { | 182 if (partial_bit_count > 0) { |
167 UINT8 buf[4]; | 183 UINT8 buf[4]; |
168 UINT32 v; | 184 UINT32 v; |
169 int l, l1; | 185 int l, l1; |
170 GetBitContext gb1; | 186 GetBitContext gb1; |
173 l = 16 - partial_bit_count; | 189 l = 16 - partial_bit_count; |
174 UPDATE_CACHE(re, &s->gb); | 190 UPDATE_CACHE(re, &s->gb); |
175 #ifdef VLC_DEBUG | 191 #ifdef VLC_DEBUG |
176 printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16)); | 192 printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16)); |
177 #endif | 193 #endif |
178 v = (mb->partial_bit_buffer[j] << l) | SHOW_UBITS(re, &s->gb, l); | 194 v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l); |
179 buf[0] = v >> 8; | 195 buf[0] = v >> 8; |
180 buf[1] = v; | 196 buf[1] = v; |
181 #ifdef VLC_DEBUG | 197 #ifdef VLC_DEBUG |
182 printf("v=%04x cnt=%d %04x\n", | 198 printf("v=%04x cnt=%d %04x\n", |
183 v, partial_bit_count, (mb->partial_bit_buffer[j] << l)); | 199 v, partial_bit_count, (mb->partial_bit_buffer << l)); |
184 #endif | 200 #endif |
185 /* try to read the codeword */ | 201 /* try to read the codeword */ |
186 init_get_bits(&gb1, buf, 4); | 202 init_get_bits(&gb1, buf, 4); |
187 { | 203 { |
188 OPEN_READER(re1, &gb1); | 204 OPEN_READER(re1, &gb1); |
202 if ((re_index + l + l1) > last_index) | 218 if ((re_index + l + l1) > last_index) |
203 return; | 219 return; |
204 /* skip read bits */ | 220 /* skip read bits */ |
205 last_re_index = 0; /* avoid warning */ | 221 last_re_index = 0; /* avoid warning */ |
206 re_index += l; | 222 re_index += l; |
207 /* by redefinition, if we can read the vlc, all partial bits | 223 /* by definition, if we can read the vlc, all partial bits |
208 will be read (otherwise we could have read the vlc before) */ | 224 will be read (otherwise we could have read the vlc before) */ |
209 mb->partial_bit_count[j] = 0; | 225 mb->partial_bit_count = 0; |
210 UPDATE_CACHE(re, &s->gb); | 226 UPDATE_CACHE(re, &s->gb); |
211 goto handle_vlc; | 227 goto handle_vlc; |
212 } | 228 } |
213 | 229 |
214 /* get the AC coefficients until last_index is reached */ | 230 /* get the AC coefficients until last_index is reached */ |
228 if (level == 256) { | 244 if (level == 256) { |
229 if (re_index > last_index) { | 245 if (re_index > last_index) { |
230 cannot_read: | 246 cannot_read: |
231 /* put position before read code */ | 247 /* put position before read code */ |
232 re_index = last_re_index; | 248 re_index = last_re_index; |
233 mb->eob_reached[j] = 0; | 249 mb->eob_reached = 0; |
234 break; | 250 break; |
235 } | 251 } |
236 /* EOB */ | 252 /* EOB */ |
237 mb->eob_reached[j] = 1; | 253 mb->eob_reached = 1; |
238 break; | 254 break; |
239 } else if (level != 0) { | 255 } else if (level != 0) { |
240 if ((re_index + 1) > last_index) | 256 if ((re_index + 1) > last_index) |
241 goto cannot_read; | 257 goto cannot_read; |
242 sign = SHOW_SBITS(re, &s->gb, 1); | 258 sign = SHOW_SBITS(re, &s->gb, 1); |
246 /* error */ | 262 /* error */ |
247 if (pos >= 64) { | 263 if (pos >= 64) { |
248 goto read_error; | 264 goto read_error; |
249 } | 265 } |
250 pos1 = scan_table[pos]; | 266 pos1 = scan_table[pos]; |
251 level = level << shift_table[pos1]; | 267 level = level << (shift_table[pos1] + shift_offset); |
252 block[pos1] = level; | 268 block[pos1] = level; |
253 // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]); | 269 // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]); |
254 } else { | 270 } else { |
255 if (re_index > last_index) | 271 if (re_index > last_index) |
256 goto cannot_read; | 272 goto cannot_read; |
262 read_error: | 278 read_error: |
263 #if defined(VLC_DEBUG) || 1 | 279 #if defined(VLC_DEBUG) || 1 |
264 printf("error pos=%d\n", pos); | 280 printf("error pos=%d\n", pos); |
265 #endif | 281 #endif |
266 /* for errors, we consider the eob is reached */ | 282 /* for errors, we consider the eob is reached */ |
267 mb->eob_reached[j] = 1; | 283 mb->eob_reached = 1; |
268 break; | 284 break; |
269 } | 285 } |
270 } | 286 } |
271 } | 287 } |
272 CLOSE_READER(re, &s->gb); | 288 CLOSE_READER(re, &s->gb); |
273 mb->pos[j] = pos; | 289 mb->pos = pos; |
274 } | 290 } |
275 | 291 |
276 static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left) | 292 static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left) |
277 { | 293 { |
278 while (bits_left >= 16) { | 294 while (bits_left >= 16) { |
292 int quant, dc, dct_mode, class1, j; | 308 int quant, dc, dct_mode, class1, j; |
293 int mb_index, mb_x, mb_y, v, last_index; | 309 int mb_index, mb_x, mb_y, v, last_index; |
294 DCTELEM *block, *block1; | 310 DCTELEM *block, *block1; |
295 int c_offset, bits_left; | 311 int c_offset, bits_left; |
296 UINT8 *y_ptr; | 312 UINT8 *y_ptr; |
297 MBInfo mb_data[5], *mb; | 313 BlockInfo mb_data[5 * 6], *mb, *mb1; |
298 void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block); | 314 void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block); |
299 UINT8 *buf_ptr; | 315 UINT8 *buf_ptr; |
300 PutBitContext pb, vs_pb; | 316 PutBitContext pb, vs_pb; |
301 UINT8 vs_bit_buffer[5 * 80 + 4]; | 317 UINT8 mb_bit_buffer[80 + 4]; /* allow some slack */ |
318 int mb_bit_count; | |
319 UINT8 vs_bit_buffer[5 * 80 + 4]; /* allow some slack */ | |
302 int vs_bit_count; | 320 int vs_bit_count; |
303 | 321 |
304 memset(s->block, 0, sizeof(s->block)); | 322 memset(s->block, 0, sizeof(s->block)); |
305 | 323 |
306 /* pass 1 : read DC and AC coefficients in blocks */ | 324 /* pass 1 : read DC and AC coefficients in blocks */ |
307 buf_ptr = buf_ptr1; | 325 buf_ptr = buf_ptr1; |
308 block1 = &s->block[0][0]; | 326 block1 = &s->block[0][0]; |
309 mb = mb_data; | 327 mb1 = mb_data; |
310 init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL); | 328 init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL); |
311 vs_bit_count = 0; | 329 vs_bit_count = 0; |
312 for(mb_index = 0; mb_index < 5; mb_index++) { | 330 for(mb_index = 0; mb_index < 5; mb_index++) { |
313 /* skip header */ | 331 /* skip header */ |
314 quant = buf_ptr[3] & 0x0f; | 332 quant = buf_ptr[3] & 0x0f; |
315 buf_ptr += 4; | 333 buf_ptr += 4; |
316 init_put_bits(&pb, mb->bit_buffer, 80, NULL, NULL); | 334 init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL); |
317 mb->bits_left = 0; | 335 mb_bit_count = 0; |
336 mb = mb1; | |
318 block = block1; | 337 block = block1; |
319 for(j = 0;j < 6; j++) { | 338 for(j = 0;j < 6; j++) { |
320 /* NOTE: size is not important here */ | 339 /* NOTE: size is not important here */ |
321 init_get_bits(&s->gb, buf_ptr, 14); | 340 init_get_bits(&s->gb, buf_ptr, 14); |
322 | 341 |
323 /* get the dc */ | 342 /* get the dc */ |
324 dc = get_bits(&s->gb, 9); | 343 dc = get_bits(&s->gb, 9); |
325 dc = (dc << (32 - 9)) >> (32 - 9); | 344 dc = (dc << (32 - 9)) >> (32 - 9); |
326 dct_mode = get_bits1(&s->gb); | 345 dct_mode = get_bits1(&s->gb); |
327 mb->dct_mode[j] = dct_mode; | 346 mb->dct_mode = dct_mode; |
328 mb->scan_table[j] = s->dv_zigzag[dct_mode]; | 347 mb->scan_table = s->dv_zigzag[dct_mode]; |
329 class1 = get_bits(&s->gb, 2); | 348 class1 = get_bits(&s->gb, 2); |
330 mb->shift_table[j] = s->dv_shift[dct_mode][class1 == 3] | 349 mb->shift_offset = (class1 == 3); |
350 mb->shift_table = s->dv_shift[dct_mode] | |
331 [quant + dv_quant_offset[class1]]; | 351 [quant + dv_quant_offset[class1]]; |
332 dc = dc << 2; | 352 dc = dc << 2; |
333 /* convert to unsigned because 128 is not added in the | 353 /* convert to unsigned because 128 is not added in the |
334 standard IDCT */ | 354 standard IDCT */ |
335 dc += 1024; | 355 dc += 1024; |
336 block[0] = dc; | 356 block[0] = dc; |
337 last_index = block_sizes[j]; | 357 last_index = block_sizes[j]; |
338 buf_ptr += last_index >> 3; | 358 buf_ptr += last_index >> 3; |
339 mb->pos[j] = 0; | 359 mb->pos = 0; |
340 mb->partial_bit_count[j] = 0; | 360 mb->partial_bit_count = 0; |
341 | 361 |
342 dv_decode_ac(s, mb, block, j, last_index); | 362 dv_decode_ac(s, mb, block, last_index); |
343 | 363 |
344 /* write the remaining bits in a new buffer only if the | 364 /* write the remaining bits in a new buffer only if the |
345 block is finished */ | 365 block is finished */ |
346 bits_left = last_index - s->gb.index; | 366 bits_left = last_index - s->gb.index; |
347 if (mb->eob_reached[j]) { | 367 if (mb->eob_reached) { |
348 mb->partial_bit_count[j] = 0; | 368 mb->partial_bit_count = 0; |
349 mb->bits_left += bits_left; | 369 mb_bit_count += bits_left; |
350 bit_copy(&pb, &s->gb, bits_left); | 370 bit_copy(&pb, &s->gb, bits_left); |
351 } else { | 371 } else { |
352 /* should be < 16 bits otherwise a codeword could have | 372 /* should be < 16 bits otherwise a codeword could have |
353 been parsed */ | 373 been parsed */ |
354 mb->partial_bit_count[j] = bits_left; | 374 mb->partial_bit_count = bits_left; |
355 mb->partial_bit_buffer[j] = get_bits(&s->gb, bits_left); | 375 mb->partial_bit_buffer = get_bits(&s->gb, bits_left); |
356 } | 376 } |
357 block += 64; | 377 block += 64; |
378 mb++; | |
358 } | 379 } |
359 | 380 |
360 flush_put_bits(&pb); | 381 flush_put_bits(&pb); |
361 | 382 |
362 /* pass 2 : we can do it just after */ | 383 /* pass 2 : we can do it just after */ |
363 #ifdef VLC_DEBUG | 384 #ifdef VLC_DEBUG |
364 printf("***pass 2 size=%d\n", mb->bits_left); | 385 printf("***pass 2 size=%d\n", mb_bit_count); |
365 #endif | 386 #endif |
366 block = block1; | 387 block = block1; |
367 init_get_bits(&s->gb, mb->bit_buffer, 80); | 388 mb = mb1; |
389 init_get_bits(&s->gb, mb_bit_buffer, 80); | |
368 for(j = 0;j < 6; j++) { | 390 for(j = 0;j < 6; j++) { |
369 if (!mb->eob_reached[j] && s->gb.index < mb->bits_left) { | 391 if (!mb->eob_reached && s->gb.index < mb_bit_count) { |
370 dv_decode_ac(s, mb, block, j, mb->bits_left); | 392 dv_decode_ac(s, mb, block, mb_bit_count); |
371 /* if still not finished, no need to parse other blocks */ | 393 /* if still not finished, no need to parse other blocks */ |
372 if (!mb->eob_reached[j]) { | 394 if (!mb->eob_reached) { |
373 /* we could not parse the current AC coefficient, | 395 /* we could not parse the current AC coefficient, |
374 so we add the remaining bytes */ | 396 so we add the remaining bytes */ |
375 bits_left = mb->bits_left - s->gb.index; | 397 bits_left = mb_bit_count - s->gb.index; |
376 if (bits_left > 0) { | 398 if (bits_left > 0) { |
377 mb->partial_bit_count[j] += bits_left; | 399 mb->partial_bit_count += bits_left; |
378 mb->partial_bit_buffer[j] = | 400 mb->partial_bit_buffer = |
379 (mb->partial_bit_buffer[j] << bits_left) | | 401 (mb->partial_bit_buffer << bits_left) | |
380 get_bits(&s->gb, bits_left); | 402 get_bits(&s->gb, bits_left); |
381 } | 403 } |
382 goto next_mb; | 404 goto next_mb; |
383 } | 405 } |
384 } | 406 } |
385 block += 64; | 407 block += 64; |
408 mb++; | |
386 } | 409 } |
387 /* all blocks are finished, so the extra bytes can be used at | 410 /* all blocks are finished, so the extra bytes can be used at |
388 the video segment level */ | 411 the video segment level */ |
389 bits_left = mb->bits_left - s->gb.index; | 412 bits_left = mb_bit_count - s->gb.index; |
390 vs_bit_count += bits_left; | 413 vs_bit_count += bits_left; |
391 bit_copy(&vs_pb, &s->gb, bits_left); | 414 bit_copy(&vs_pb, &s->gb, bits_left); |
392 next_mb: | 415 next_mb: |
393 mb++; | 416 mb1 += 6; |
394 block1 += 6 * 64; | 417 block1 += 6 * 64; |
395 } | 418 } |
396 | 419 |
397 /* we need a pass other the whole video segment */ | 420 /* we need a pass other the whole video segment */ |
398 flush_put_bits(&vs_pb); | 421 flush_put_bits(&vs_pb); |
403 block = &s->block[0][0]; | 426 block = &s->block[0][0]; |
404 mb = mb_data; | 427 mb = mb_data; |
405 init_get_bits(&s->gb, vs_bit_buffer, 5 * 80); | 428 init_get_bits(&s->gb, vs_bit_buffer, 5 * 80); |
406 for(mb_index = 0; mb_index < 5; mb_index++) { | 429 for(mb_index = 0; mb_index < 5; mb_index++) { |
407 for(j = 0;j < 6; j++) { | 430 for(j = 0;j < 6; j++) { |
408 if (!mb->eob_reached[j]) { | 431 if (!mb->eob_reached) { |
409 #ifdef VLC_DEBUG | 432 #ifdef VLC_DEBUG |
410 printf("start %d:%d\n", mb_index, j); | 433 printf("start %d:%d\n", mb_index, j); |
411 #endif | 434 #endif |
412 dv_decode_ac(s, mb, block, j, vs_bit_count); | 435 dv_decode_ac(s, mb, block, vs_bit_count); |
413 } | 436 } |
414 block += 64; | 437 block += 64; |
415 } | 438 mb++; |
416 mb++; | 439 } |
417 } | 440 } |
418 | 441 |
419 /* compute idct and place blocks */ | 442 /* compute idct and place blocks */ |
420 block = &s->block[0][0]; | 443 block = &s->block[0][0]; |
421 mb = mb_data; | 444 mb = mb_data; |
427 if (s->sampling_411) | 450 if (s->sampling_411) |
428 c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8); | 451 c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8); |
429 else | 452 else |
430 c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8); | 453 c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8); |
431 for(j = 0;j < 6; j++) { | 454 for(j = 0;j < 6; j++) { |
432 idct_put = s->idct_put[mb->dct_mode[j]]; | 455 idct_put = s->idct_put[mb->dct_mode]; |
433 if (j < 4) { | 456 if (j < 4) { |
434 if (s->sampling_411) { | 457 if (s->sampling_411) { |
435 idct_put(y_ptr + (j * 8), s->linesize[0], block); | 458 idct_put(y_ptr + (j * 8), s->linesize[0], block); |
436 } else { | 459 } else { |
437 idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]), | 460 idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]), |
441 /* don't ask me why they inverted Cb and Cr ! */ | 464 /* don't ask me why they inverted Cb and Cr ! */ |
442 idct_put(s->current_picture[6 - j] + c_offset, | 465 idct_put(s->current_picture[6 - j] + c_offset, |
443 s->linesize[6 - j], block); | 466 s->linesize[6 - j], block); |
444 } | 467 } |
445 block += 64; | 468 block += 64; |
446 } | 469 mb++; |
447 mb++; | 470 } |
448 } | 471 } |
449 } | 472 } |
450 | 473 |
451 | 474 |
452 /* NOTE: exactly one frame must be given (120000 bytes for NTSC, | 475 /* NOTE: exactly one frame must be given (120000 bytes for NTSC, |