Mercurial > libavcodec.hg
comparison vp3.c @ 3488:a647bf3a7fa8 libavcodec
replace *_dequant (2 intra, 1 inter) by qmat (3 intra, 3 inter) (needed for theora according to spec)
author | michael |
---|---|
date | Mon, 17 Jul 2006 08:09:08 +0000 |
parents | 26d3704e12c0 |
children | 9aacd9410e57 |
comparison
equal
deleted
inserted
replaced
3487:26d3704e12c0 | 3488:a647bf3a7fa8 |
---|---|
283 VLC mode_code_vlc; | 283 VLC mode_code_vlc; |
284 VLC motion_vector_vlc; | 284 VLC motion_vector_vlc; |
285 | 285 |
286 /* these arrays need to be on 16-byte boundaries since SSE2 operations | 286 /* these arrays need to be on 16-byte boundaries since SSE2 operations |
287 * index into them */ | 287 * index into them */ |
288 DECLARE_ALIGNED_16(int16_t, intra_y_dequant[64]); | 288 DECLARE_ALIGNED_16(int16_t, qmat[2][4][64]); //<qmat[is_inter][plane] |
289 DECLARE_ALIGNED_16(int16_t, intra_c_dequant[64]); | |
290 DECLARE_ALIGNED_16(int16_t, inter_dequant[64]); | |
291 | 289 |
292 /* This table contains superblock_count * 16 entries. Each set of 16 | 290 /* This table contains superblock_count * 16 entries. Each set of 16 |
293 * numbers corresponds to the fragment indices 0..15 of the superblock. | 291 * numbers corresponds to the fragment indices 0..15 of the superblock. |
294 * An entry will be -1 to indicate that no entry corresponds to that | 292 * An entry will be -1 to indicate that no entry corresponds to that |
295 * index. */ | 293 * index. */ |
665 * Then, saturate the result to a lower limit of MIN_DEQUANT_VAL. | 663 * Then, saturate the result to a lower limit of MIN_DEQUANT_VAL. |
666 */ | 664 */ |
667 #define SCALER 4 | 665 #define SCALER 4 |
668 | 666 |
669 /* scale DC quantizers */ | 667 /* scale DC quantizers */ |
670 s->intra_y_dequant[0] = s->coded_intra_y_dequant[0] * dc_scale_factor / 100; | 668 s->qmat[0][0][0] = s->coded_intra_y_dequant[0] * dc_scale_factor / 100; |
671 if (s->intra_y_dequant[0] < MIN_DEQUANT_VAL * 2) | 669 if (s->qmat[0][0][0] < MIN_DEQUANT_VAL * 2) |
672 s->intra_y_dequant[0] = MIN_DEQUANT_VAL * 2; | 670 s->qmat[0][0][0] = MIN_DEQUANT_VAL * 2; |
673 s->intra_y_dequant[0] *= SCALER; | 671 s->qmat[0][0][0] *= SCALER; |
674 | 672 |
675 s->intra_c_dequant[0] = s->coded_intra_c_dequant[0] * dc_scale_factor / 100; | 673 s->qmat[0][1][0] = s->coded_intra_c_dequant[0] * dc_scale_factor / 100; |
676 if (s->intra_c_dequant[0] < MIN_DEQUANT_VAL * 2) | 674 if (s->qmat[0][1][0] < MIN_DEQUANT_VAL * 2) |
677 s->intra_c_dequant[0] = MIN_DEQUANT_VAL * 2; | 675 s->qmat[0][1][0] = MIN_DEQUANT_VAL * 2; |
678 s->intra_c_dequant[0] *= SCALER; | 676 s->qmat[0][1][0] *= SCALER; |
679 | 677 |
680 s->inter_dequant[0] = s->coded_inter_dequant[0] * dc_scale_factor / 100; | 678 s->qmat[1][0][0] = s->coded_inter_dequant[0] * dc_scale_factor / 100; |
681 if (s->inter_dequant[0] < MIN_DEQUANT_VAL * 4) | 679 if (s->qmat[1][0][0] < MIN_DEQUANT_VAL * 4) |
682 s->inter_dequant[0] = MIN_DEQUANT_VAL * 4; | 680 s->qmat[1][0][0] = MIN_DEQUANT_VAL * 4; |
683 s->inter_dequant[0] *= SCALER; | 681 s->qmat[1][0][0] *= SCALER; |
684 | 682 |
685 /* scale AC quantizers, zigzag at the same time in preparation for | 683 /* scale AC quantizers, zigzag at the same time in preparation for |
686 * the dequantization phase */ | 684 * the dequantization phase */ |
687 for (i = 1; i < 64; i++) { | 685 for (i = 1; i < 64; i++) { |
688 int k= s->scantable.scantable[i]; | 686 int k= s->scantable.scantable[i]; |
689 j = s->scantable.permutated[i]; | 687 j = s->scantable.permutated[i]; |
690 | 688 |
691 s->intra_y_dequant[j] = s->coded_intra_y_dequant[k] * ac_scale_factor / 100; | 689 s->qmat[0][0][j] = s->coded_intra_y_dequant[k] * ac_scale_factor / 100; |
692 if (s->intra_y_dequant[j] < MIN_DEQUANT_VAL) | 690 if (s->qmat[0][0][j] < MIN_DEQUANT_VAL) |
693 s->intra_y_dequant[j] = MIN_DEQUANT_VAL; | 691 s->qmat[0][0][j] = MIN_DEQUANT_VAL; |
694 s->intra_y_dequant[j] *= SCALER; | 692 s->qmat[0][0][j] *= SCALER; |
695 | 693 |
696 s->intra_c_dequant[j] = s->coded_intra_c_dequant[k] * ac_scale_factor / 100; | 694 s->qmat[0][1][j] = s->coded_intra_c_dequant[k] * ac_scale_factor / 100; |
697 if (s->intra_c_dequant[j] < MIN_DEQUANT_VAL) | 695 if (s->qmat[0][1][j] < MIN_DEQUANT_VAL) |
698 s->intra_c_dequant[j] = MIN_DEQUANT_VAL; | 696 s->qmat[0][1][j] = MIN_DEQUANT_VAL; |
699 s->intra_c_dequant[j] *= SCALER; | 697 s->qmat[0][1][j] *= SCALER; |
700 | 698 |
701 s->inter_dequant[j] = s->coded_inter_dequant[k] * ac_scale_factor / 100; | 699 s->qmat[1][0][j] = s->coded_inter_dequant[k] * ac_scale_factor / 100; |
702 if (s->inter_dequant[j] < MIN_DEQUANT_VAL * 2) | 700 if (s->qmat[1][0][j] < MIN_DEQUANT_VAL * 2) |
703 s->inter_dequant[j] = MIN_DEQUANT_VAL * 2; | 701 s->qmat[1][0][j] = MIN_DEQUANT_VAL * 2; |
704 s->inter_dequant[j] *= SCALER; | 702 s->qmat[1][0][j] *= SCALER; |
705 } | 703 } |
706 | 704 |
707 memset(s->qscale_table, (FFMAX(s->intra_y_dequant[1], s->intra_c_dequant[1])+8)/16, 512); //FIXME finetune | 705 memcpy(s->qmat[0][2], s->qmat[0][1], sizeof(s->qmat[0][0])); |
706 memcpy(s->qmat[1][1], s->qmat[1][0], sizeof(s->qmat[0][0])); | |
707 memcpy(s->qmat[1][2], s->qmat[1][0], sizeof(s->qmat[0][0])); | |
708 | |
709 memset(s->qscale_table, (FFMAX(s->qmat[0][0][1], s->qmat[0][1][1])+8)/16, 512); //FIXME finetune | |
708 | 710 |
709 /* print debug information as requested */ | 711 /* print debug information as requested */ |
710 debug_dequantizers("intra Y dequantizers:\n"); | 712 debug_dequantizers("intra Y dequantizers:\n"); |
711 for (i = 0; i < 8; i++) { | 713 for (i = 0; i < 8; i++) { |
712 for (j = i * 8; j < i * 8 + 8; j++) { | 714 for (j = i * 8; j < i * 8 + 8; j++) { |
713 debug_dequantizers(" %4d,", s->intra_y_dequant[j]); | 715 debug_dequantizers(" %4d,", s->qmat[0][0][j]); |
714 } | 716 } |
715 debug_dequantizers("\n"); | 717 debug_dequantizers("\n"); |
716 } | 718 } |
717 debug_dequantizers("\n"); | 719 debug_dequantizers("\n"); |
718 | 720 |
719 debug_dequantizers("intra C dequantizers:\n"); | 721 debug_dequantizers("intra C dequantizers:\n"); |
720 for (i = 0; i < 8; i++) { | 722 for (i = 0; i < 8; i++) { |
721 for (j = i * 8; j < i * 8 + 8; j++) { | 723 for (j = i * 8; j < i * 8 + 8; j++) { |
722 debug_dequantizers(" %4d,", s->intra_c_dequant[j]); | 724 debug_dequantizers(" %4d,", s->qmat[0][1][j]); |
723 } | 725 } |
724 debug_dequantizers("\n"); | 726 debug_dequantizers("\n"); |
725 } | 727 } |
726 debug_dequantizers("\n"); | 728 debug_dequantizers("\n"); |
727 | 729 |
728 debug_dequantizers("interframe dequantizers:\n"); | 730 debug_dequantizers("interframe dequantizers:\n"); |
729 for (i = 0; i < 8; i++) { | 731 for (i = 0; i < 8; i++) { |
730 for (j = i * 8; j < i * 8 + 8; j++) { | 732 for (j = i * 8; j < i * 8 + 8; j++) { |
731 debug_dequantizers(" %4d,", s->inter_dequant[j]); | 733 debug_dequantizers(" %4d,", s->qmat[1][0][j]); |
732 } | 734 } |
733 debug_dequantizers("\n"); | 735 debug_dequantizers("\n"); |
734 } | 736 } |
735 debug_dequantizers("\n"); | 737 debug_dequantizers("\n"); |
736 } | 738 } |
1845 output_plane + s->all_fragments[i].first_pixel, | 1847 output_plane + s->all_fragments[i].first_pixel, |
1846 motion_source - d, | 1848 motion_source - d, |
1847 motion_source + stride + 1 + d, | 1849 motion_source + stride + 1 + d, |
1848 stride, 8); | 1850 stride, 8); |
1849 } | 1851 } |
1850 dequantizer = s->inter_dequant; | 1852 dequantizer = s->qmat[1][plane]; |
1851 }else{ | 1853 }else{ |
1852 if (plane == 0) | 1854 dequantizer = s->qmat[0][plane]; |
1853 dequantizer = s->intra_y_dequant; | |
1854 else | |
1855 dequantizer = s->intra_c_dequant; | |
1856 } | 1855 } |
1857 | 1856 |
1858 /* dequantize the DCT coefficients */ | 1857 /* dequantize the DCT coefficients */ |
1859 debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", | 1858 debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", |
1860 i, s->all_fragments[i].coding_method, | 1859 i, s->all_fragments[i].coding_method, |