OLD | NEW |
1 /* | 1 /* |
2 * H.26L/H.264/AVC/JVT/14496-10/... cabac decoding | 2 * H.26L/H.264/AVC/JVT/14496-10/... cabac decoding |
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | 3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 }, | 681 { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 }, |
682 { -14, 59 }, { -9, 52 }, { -11, 68 }, { 9, -2 }, | 682 { -14, 59 }, { -9, 52 }, { -11, 68 }, { 9, -2 }, |
683 { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 }, | 683 { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 }, |
684 { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 }, | 684 { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 }, |
685 } | 685 } |
686 }; | 686 }; |
687 | 687 |
688 void ff_h264_init_cabac_states(H264Context *h) { | 688 void ff_h264_init_cabac_states(H264Context *h) { |
689 MpegEncContext * const s = &h->s; | 689 MpegEncContext * const s = &h->s; |
690 int i; | 690 int i; |
| 691 const int8_t (*tab)[2]; |
| 692 |
| 693 if( h->slice_type_nos == FF_I_TYPE ) tab = cabac_context_init_I; |
| 694 else tab = cabac_context_init_PB[h->cabac_in
it_idc]; |
691 | 695 |
692 /* calculate pre-state */ | 696 /* calculate pre-state */ |
693 for( i= 0; i < 460; i++ ) { | 697 for( i= 0; i < 460; i++ ) { |
694 int pre; | 698 int pre = 2*(((tab[i][0] * s->qscale) >>4 ) + tab[i][1]) - 127; |
695 if( h->slice_type_nos == FF_I_TYPE ) | |
696 pre = av_clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cab
ac_context_init_I[i][1], 1, 126 ); | |
697 else | |
698 pre = av_clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s-
>qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 ); | |
699 | 699 |
700 if( pre <= 63 ) | 700 pre^= pre>>31; |
701 h->cabac_state[i] = 2 * ( 63 - pre ) + 0; | 701 if(pre > 124) |
702 else | 702 pre= 124 + (pre&1); |
703 h->cabac_state[i] = 2 * ( pre - 64 ) + 1; | 703 |
| 704 h->cabac_state[i] = pre; |
704 } | 705 } |
705 } | 706 } |
706 | 707 |
707 static int decode_cabac_field_decoding_flag(H264Context *h) { | 708 static int decode_cabac_field_decoding_flag(H264Context *h) { |
708 MpegEncContext * const s = &h->s; | 709 MpegEncContext * const s = &h->s; |
709 const long mba_xy = h->mb_xy - 1L; | |
710 const long mbb_xy = h->mb_xy - 2L*s->mb_stride; | 710 const long mbb_xy = h->mb_xy - 2L*s->mb_stride; |
711 | 711 |
712 unsigned long ctx = 0; | 712 unsigned long ctx = 0; |
713 | 713 |
714 ctx += (s->current_picture.mb_type[mba_xy]>>7)&(h->slice_table[mba_xy] == h-
>slice_num); | 714 ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.
mb_type[mba_xy]>>7)&(h->slice_table[mba_xy] == h->slice_num); |
715 ctx += (s->current_picture.mb_type[mbb_xy]>>7)&(h->slice_table[mbb_xy] == h-
>slice_num); | 715 ctx += (s->current_picture.mb_type[mbb_xy]>>7)&(h->slice_table[mbb_xy] == h-
>slice_num); |
716 | 716 |
717 return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] ); | 717 return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] ); |
718 } | 718 } |
719 | 719 |
720 static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl
ice) { | 720 static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl
ice) { |
721 uint8_t *state= &h->cabac_state[ctx_base]; | 721 uint8_t *state= &h->cabac_state[ctx_base]; |
722 int mb_type; | 722 int mb_type; |
723 | 723 |
724 if(intra_slice){ | 724 if(intra_slice){ |
725 MpegEncContext * const s = &h->s; | |
726 const int mba_xy = h->left_mb_xy[0]; | |
727 const int mbb_xy = h->top_mb_xy; | |
728 int ctx=0; | 725 int ctx=0; |
729 if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_p
icture.mb_type[mba_xy] ) ) | 726 if( h->left_type[0] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) |
730 ctx++; | 727 ctx++; |
731 if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_p
icture.mb_type[mbb_xy] ) ) | 728 if( h->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)) |
732 ctx++; | 729 ctx++; |
733 if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 ) | 730 if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 ) |
734 return 0; /* I4x4 */ | 731 return 0; /* I4x4 */ |
735 state += 2; | 732 state += 2; |
736 }else{ | 733 }else{ |
737 if( get_cabac_noinline( &h->cabac, state ) == 0 ) | 734 if( get_cabac_noinline( &h->cabac, state ) == 0 ) |
738 return 0; /* I4x4 */ | 735 return 0; /* I4x4 */ |
739 } | 736 } |
740 | 737 |
741 if( get_cabac_terminate( &h->cabac ) ) | 738 if( get_cabac_terminate( &h->cabac ) ) |
742 return 25; /* PCM */ | 739 return 25; /* PCM */ |
743 | 740 |
744 mb_type = 1; /* I16x16 */ | 741 mb_type = 1; /* I16x16 */ |
745 mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] ); /* cbp_luma != 0
*/ | 742 mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] ); /* cbp_luma != 0
*/ |
746 if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */ | 743 if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */ |
747 mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice]
); | 744 mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice]
); |
748 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] ); | 745 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] ); |
749 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] ); | 746 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] ); |
750 return mb_type; | 747 return mb_type; |
751 } | 748 } |
752 | 749 |
753 static int decode_cabac_mb_type_b( H264Context *h ) { | |
754 MpegEncContext * const s = &h->s; | |
755 | |
756 const int mba_xy = h->left_mb_xy[0]; | |
757 const int mbb_xy = h->top_mb_xy; | |
758 int ctx = 0; | |
759 int bits; | |
760 assert(h->slice_type_nos == FF_B_TYPE); | |
761 | |
762 if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_pic
ture.mb_type[mba_xy] ) ) | |
763 ctx++; | |
764 if( h->slice_table[mbb_xy] == h->slice_num && !IS_DIRECT( s->current_pic
ture.mb_type[mbb_xy] ) ) | |
765 ctx++; | |
766 | |
767 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ) | |
768 return 0; /* B_Direct_16x16 */ | |
769 | |
770 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) { | |
771 return 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); /
* B_L[01]_16x16 */ | |
772 } | |
773 | |
774 bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3; | |
775 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2; | |
776 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1; | |
777 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); | |
778 if( bits < 8 ) | |
779 return bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ | |
780 else if( bits == 13 ) { | |
781 return decode_cabac_intra_mb_type(h, 32, 0) + 23; | |
782 } else if( bits == 14 ) | |
783 return 11; /* B_L1_L0_8x16 */ | |
784 else if( bits == 15 ) | |
785 return 22; /* B_8x8 */ | |
786 | |
787 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5]
); | |
788 return bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */ | |
789 } | |
790 | |
791 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { | 750 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { |
792 MpegEncContext * const s = &h->s; | 751 MpegEncContext * const s = &h->s; |
793 int mba_xy, mbb_xy; | 752 int mba_xy, mbb_xy; |
794 int ctx = 0; | 753 int ctx = 0; |
795 | 754 |
796 if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches? | 755 if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches? |
797 int mb_xy = mb_x + (mb_y&~1)*s->mb_stride; | 756 int mb_xy = mb_x + (mb_y&~1)*s->mb_stride; |
798 mba_xy = mb_xy - 1; | 757 mba_xy = mb_xy - 1; |
799 if( (mb_y&1) | 758 if( (mb_y&1) |
800 && h->slice_table[mba_xy] == h->slice_num | 759 && h->slice_table[mba_xy] == h->slice_num |
(...skipping 26 matching lines...) Expand all Loading... |
827 static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) { | 786 static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) { |
828 int mode = 0; | 787 int mode = 0; |
829 | 788 |
830 if( get_cabac( &h->cabac, &h->cabac_state[68] ) ) | 789 if( get_cabac( &h->cabac, &h->cabac_state[68] ) ) |
831 return pred_mode; | 790 return pred_mode; |
832 | 791 |
833 mode += 1 * get_cabac( &h->cabac, &h->cabac_state[69] ); | 792 mode += 1 * get_cabac( &h->cabac, &h->cabac_state[69] ); |
834 mode += 2 * get_cabac( &h->cabac, &h->cabac_state[69] ); | 793 mode += 2 * get_cabac( &h->cabac, &h->cabac_state[69] ); |
835 mode += 4 * get_cabac( &h->cabac, &h->cabac_state[69] ); | 794 mode += 4 * get_cabac( &h->cabac, &h->cabac_state[69] ); |
836 | 795 |
837 if( mode >= pred_mode ) | 796 return mode + ( mode >= pred_mode ); |
838 return mode + 1; | |
839 else | |
840 return mode; | |
841 } | 797 } |
842 | 798 |
843 static int decode_cabac_mb_chroma_pre_mode( H264Context *h) { | 799 static int decode_cabac_mb_chroma_pre_mode( H264Context *h) { |
844 const int mba_xy = h->left_mb_xy[0]; | 800 const int mba_xy = h->left_mb_xy[0]; |
845 const int mbb_xy = h->top_mb_xy; | 801 const int mbb_xy = h->top_mb_xy; |
846 | 802 |
847 int ctx = 0; | 803 int ctx = 0; |
848 | 804 |
849 /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_
mode_table to 0 */ | 805 /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_
mode_table to 0 */ |
850 if( h->slice_table[mba_xy] == h->slice_num && h->chroma_pred_mode_table[mba_
xy] != 0 ) | 806 if( h->left_type[0] && h->chroma_pred_mode_table[mba_xy] != 0 ) |
851 ctx++; | 807 ctx++; |
852 | 808 |
853 if( h->slice_table[mbb_xy] == h->slice_num && h->chroma_pred_mode_table[mbb_
xy] != 0 ) | 809 if( h->top_type && h->chroma_pred_mode_table[mbb_xy] != 0 ) |
854 ctx++; | 810 ctx++; |
855 | 811 |
856 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 ) | 812 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 ) |
857 return 0; | 813 return 0; |
858 | 814 |
859 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 ) | 815 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 ) |
860 return 1; | 816 return 1; |
861 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 ) | 817 if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 ) |
862 return 2; | 818 return 2; |
863 else | 819 else |
864 return 3; | 820 return 3; |
865 } | 821 } |
866 | 822 |
867 static int decode_cabac_mb_cbp_luma( H264Context *h) { | 823 static int decode_cabac_mb_cbp_luma( H264Context *h) { |
868 int cbp_b, cbp_a, ctx, cbp = 0; | 824 int cbp_b, cbp_a, ctx, cbp = 0; |
869 | 825 |
870 cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1; | 826 cbp_a = h->left_cbp; |
871 cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1; | 827 cbp_b = h->top_cbp; |
872 | 828 |
873 ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04); | 829 ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04); |
874 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]); | 830 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]); |
875 ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08); | 831 ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08); |
876 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1; | 832 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1; |
877 ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01); | 833 ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01); |
878 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2; | 834 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2; |
879 ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02); | 835 ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02); |
880 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3; | 836 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3; |
881 return cbp; | 837 return cbp; |
882 } | 838 } |
883 static int decode_cabac_mb_cbp_chroma( H264Context *h) { | 839 static int decode_cabac_mb_cbp_chroma( H264Context *h) { |
884 int ctx; | 840 int ctx; |
885 int cbp_a, cbp_b; | 841 int cbp_a, cbp_b; |
886 | 842 |
887 cbp_a = (h->left_cbp>>4)&0x03; | 843 cbp_a = (h->left_cbp>>4)&0x03; |
888 cbp_b = (h-> top_cbp>>4)&0x03; | 844 cbp_b = (h-> top_cbp>>4)&0x03; |
889 | 845 |
890 ctx = 0; | 846 ctx = 0; |
891 if( cbp_a > 0 ) ctx++; | 847 if( cbp_a > 0 ) ctx++; |
892 if( cbp_b > 0 ) ctx += 2; | 848 if( cbp_b > 0 ) ctx += 2; |
893 if( get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] ) == 0 ) | 849 if( get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] ) == 0 ) |
894 return 0; | 850 return 0; |
895 | 851 |
896 ctx = 4; | 852 ctx = 4; |
897 if( cbp_a == 2 ) ctx++; | 853 if( cbp_a == 2 ) ctx++; |
898 if( cbp_b == 2 ) ctx += 2; | 854 if( cbp_b == 2 ) ctx += 2; |
899 return 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] ); | 855 return 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] ); |
900 } | 856 } |
901 static int decode_cabac_mb_dqp( H264Context *h) { | |
902 int ctx= h->last_qscale_diff != 0; | |
903 int val = 0; | |
904 | 857 |
905 while( get_cabac_noinline( &h->cabac, &h->cabac_state[60 + ctx] ) ) { | |
906 ctx= 2+(ctx>>1); | |
907 val++; | |
908 if(val > 102) //prevent infinite loop | |
909 return INT_MIN; | |
910 } | |
911 | |
912 if( val&0x01 ) | |
913 return (val + 1)>>1 ; | |
914 else | |
915 return -((val + 1)>>1); | |
916 } | |
917 static int decode_cabac_p_mb_sub_type( H264Context *h ) { | 858 static int decode_cabac_p_mb_sub_type( H264Context *h ) { |
918 if( get_cabac( &h->cabac, &h->cabac_state[21] ) ) | 859 if( get_cabac( &h->cabac, &h->cabac_state[21] ) ) |
919 return 0; /* 8x8 */ | 860 return 0; /* 8x8 */ |
920 if( !get_cabac( &h->cabac, &h->cabac_state[22] ) ) | 861 if( !get_cabac( &h->cabac, &h->cabac_state[22] ) ) |
921 return 1; /* 8x4 */ | 862 return 1; /* 8x4 */ |
922 if( get_cabac( &h->cabac, &h->cabac_state[23] ) ) | 863 if( get_cabac( &h->cabac, &h->cabac_state[23] ) ) |
923 return 2; /* 4x8 */ | 864 return 2; /* 4x8 */ |
924 return 3; /* 4x4 */ | 865 return 3; /* 4x4 */ |
925 } | 866 } |
926 static int decode_cabac_b_mb_sub_type( H264Context *h ) { | 867 static int decode_cabac_b_mb_sub_type( H264Context *h ) { |
927 int type; | 868 int type; |
928 if( !get_cabac( &h->cabac, &h->cabac_state[36] ) ) | 869 if( !get_cabac( &h->cabac, &h->cabac_state[36] ) ) |
929 return 0; /* B_Direct_8x8 */ | 870 return 0; /* B_Direct_8x8 */ |
930 if( !get_cabac( &h->cabac, &h->cabac_state[37] ) ) | 871 if( !get_cabac( &h->cabac, &h->cabac_state[37] ) ) |
931 return 1 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L0_8x8, B_L
1_8x8 */ | 872 return 1 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L0_8x8, B_L
1_8x8 */ |
932 type = 3; | 873 type = 3; |
933 if( get_cabac( &h->cabac, &h->cabac_state[38] ) ) { | 874 if( get_cabac( &h->cabac, &h->cabac_state[38] ) ) { |
934 if( get_cabac( &h->cabac, &h->cabac_state[39] ) ) | 875 if( get_cabac( &h->cabac, &h->cabac_state[39] ) ) |
935 return 11 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L1_4x4
, B_Bi_4x4 */ | 876 return 11 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L1_4x4
, B_Bi_4x4 */ |
936 type += 4; | 877 type += 4; |
937 } | 878 } |
938 type += 2*get_cabac( &h->cabac, &h->cabac_state[39] ); | 879 type += 2*get_cabac( &h->cabac, &h->cabac_state[39] ); |
939 type += get_cabac( &h->cabac, &h->cabac_state[39] ); | 880 type += get_cabac( &h->cabac, &h->cabac_state[39] ); |
940 return type; | 881 return type; |
941 } | 882 } |
942 | 883 |
943 static inline int decode_cabac_mb_transform_size( H264Context *h ) { | |
944 return get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_tran
sform_size] ); | |
945 } | |
946 | |
947 static int decode_cabac_mb_ref( H264Context *h, int list, int n ) { | 884 static int decode_cabac_mb_ref( H264Context *h, int list, int n ) { |
948 int refa = h->ref_cache[list][scan8[n] - 1]; | 885 int refa = h->ref_cache[list][scan8[n] - 1]; |
949 int refb = h->ref_cache[list][scan8[n] - 8]; | 886 int refb = h->ref_cache[list][scan8[n] - 8]; |
950 int ref = 0; | 887 int ref = 0; |
951 int ctx = 0; | 888 int ctx = 0; |
952 | 889 |
953 if( h->slice_type_nos == FF_B_TYPE) { | 890 if( h->slice_type_nos == FF_B_TYPE) { |
954 if( refa > 0 && !h->direct_cache[scan8[n] - 1] ) | 891 if( refa > 0 && !(h->direct_cache[scan8[n] - 1]&(MB_TYPE_DIRECT2>>1)) ) |
955 ctx++; | 892 ctx++; |
956 if( refb > 0 && !h->direct_cache[scan8[n] - 8] ) | 893 if( refb > 0 && !(h->direct_cache[scan8[n] - 8]&(MB_TYPE_DIRECT2>>1)) ) |
957 ctx += 2; | 894 ctx += 2; |
958 } else { | 895 } else { |
959 if( refa > 0 ) | 896 if( refa > 0 ) |
960 ctx++; | 897 ctx++; |
961 if( refb > 0 ) | 898 if( refb > 0 ) |
962 ctx += 2; | 899 ctx += 2; |
963 } | 900 } |
964 | 901 |
965 while( get_cabac( &h->cabac, &h->cabac_state[54+ctx] ) ) { | 902 while( get_cabac( &h->cabac, &h->cabac_state[54+ctx] ) ) { |
966 ref++; | 903 ref++; |
967 ctx = (ctx>>2)+4; | 904 ctx = (ctx>>2)+4; |
968 if(ref >= 32 /*h->ref_list[list]*/){ | 905 if(ref >= 32 /*h->ref_list[list]*/){ |
969 return -1; | 906 return -1; |
970 } | 907 } |
971 } | 908 } |
972 return ref; | 909 return ref; |
973 } | 910 } |
974 | 911 |
975 static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) { | 912 static int decode_cabac_mb_mvd( H264Context *h, int ctxbase, int amvd, int *mvda
) { |
976 int amvd = abs( h->mvd_cache[list][scan8[n] - 1][l] ) + | |
977 abs( h->mvd_cache[list][scan8[n] - 8][l] ); | |
978 int ctxbase = (l == 0) ? 40 : 47; | |
979 int mvd; | 913 int mvd; |
980 int ctx = (amvd>2) + (amvd>32); | |
981 | 914 |
982 if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+ctx])) | 915 if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+((amvd-3)>>(INT_BIT-1))+((a
mvd-33)>>(INT_BIT-1))+2])){ |
| 916 // if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){ |
| 917 *mvda= 0; |
983 return 0; | 918 return 0; |
| 919 } |
984 | 920 |
985 mvd= 1; | 921 mvd= 1; |
986 ctx= 3; | 922 ctxbase+= 3; |
987 while( mvd < 9 && get_cabac( &h->cabac, &h->cabac_state[ctxbase+ctx] ) ) { | 923 while( mvd < 9 && get_cabac( &h->cabac, &h->cabac_state[ctxbase] ) ) { |
| 924 if( mvd < 4 ) |
| 925 ctxbase++; |
988 mvd++; | 926 mvd++; |
989 if( ctx < 6 ) | |
990 ctx++; | |
991 } | 927 } |
992 | 928 |
993 if( mvd >= 9 ) { | 929 if( mvd >= 9 ) { |
994 int k = 3; | 930 int k = 3; |
995 while( get_cabac_bypass( &h->cabac ) ) { | 931 while( get_cabac_bypass( &h->cabac ) ) { |
996 mvd += 1 << k; | 932 mvd += 1 << k; |
997 k++; | 933 k++; |
998 if(k>24){ | 934 if(k>24){ |
999 av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mv
d\n"); | 935 av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mv
d\n"); |
1000 return INT_MIN; | 936 return INT_MIN; |
1001 } | 937 } |
1002 } | 938 } |
1003 while( k-- ) { | 939 while( k-- ) { |
1004 if( get_cabac_bypass( &h->cabac ) ) | 940 mvd += get_cabac_bypass( &h->cabac )<<k; |
1005 mvd += 1 << k; | |
1006 } | 941 } |
1007 } | 942 *mvda=mvd < 70 ? mvd : 70; |
| 943 }else |
| 944 *mvda=mvd; |
1008 return get_cabac_bypass_sign( &h->cabac, -mvd ); | 945 return get_cabac_bypass_sign( &h->cabac, -mvd ); |
1009 } | 946 } |
1010 | 947 |
| 948 #define DECODE_CABAC_MB_MVD( h, list, n )\ |
| 949 {\ |
| 950 int amvd0 = h->mvd_cache[list][scan8[n] - 1][0] +\ |
| 951 h->mvd_cache[list][scan8[n] - 8][0];\ |
| 952 int amvd1 = h->mvd_cache[list][scan8[n] - 1][1] +\ |
| 953 h->mvd_cache[list][scan8[n] - 8][1];\ |
| 954 \ |
| 955 mx += decode_cabac_mb_mvd( h, 40, amvd0, &mpx );\ |
| 956 my += decode_cabac_mb_mvd( h, 47, amvd1, &mpy );\ |
| 957 } |
| 958 |
1011 static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx,
int is_dc ) { | 959 static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx,
int is_dc ) { |
1012 int nza, nzb; | 960 int nza, nzb; |
1013 int ctx = 0; | 961 int ctx = 0; |
1014 | 962 |
1015 if( is_dc ) { | 963 if( is_dc ) { |
1016 if( cat == 0 ) { | 964 if( cat == 0 ) { |
1017 nza = h->left_cbp&0x100; | 965 nza = h->left_cbp&0x100; |
1018 nzb = h-> top_cbp&0x100; | 966 nzb = h-> top_cbp&0x100; |
1019 } else { | 967 } else { |
1020 nza = (h->left_cbp>>(6+idx))&0x01; | 968 nza = (h->left_cbp>>(6+idx))&0x01; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1183 |
1236 static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int
n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { | 1184 static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int
n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
1237 #if CONFIG_SMALL | 1185 #if CONFIG_SMALL |
1238 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff,
cat == 0 || cat == 3); | 1186 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff,
cat == 0 || cat == 3); |
1239 #else | 1187 #else |
1240 if( cat == 0 || cat == 3 ) decode_cabac_residual_dc(h, block, cat, n, scanta
ble, qmul, max_coeff); | 1188 if( cat == 0 || cat == 3 ) decode_cabac_residual_dc(h, block, cat, n, scanta
ble, qmul, max_coeff); |
1241 else decode_cabac_residual_nondc(h, block, cat, n, scantable, qmul, max_coef
f); | 1189 else decode_cabac_residual_nondc(h, block, cat, n, scantable, qmul, max_coef
f); |
1242 #endif | 1190 #endif |
1243 } | 1191 } |
1244 | 1192 |
1245 static inline void compute_mb_neighbors(H264Context *h) | |
1246 { | |
1247 MpegEncContext * const s = &h->s; | |
1248 const int mb_xy = h->mb_xy; | |
1249 h->top_mb_xy = mb_xy - s->mb_stride; | |
1250 h->left_mb_xy[0] = mb_xy - 1; | |
1251 if(FRAME_MBAFF){ | |
1252 const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride; | |
1253 const int top_pair_xy = pair_xy - s->mb_stride; | |
1254 const int top_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[
top_pair_xy]); | |
1255 const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[
pair_xy-1]); | |
1256 const int curr_mb_field_flag = MB_FIELD; | |
1257 const int bottom = (s->mb_y & 1); | |
1258 | |
1259 if (curr_mb_field_flag && (bottom || top_mb_field_flag)){ | |
1260 h->top_mb_xy -= s->mb_stride; | |
1261 } | |
1262 if (!left_mb_field_flag == curr_mb_field_flag) { | |
1263 h->left_mb_xy[0] = pair_xy - 1; | |
1264 } | |
1265 } else if (FIELD_PICTURE) { | |
1266 h->top_mb_xy -= s->mb_stride; | |
1267 } | |
1268 return; | |
1269 } | |
1270 | |
1271 /** | 1193 /** |
1272 * decodes a macroblock | 1194 * decodes a macroblock |
1273 * @returns 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed | 1195 * @returns 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed |
1274 */ | 1196 */ |
1275 int ff_h264_decode_mb_cabac(H264Context *h) { | 1197 int ff_h264_decode_mb_cabac(H264Context *h) { |
1276 MpegEncContext * const s = &h->s; | 1198 MpegEncContext * const s = &h->s; |
1277 int mb_xy; | 1199 int mb_xy; |
1278 int mb_type, partition_count, cbp = 0; | 1200 int mb_type, partition_count, cbp = 0; |
1279 int dct8x8_allowed= h->pps.transform_8x8_mode; | 1201 int dct8x8_allowed= h->pps.transform_8x8_mode; |
1280 | 1202 |
1281 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; | 1203 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; |
1282 | 1204 |
1283 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); | 1205 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); |
1284 if( h->slice_type_nos != FF_I_TYPE ) { | 1206 if( h->slice_type_nos != FF_I_TYPE ) { |
1285 int skip; | 1207 int skip; |
1286 /* a skipped mb needs the aff flag from the following mb */ | 1208 /* a skipped mb needs the aff flag from the following mb */ |
1287 if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 ) | |
1288 predict_field_decoding_flag(h); | |
1289 if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped ) | 1209 if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped ) |
1290 skip = h->next_mb_skipped; | 1210 skip = h->next_mb_skipped; |
1291 else | 1211 else |
1292 skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y ); | 1212 skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y ); |
1293 /* read skip flags */ | 1213 /* read skip flags */ |
1294 if( skip ) { | 1214 if( skip ) { |
1295 if( FRAME_MBAFF && (s->mb_y&1)==0 ){ | 1215 if( FRAME_MBAFF && (s->mb_y&1)==0 ){ |
1296 s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP; | 1216 s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP; |
1297 h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1
); | 1217 h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1
); |
1298 if(!h->next_mb_skipped) | 1218 if(!h->next_mb_skipped) |
(...skipping 11 matching lines...) Expand all Loading... |
1310 } | 1230 } |
1311 } | 1231 } |
1312 if(FRAME_MBAFF){ | 1232 if(FRAME_MBAFF){ |
1313 if( (s->mb_y&1) == 0 ) | 1233 if( (s->mb_y&1) == 0 ) |
1314 h->mb_mbaff = | 1234 h->mb_mbaff = |
1315 h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h); | 1235 h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h); |
1316 } | 1236 } |
1317 | 1237 |
1318 h->prev_mb_skipped = 0; | 1238 h->prev_mb_skipped = 0; |
1319 | 1239 |
1320 compute_mb_neighbors(h); | 1240 fill_decode_neighbors(h, -(MB_FIELD)); |
1321 | 1241 |
1322 if( h->slice_type_nos == FF_B_TYPE ) { | 1242 if( h->slice_type_nos == FF_B_TYPE ) { |
1323 mb_type = decode_cabac_mb_type_b( h ); | 1243 int ctx = 0; |
1324 if( mb_type < 23 ){ | 1244 assert(h->slice_type_nos == FF_B_TYPE); |
| 1245 |
| 1246 if( !IS_DIRECT( h->left_type[0]-1 ) ) |
| 1247 ctx++; |
| 1248 if( !IS_DIRECT( h->top_type-1 ) ) |
| 1249 ctx++; |
| 1250 |
| 1251 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){ |
| 1252 mb_type= 0; /* B_Direct_16x16 */ |
| 1253 }else if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) { |
| 1254 mb_type= 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
/* B_L[01]_16x16 */ |
| 1255 }else{ |
| 1256 int bits; |
| 1257 bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3; |
| 1258 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2; |
| 1259 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1; |
| 1260 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); |
| 1261 if( bits < 8 ){ |
| 1262 mb_type= bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ |
| 1263 }else if( bits == 13 ){ |
| 1264 mb_type= decode_cabac_intra_mb_type(h, 32, 0); |
| 1265 goto decode_intra_mb; |
| 1266 }else if( bits == 14 ){ |
| 1267 mb_type= 11; /* B_L1_L0_8x16 */ |
| 1268 }else if( bits == 15 ){ |
| 1269 mb_type= 22; /* B_8x8 */ |
| 1270 }else{ |
| 1271 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_sta
te[27+5] ); |
| 1272 mb_type= bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */ |
| 1273 } |
| 1274 } |
1325 partition_count= b_mb_type_info[mb_type].partition_count; | 1275 partition_count= b_mb_type_info[mb_type].partition_count; |
1326 mb_type= b_mb_type_info[mb_type].type; | 1276 mb_type= b_mb_type_info[mb_type].type; |
1327 }else{ | |
1328 mb_type -= 23; | |
1329 goto decode_intra_mb; | |
1330 } | |
1331 } else if( h->slice_type_nos == FF_P_TYPE ) { | 1277 } else if( h->slice_type_nos == FF_P_TYPE ) { |
1332 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) { | 1278 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) { |
1333 /* P-type */ | 1279 /* P-type */ |
1334 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) { | 1280 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) { |
1335 /* P_L0_D16x16, P_8x8 */ | 1281 /* P_L0_D16x16, P_8x8 */ |
1336 mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16]
); | 1282 mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16]
); |
1337 } else { | 1283 } else { |
1338 /* P_L0_D8x16, P_L0_D16x8 */ | 1284 /* P_L0_D8x16, P_L0_D16x8 */ |
1339 mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17]
); | 1285 mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17]
); |
1340 } | 1286 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 if(MB_MBAFF){ | 1341 if(MB_MBAFF){ |
1396 h->ref_count[0] <<= 1; | 1342 h->ref_count[0] <<= 1; |
1397 h->ref_count[1] <<= 1; | 1343 h->ref_count[1] <<= 1; |
1398 } | 1344 } |
1399 | 1345 |
1400 fill_decode_caches(h, mb_type); | 1346 fill_decode_caches(h, mb_type); |
1401 | 1347 |
1402 if( IS_INTRA( mb_type ) ) { | 1348 if( IS_INTRA( mb_type ) ) { |
1403 int i, pred_mode; | 1349 int i, pred_mode; |
1404 if( IS_INTRA4x4( mb_type ) ) { | 1350 if( IS_INTRA4x4( mb_type ) ) { |
1405 if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) { | 1351 if( dct8x8_allowed && get_cabac_noinline( &h->cabac, &h->cabac_state
[399 + h->neighbor_transform_size] ) ) { |
1406 mb_type |= MB_TYPE_8x8DCT; | 1352 mb_type |= MB_TYPE_8x8DCT; |
1407 for( i = 0; i < 16; i+=4 ) { | 1353 for( i = 0; i < 16; i+=4 ) { |
1408 int pred = pred_intra_mode( h, i ); | 1354 int pred = pred_intra_mode( h, i ); |
1409 int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred ); | 1355 int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred ); |
1410 fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2,
2, 8, mode, 1 ); | 1356 fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2,
2, 8, mode, 1 ); |
1411 } | 1357 } |
1412 } else { | 1358 } else { |
1413 for( i = 0; i < 16; i++ ) { | 1359 for( i = 0; i < 16; i++ ) { |
1414 int pred = pred_intra_mode( h, i ); | 1360 int pred = pred_intra_mode( h, i ); |
1415 h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_in
tra4x4_pred_mode( h, pred ); | 1361 h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_in
tra4x4_pred_mode( h, pred ); |
(...skipping 24 matching lines...) Expand all Loading... |
1440 sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].
partition_count; | 1386 sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].
partition_count; |
1441 h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].
type; | 1387 h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].
type; |
1442 } | 1388 } |
1443 if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] | | 1389 if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] | |
1444 h->sub_mb_type[2] | h->sub_mb_type[3]) ) { | 1390 h->sub_mb_type[2] | h->sub_mb_type[3]) ) { |
1445 ff_h264_pred_direct_motion(h, &mb_type); | 1391 ff_h264_pred_direct_motion(h, &mb_type); |
1446 h->ref_cache[0][scan8[4]] = | 1392 h->ref_cache[0][scan8[4]] = |
1447 h->ref_cache[1][scan8[4]] = | 1393 h->ref_cache[1][scan8[4]] = |
1448 h->ref_cache[0][scan8[12]] = | 1394 h->ref_cache[0][scan8[12]] = |
1449 h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; | 1395 h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; |
1450 if( h->ref_count[0] > 1 || h->ref_count[1] > 1 ) { | |
1451 for( i = 0; i < 4; i++ ) | 1396 for( i = 0; i < 4; i++ ) |
1452 if( IS_DIRECT(h->sub_mb_type[i]) ) | 1397 fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, (
h->sub_mb_type[i]>>1)&0xFF, 1 ); |
1453 fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2,
8, 1, 1 ); | |
1454 } | |
1455 } | 1398 } |
1456 } else { | 1399 } else { |
1457 for( i = 0; i < 4; i++ ) { | 1400 for( i = 0; i < 4; i++ ) { |
1458 h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h ); | 1401 h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h ); |
1459 sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].
partition_count; | 1402 sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].
partition_count; |
1460 h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].
type; | 1403 h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].
type; |
1461 } | 1404 } |
1462 } | 1405 } |
1463 | 1406 |
1464 for( list = 0; list < h->list_count; list++ ) { | 1407 for( list = 0; list < h->list_count; list++ ) { |
(...skipping 16 matching lines...) Expand all Loading... |
1481 } | 1424 } |
1482 } | 1425 } |
1483 | 1426 |
1484 if(dct8x8_allowed) | 1427 if(dct8x8_allowed) |
1485 dct8x8_allowed = get_dct8x8_allowed(h); | 1428 dct8x8_allowed = get_dct8x8_allowed(h); |
1486 | 1429 |
1487 for(list=0; list<h->list_count; list++){ | 1430 for(list=0; list<h->list_count; list++){ |
1488 for(i=0; i<4; i++){ | 1431 for(i=0; i<4; i++){ |
1489 h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i
]+1 ]; | 1432 h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i
]+1 ]; |
1490 if(IS_DIRECT(h->sub_mb_type[i])){ | 1433 if(IS_DIRECT(h->sub_mb_type[i])){ |
1491 fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4
); | 1434 fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 2
); |
1492 continue; | 1435 continue; |
1493 } | 1436 } |
1494 | 1437 |
1495 if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_ty
pe[i])){ | 1438 if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_ty
pe[i])){ |
1496 const int sub_mb_type= h->sub_mb_type[i]; | 1439 const int sub_mb_type= h->sub_mb_type[i]; |
1497 const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE
_16x8)) ? 2 : 1; | 1440 const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE
_16x8)) ? 2 : 1; |
1498 for(j=0; j<sub_partition_count[i]; j++){ | 1441 for(j=0; j<sub_partition_count[i]; j++){ |
1499 int mpx, mpy; | 1442 int mpx, mpy; |
1500 int mx, my; | 1443 int mx, my; |
1501 const int index= 4*i + block_width*j; | 1444 const int index= 4*i + block_width*j; |
1502 int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index
] ]; | 1445 int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index
] ]; |
1503 int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[ind
ex] ]; | 1446 uint8_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[ind
ex] ]; |
1504 pred_motion(h, index, block_width, list, h->ref_cache[li
st][ scan8[index] ], &mpx, &mpy); | 1447 pred_motion(h, index, block_width, list, h->ref_cache[li
st][ scan8[index] ], &mx, &my); |
1505 | 1448 DECODE_CABAC_MB_MVD( h, list, index) |
1506 mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 ); | |
1507 my = mpy + decode_cabac_mb_mvd( h, list, index, 1 ); | |
1508 tprintf(s->avctx, "final mv:%d %d\n", mx, my); | 1449 tprintf(s->avctx, "final mv:%d %d\n", mx, my); |
1509 | 1450 |
1510 if(IS_SUB_8X8(sub_mb_type)){ | 1451 if(IS_SUB_8X8(sub_mb_type)){ |
1511 mv_cache[ 1 ][0]= | 1452 mv_cache[ 1 ][0]= |
1512 mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; | 1453 mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; |
1513 mv_cache[ 1 ][1]= | 1454 mv_cache[ 1 ][1]= |
1514 mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; | 1455 mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; |
1515 | 1456 |
1516 mvd_cache[ 1 ][0]= | 1457 mvd_cache[ 1 ][0]= |
1517 mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx; | 1458 mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mpx; |
1518 mvd_cache[ 1 ][1]= | 1459 mvd_cache[ 1 ][1]= |
1519 mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy; | 1460 mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= mpy; |
1520 }else if(IS_SUB_8X4(sub_mb_type)){ | 1461 }else if(IS_SUB_8X4(sub_mb_type)){ |
1521 mv_cache[ 1 ][0]= mx; | 1462 mv_cache[ 1 ][0]= mx; |
1522 mv_cache[ 1 ][1]= my; | 1463 mv_cache[ 1 ][1]= my; |
1523 | 1464 |
1524 mvd_cache[ 1 ][0]= mx - mpx; | 1465 mvd_cache[ 1 ][0]= mpx; |
1525 mvd_cache[ 1 ][1]= my - mpy; | 1466 mvd_cache[ 1 ][1]= mpy; |
1526 }else if(IS_SUB_4X8(sub_mb_type)){ | 1467 }else if(IS_SUB_4X8(sub_mb_type)){ |
1527 mv_cache[ 8 ][0]= mx; | 1468 mv_cache[ 8 ][0]= mx; |
1528 mv_cache[ 8 ][1]= my; | 1469 mv_cache[ 8 ][1]= my; |
1529 | 1470 |
1530 mvd_cache[ 8 ][0]= mx - mpx; | 1471 mvd_cache[ 8 ][0]= mpx; |
1531 mvd_cache[ 8 ][1]= my - mpy; | 1472 mvd_cache[ 8 ][1]= mpy; |
1532 } | 1473 } |
1533 mv_cache[ 0 ][0]= mx; | 1474 mv_cache[ 0 ][0]= mx; |
1534 mv_cache[ 0 ][1]= my; | 1475 mv_cache[ 0 ][1]= my; |
1535 | 1476 |
1536 mvd_cache[ 0 ][0]= mx - mpx; | 1477 mvd_cache[ 0 ][0]= mpx; |
1537 mvd_cache[ 0 ][1]= my - mpy; | 1478 mvd_cache[ 0 ][1]= mpy; |
1538 } | 1479 } |
1539 }else{ | 1480 }else{ |
1540 uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]
; | 1481 fill_rectangle(h->mv_cache [list][ scan8[4*i] ], 2, 2, 8, 0,
4); |
1541 uint32_t *pd= (uint32_t *)&h->mvd_cache[list][ scan8[4*i] ][
0]; | 1482 fill_rectangle(h->mvd_cache[list][ scan8[4*i] ], 2, 2, 8, 0,
2); |
1542 p[0] = p[1] = p[8] = p[9] = 0; | |
1543 pd[0]= pd[1]= pd[8]= pd[9]= 0; | |
1544 } | 1483 } |
1545 } | 1484 } |
1546 } | 1485 } |
1547 } else if( IS_DIRECT(mb_type) ) { | 1486 } else if( IS_DIRECT(mb_type) ) { |
1548 ff_h264_pred_direct_motion(h, &mb_type); | 1487 ff_h264_pred_direct_motion(h, &mb_type); |
1549 fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4); | 1488 fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 2); |
1550 fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4); | 1489 fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 2); |
1551 dct8x8_allowed &= h->sps.direct_8x8_inference_flag; | 1490 dct8x8_allowed &= h->sps.direct_8x8_inference_flag; |
1552 } else { | 1491 } else { |
1553 int list, mx, my, i, mpx, mpy; | 1492 int list, i; |
1554 if(IS_16X16(mb_type)){ | 1493 if(IS_16X16(mb_type)){ |
1555 for(list=0; list<h->list_count; list++){ | 1494 for(list=0; list<h->list_count; list++){ |
1556 if(IS_DIR(mb_type, 0, list)){ | 1495 if(IS_DIR(mb_type, 0, list)){ |
1557 int ref; | 1496 int ref; |
1558 if(h->ref_count[list] > 1){ | 1497 if(h->ref_count[list] > 1){ |
1559 ref= decode_cabac_mb_ref(h, list, 0); | 1498 ref= decode_cabac_mb_ref(h, list, 0); |
1560 if(ref >= (unsigned)h->ref_count[list]){ | 1499 if(ref >= (unsigned)h->ref_count[list]){ |
1561 av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n
", ref, h->ref_count[list]); | 1500 av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n
", ref, h->ref_count[list]); |
1562 return -1; | 1501 return -1; |
1563 } | 1502 } |
1564 }else | 1503 }else |
1565 ref=0; | 1504 ref=0; |
1566 fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8,
ref, 1); | 1505 fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8,
ref, 1); |
1567 }else | 1506 } |
1568 fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (ui
nt8_t)LIST_NOT_USED, 1); //FIXME factorize and the other fill_rect below too | |
1569 } | 1507 } |
1570 for(list=0; list<h->list_count; list++){ | 1508 for(list=0; list<h->list_count; list++){ |
1571 if(IS_DIR(mb_type, 0, list)){ | 1509 if(IS_DIR(mb_type, 0, list)){ |
1572 pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &
mpx, &mpy); | 1510 int mx,my,mpx,mpy; |
1573 | 1511 pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &
mx, &my); |
1574 mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 ); | 1512 DECODE_CABAC_MB_MVD( h, list, 0) |
1575 my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 ); | |
1576 tprintf(s->avctx, "final mv:%d %d\n", mx, my); | 1513 tprintf(s->avctx, "final mv:%d %d\n", mx, my); |
1577 | 1514 |
1578 fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack
16to32(mx-mpx,my-mpy), 4); | 1515 fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack
8to16(mpx,mpy), 2); |
1579 fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack1
6to32(mx,my), 4); | 1516 fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack1
6to32(mx,my), 4); |
1580 }else | 1517 } |
1581 fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4)
; | |
1582 } | 1518 } |
1583 } | 1519 } |
1584 else if(IS_16X8(mb_type)){ | 1520 else if(IS_16X8(mb_type)){ |
1585 for(list=0; list<h->list_count; list++){ | 1521 for(list=0; list<h->list_count; list++){ |
1586 for(i=0; i<2; i++){ | 1522 for(i=0; i<2; i++){ |
1587 if(IS_DIR(mb_type, i, list)){ | 1523 if(IS_DIR(mb_type, i, list)){ |
1588 int ref; | 1524 int ref; |
1589 if(h->ref_count[list] > 1){ | 1525 if(h->ref_count[list] > 1){ |
1590 ref= decode_cabac_mb_ref( h, list, 8*i ); | 1526 ref= decode_cabac_mb_ref( h, list, 8*i ); |
1591 if(ref >= (unsigned)h->ref_count[list]){ | 1527 if(ref >= (unsigned)h->ref_count[list]){ |
1592 av_log(s->avctx, AV_LOG_ERROR, "Reference %d
>= %d\n", ref, h->ref_count[list]); | 1528 av_log(s->avctx, AV_LOG_ERROR, "Reference %d
>= %d\n", ref, h->ref_count[list]); |
1593 return -1; | 1529 return -1; |
1594 } | 1530 } |
1595 }else | 1531 }else |
1596 ref=0; | 1532 ref=0; |
1597 fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i
], 4, 2, 8, ref, 1); | 1533 fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i
], 4, 2, 8, ref, 1); |
1598 }else | 1534 }else |
1599 fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i
], 4, 2, 8, (LIST_NOT_USED&0xFF), 1); | 1535 fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i
], 4, 2, 8, (LIST_NOT_USED&0xFF), 1); |
1600 } | 1536 } |
1601 } | 1537 } |
1602 for(list=0; list<h->list_count; list++){ | 1538 for(list=0; list<h->list_count; list++){ |
1603 for(i=0; i<2; i++){ | 1539 for(i=0; i<2; i++){ |
1604 if(IS_DIR(mb_type, i, list)){ | 1540 if(IS_DIR(mb_type, i, list)){ |
1605 pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[
0] + 16*i], &mpx, &mpy); | 1541 int mx,my,mpx,mpy; |
1606 mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 ); | 1542 pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[
0] + 16*i], &mx, &my); |
1607 my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 ); | 1543 DECODE_CABAC_MB_MVD( h, list, 8*i) |
1608 tprintf(s->avctx, "final mv:%d %d\n", mx, my); | 1544 tprintf(s->avctx, "final mv:%d %d\n", mx, my); |
1609 | 1545 |
1610 fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4,
2, 8, pack16to32(mx-mpx,my-mpy), 4); | 1546 fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4,
2, 8, pack8to16(mpx,mpy), 2); |
1611 fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4,
2, 8, pack16to32(mx,my), 4); | 1547 fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4,
2, 8, pack16to32(mx,my), 4); |
1612 }else{ | 1548 }else{ |
1613 fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4,
2, 8, 0, 4); | 1549 fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4,
2, 8, 0, 2); |
1614 fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4,
2, 8, 0, 4); | 1550 fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4,
2, 8, 0, 4); |
1615 } | 1551 } |
1616 } | 1552 } |
1617 } | 1553 } |
1618 }else{ | 1554 }else{ |
1619 assert(IS_8X16(mb_type)); | 1555 assert(IS_8X16(mb_type)); |
1620 for(list=0; list<h->list_count; list++){ | 1556 for(list=0; list<h->list_count; list++){ |
1621 for(i=0; i<2; i++){ | 1557 for(i=0; i<2; i++){ |
1622 if(IS_DIR(mb_type, i, list)){ //FIXME optimize | 1558 if(IS_DIR(mb_type, i, list)){ //FIXME optimize |
1623 int ref; | 1559 int ref; |
1624 if(h->ref_count[list] > 1){ | 1560 if(h->ref_count[list] > 1){ |
1625 ref= decode_cabac_mb_ref( h, list, 4*i ); | 1561 ref= decode_cabac_mb_ref( h, list, 4*i ); |
1626 if(ref >= (unsigned)h->ref_count[list]){ | 1562 if(ref >= (unsigned)h->ref_count[list]){ |
1627 av_log(s->avctx, AV_LOG_ERROR, "Reference %d
>= %d\n", ref, h->ref_count[list]); | 1563 av_log(s->avctx, AV_LOG_ERROR, "Reference %d
>= %d\n", ref, h->ref_count[list]); |
1628 return -1; | 1564 return -1; |
1629 } | 1565 } |
1630 }else | 1566 }else |
1631 ref=0; | 1567 ref=0; |
1632 fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ]
, 2, 4, 8, ref, 1); | 1568 fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ]
, 2, 4, 8, ref, 1); |
1633 }else | 1569 }else |
1634 fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ]
, 2, 4, 8, (LIST_NOT_USED&0xFF), 1); | 1570 fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ]
, 2, 4, 8, (LIST_NOT_USED&0xFF), 1); |
1635 } | 1571 } |
1636 } | 1572 } |
1637 for(list=0; list<h->list_count; list++){ | 1573 for(list=0; list<h->list_count; list++){ |
1638 for(i=0; i<2; i++){ | 1574 for(i=0; i<2; i++){ |
1639 if(IS_DIR(mb_type, i, list)){ | 1575 if(IS_DIR(mb_type, i, list)){ |
1640 pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8
[0] + 2*i ], &mpx, &mpy); | 1576 int mx,my,mpx,mpy; |
1641 mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 ); | 1577 pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8
[0] + 2*i ], &mx, &my); |
1642 my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 ); | 1578 DECODE_CABAC_MB_MVD( h, list, 4*i) |
1643 | 1579 |
1644 tprintf(s->avctx, "final mv:%d %d\n", mx, my); | 1580 tprintf(s->avctx, "final mv:%d %d\n", mx, my); |
1645 fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2,
4, 8, pack16to32(mx-mpx,my-mpy), 4); | 1581 fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2,
4, 8, pack8to16(mpx,mpy), 2); |
1646 fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4
, 8, pack16to32(mx,my), 4); | 1582 fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4
, 8, pack16to32(mx,my), 4); |
1647 }else{ | 1583 }else{ |
1648 fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2,
4, 8, 0, 4); | 1584 fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2,
4, 8, 0, 2); |
1649 fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2,
4, 8, 0, 4); | 1585 fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2,
4, 8, 0, 4); |
1650 } | 1586 } |
1651 } | 1587 } |
1652 } | 1588 } |
1653 } | 1589 } |
1654 } | 1590 } |
1655 | 1591 |
1656 if( IS_INTER( mb_type ) ) { | 1592 if( IS_INTER( mb_type ) ) { |
1657 h->chroma_pred_mode_table[mb_xy] = 0; | 1593 h->chroma_pred_mode_table[mb_xy] = 0; |
1658 write_back_motion( h, mb_type ); | 1594 write_back_motion( h, mb_type ); |
1659 } | 1595 } |
1660 | 1596 |
1661 if( !IS_INTRA16x16( mb_type ) ) { | 1597 if( !IS_INTRA16x16( mb_type ) ) { |
1662 cbp = decode_cabac_mb_cbp_luma( h ); | 1598 cbp = decode_cabac_mb_cbp_luma( h ); |
1663 if(CHROMA) | 1599 if(CHROMA) |
1664 cbp |= decode_cabac_mb_cbp_chroma( h ) << 4; | 1600 cbp |= decode_cabac_mb_cbp_chroma( h ) << 4; |
1665 } | 1601 } |
1666 | 1602 |
1667 h->cbp_table[mb_xy] = h->cbp = cbp; | 1603 h->cbp_table[mb_xy] = h->cbp = cbp; |
1668 | 1604 |
1669 if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) { | 1605 if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) { |
1670 if( decode_cabac_mb_transform_size( h ) ) | 1606 mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline( &h->cabac, &h->cabac_sta
te[399 + h->neighbor_transform_size] ); |
1671 mb_type |= MB_TYPE_8x8DCT; | |
1672 } | 1607 } |
1673 s->current_picture.mb_type[mb_xy]= mb_type; | 1608 s->current_picture.mb_type[mb_xy]= mb_type; |
1674 | 1609 |
1675 if( cbp || IS_INTRA16x16( mb_type ) ) { | 1610 if( cbp || IS_INTRA16x16( mb_type ) ) { |
1676 const uint8_t *scan, *scan8x8, *dc_scan; | 1611 const uint8_t *scan, *scan8x8, *dc_scan; |
1677 const uint32_t *qmul; | 1612 const uint32_t *qmul; |
1678 int dqp; | |
1679 | 1613 |
1680 if(IS_INTERLACED(mb_type)){ | 1614 if(IS_INTERLACED(mb_type)){ |
1681 scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0; | 1615 scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0; |
1682 scan= s->qscale ? h->field_scan : h->field_scan_q0; | 1616 scan= s->qscale ? h->field_scan : h->field_scan_q0; |
1683 dc_scan= luma_dc_field_scan; | 1617 dc_scan= luma_dc_field_scan; |
1684 }else{ | 1618 }else{ |
1685 scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0; | 1619 scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0; |
1686 scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; | 1620 scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; |
1687 dc_scan= luma_dc_zigzag_scan; | 1621 dc_scan= luma_dc_zigzag_scan; |
1688 } | 1622 } |
1689 | 1623 |
1690 h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h ); | 1624 // decode_cabac_mb_dqp |
1691 if( dqp == INT_MIN ){ | 1625 if(get_cabac_noinline( &h->cabac, &h->cabac_state[60 + (h->last_qscale_d
iff != 0)])){ |
1692 av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed
at %d %d\n", s->mb_x, s->mb_y); | 1626 int val = 1; |
1693 return -1; | 1627 int ctx= 2; |
1694 } | 1628 |
1695 s->qscale += dqp; | 1629 while( get_cabac_noinline( &h->cabac, &h->cabac_state[60 + ctx] ) )
{ |
1696 if(((unsigned)s->qscale) > 51){ | 1630 ctx= 3; |
1697 if(s->qscale<0) s->qscale+= 52; | 1631 val++; |
1698 else s->qscale-= 52; | 1632 if(val > 102){ //prevent infinite loop |
1699 } | 1633 av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale dif
f failed at %d %d\n", s->mb_x, s->mb_y); |
1700 h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale); | 1634 return -1; |
1701 h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale); | 1635 } |
| 1636 } |
| 1637 |
| 1638 if( val&0x01 ) |
| 1639 val= (val + 1)>>1 ; |
| 1640 else |
| 1641 val= -((val + 1)>>1); |
| 1642 h->last_qscale_diff = val; |
| 1643 s->qscale += val; |
| 1644 if(((unsigned)s->qscale) > 51){ |
| 1645 if(s->qscale<0) s->qscale+= 52; |
| 1646 else s->qscale-= 52; |
| 1647 } |
| 1648 h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale); |
| 1649 h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale); |
| 1650 }else |
| 1651 h->last_qscale_diff=0; |
1702 | 1652 |
1703 if( IS_INTRA16x16( mb_type ) ) { | 1653 if( IS_INTRA16x16( mb_type ) ) { |
1704 int i; | 1654 int i; |
1705 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); | 1655 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); |
1706 decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16); | 1656 decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16); |
1707 | 1657 |
1708 if( cbp&15 ) { | 1658 if( cbp&15 ) { |
1709 qmul = h->dequant4_coeff[0][s->qscale]; | 1659 qmul = h->dequant4_coeff[0][s->qscale]; |
1710 for( i = 0; i < 16; i++ ) { | 1660 for( i = 0; i < 16; i++ ) { |
1711 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); | 1661 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 s->current_picture.qscale_table[mb_xy]= s->qscale; | 1722 s->current_picture.qscale_table[mb_xy]= s->qscale; |
1773 write_back_non_zero_count(h); | 1723 write_back_non_zero_count(h); |
1774 | 1724 |
1775 if(MB_MBAFF){ | 1725 if(MB_MBAFF){ |
1776 h->ref_count[0] >>= 1; | 1726 h->ref_count[0] >>= 1; |
1777 h->ref_count[1] >>= 1; | 1727 h->ref_count[1] >>= 1; |
1778 } | 1728 } |
1779 | 1729 |
1780 return 0; | 1730 return 0; |
1781 } | 1731 } |
OLD | NEW |