Mercurial > libavcodec.hg
comparison dv.c @ 7706:a7ebe82c6331 libavcodec
Simplification of how dct_mode affects decoding.
| author | romansh |
|---|---|
| date | Wed, 27 Aug 2008 20:17:01 +0000 |
| parents | 685ef77c9fe5 |
| children | beabdadf79e6 |
comparison
equal
deleted
inserted
replaced
| 7705:36b17ee44b76 | 7706:a7ebe82c6331 |
|---|---|
| 245 | 245 |
| 246 typedef struct BlockInfo { | 246 typedef struct BlockInfo { |
| 247 const uint32_t *factor_table; | 247 const uint32_t *factor_table; |
| 248 const uint8_t *scan_table; | 248 const uint8_t *scan_table; |
| 249 uint8_t pos; /* position in block */ | 249 uint8_t pos; /* position in block */ |
| 250 uint8_t dct_mode; | 250 void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); |
| 251 uint8_t partial_bit_count; | 251 uint8_t partial_bit_count; |
| 252 uint16_t partial_bit_buffer; | 252 uint16_t partial_bit_buffer; |
| 253 int shift_offset; | 253 int shift_offset; |
| 254 } BlockInfo; | 254 } BlockInfo; |
| 255 | 255 |
| 350 int quant, dc, dct_mode, class1, j; | 350 int quant, dc, dct_mode, class1, j; |
| 351 int mb_index, mb_x, mb_y, v, last_index; | 351 int mb_index, mb_x, mb_y, v, last_index; |
| 352 DCTELEM *block, *block1; | 352 DCTELEM *block, *block1; |
| 353 int c_offset; | 353 int c_offset; |
| 354 uint8_t *y_ptr; | 354 uint8_t *y_ptr; |
| 355 void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); | |
| 356 const uint8_t *buf_ptr; | 355 const uint8_t *buf_ptr; |
| 357 PutBitContext pb, vs_pb; | 356 PutBitContext pb, vs_pb; |
| 358 GetBitContext gb; | 357 GetBitContext gb; |
| 359 BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; | 358 BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; |
| 360 DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]); | 359 DECLARE_ALIGNED_16(DCTELEM, sblock[5*DV_MAX_BPM][64]); |
| 384 init_get_bits(&gb, buf_ptr, last_index); | 383 init_get_bits(&gb, buf_ptr, last_index); |
| 385 | 384 |
| 386 /* get the dc */ | 385 /* get the dc */ |
| 387 dc = get_sbits(&gb, 9); | 386 dc = get_sbits(&gb, 9); |
| 388 dct_mode = get_bits1(&gb); | 387 dct_mode = get_bits1(&gb); |
| 389 mb->dct_mode = dct_mode; | 388 mb->idct_put = s->idct_put[dct_mode && log2_blocksize==3]; |
| 390 mb->scan_table = s->dv_zigzag[dct_mode]; | 389 mb->scan_table = s->dv_zigzag[dct_mode]; |
| 391 class1 = get_bits(&gb, 2); | 390 class1 = get_bits(&gb, 2); |
| 392 mb->factor_table = s->dv_idct_factor[class1 == 3][dct_mode] | 391 mb->factor_table = s->dv_idct_factor[class1 == 3][dct_mode] |
| 393 [quant + dv_quant_offset[class1]]; | 392 [quant + dv_quant_offset[class1]]; |
| 394 dc = dc << 2; | 393 dc = dc << 2; |
| 469 y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize); | 468 y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize); |
| 470 c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] + | 469 c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] + |
| 471 (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<log2_blocksize); | 470 (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<log2_blocksize); |
| 472 | 471 |
| 473 for(j = 0;j < 6; j++) { | 472 for(j = 0;j < 6; j++) { |
| 474 idct_put = s->idct_put[mb->dct_mode && log2_blocksize==3]; | |
| 475 if (s->sys->pix_fmt == PIX_FMT_YUV422P) { /* 4:2:2 */ | 473 if (s->sys->pix_fmt == PIX_FMT_YUV422P) { /* 4:2:2 */ |
| 476 if (j == 0 || j == 2) { | 474 if (j == 0 || j == 2) { |
| 477 /* Y0 Y1 */ | 475 /* Y0 Y1 */ |
| 478 idct_put(y_ptr + ((j >> 1)<<log2_blocksize), | 476 mb->idct_put(y_ptr + ((j >> 1)<<log2_blocksize), |
| 479 s->picture.linesize[0], block); | 477 s->picture.linesize[0], block); |
| 480 } else if(j > 3) { | 478 } else if(j > 3) { |
| 481 /* Cr Cb */ | 479 /* Cr Cb */ |
| 482 idct_put(s->picture.data[6 - j] + c_offset, | 480 mb->idct_put(s->picture.data[6 - j] + c_offset, |
| 483 s->picture.linesize[6 - j], block); | 481 s->picture.linesize[6 - j], block); |
| 484 } | 482 } |
| 485 /* note: j=1 and j=3 are "dummy" blocks in 4:2:2 */ | 483 /* note: j=1 and j=3 are "dummy" blocks in 4:2:2 */ |
| 486 } else { /* 4:1:1 or 4:2:0 */ | 484 } else { /* 4:1:1 or 4:2:0 */ |
| 487 if (j < 4) { | 485 if (j < 4) { |
| 488 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) { | 486 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x < (704 / 8)) { |
| 489 /* NOTE: at end of line, the macroblock is handled as 420 */ | 487 /* NOTE: at end of line, the macroblock is handled as 420 */ |
| 490 idct_put(y_ptr + (j<<log2_blocksize), s->picture.linesize[0], block); | 488 mb->idct_put(y_ptr + (j<<log2_blocksize), s->picture.linesize[0], block); |
| 491 } else { | 489 } else { |
| 492 idct_put(y_ptr + (((j & 1) + (j >> 1) * s->picture.linesize[0])<<log2_blocksize), | 490 mb->idct_put(y_ptr + (((j & 1) + (j >> 1) * s->picture.linesize[0])<<log2_blocksize), |
| 493 s->picture.linesize[0], block); | 491 s->picture.linesize[0], block); |
| 494 } | 492 } |
| 495 } else { | 493 } else { |
| 496 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) { | 494 if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) { |
| 497 uint64_t aligned_pixels[64/8]; | 495 uint64_t aligned_pixels[64/8]; |
| 498 uint8_t *pixels= (uint8_t*)aligned_pixels; | 496 uint8_t *pixels= (uint8_t*)aligned_pixels; |
| 499 uint8_t *c_ptr, *c_ptr1, *ptr, *ptr1; | 497 uint8_t *c_ptr, *c_ptr1, *ptr, *ptr1; |
| 500 int x, y, linesize; | 498 int x, y, linesize; |
| 501 /* NOTE: at end of line, the macroblock is handled as 420 */ | 499 /* NOTE: at end of line, the macroblock is handled as 420 */ |
| 502 idct_put(pixels, 8, block); | 500 mb->idct_put(pixels, 8, block); |
| 503 linesize = s->picture.linesize[6 - j]; | 501 linesize = s->picture.linesize[6 - j]; |
| 504 c_ptr = s->picture.data[6 - j] + c_offset; | 502 c_ptr = s->picture.data[6 - j] + c_offset; |
| 505 ptr = pixels; | 503 ptr = pixels; |
| 506 for(y = 0;y < (1<<log2_blocksize); y++) { | 504 for(y = 0;y < (1<<log2_blocksize); y++) { |
| 507 ptr1= ptr + (1<<(log2_blocksize-1)); | 505 ptr1= ptr + (1<<(log2_blocksize-1)); |
| 512 c_ptr += linesize; | 510 c_ptr += linesize; |
| 513 ptr += 8; | 511 ptr += 8; |
| 514 } | 512 } |
| 515 } else { | 513 } else { |
| 516 /* don't ask me why they inverted Cb and Cr ! */ | 514 /* don't ask me why they inverted Cb and Cr ! */ |
| 517 idct_put(s->picture.data[6 - j] + c_offset, | 515 mb->idct_put(s->picture.data[6 - j] + c_offset, |
| 518 s->picture.linesize[6 - j], block); | 516 s->picture.linesize[6 - j], block); |
| 519 } | 517 } |
| 520 } | 518 } |
| 521 } | 519 } |
| 522 block += 64; | 520 block += 64; |
