Revision 7a93858a

View differences:

libavcodec/h264.h
798 798

  
799 799
        //for sufficiently low qp, filtering wouldn't do anything
800 800
        //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp
801
            int qp_thresh = h->qp_thresh; //FIXME strictly we should store qp_thresh for each mb of a slice
802
            int qp = s->current_picture.qscale_table[mb_xy];
803
            if(qp <= qp_thresh
804
            && (left_xy[0]<0 || ((qp + s->current_picture.qscale_table[left_xy[0]] + 1)>>1) <= qp_thresh)
805
            && (left_xy[1]<0 || ((qp + s->current_picture.qscale_table[left_xy[1]] + 1)>>1) <= qp_thresh)
806
            && (top_xy   < 0 || ((qp + s->current_picture.qscale_table[top_xy ] + 1)>>1) <= qp_thresh)){
807
                return 1;
808
            }
801
        int qp_thresh = h->qp_thresh; //FIXME strictly we should store qp_thresh for each mb of a slice
802
        int qp = s->current_picture.qscale_table[mb_xy];
803
        if(qp <= qp_thresh
804
           && (left_xy[0]<0 || ((qp + s->current_picture.qscale_table[left_xy[0]] + 1)>>1) <= qp_thresh)
805
           && (left_xy[1]<0 || ((qp + s->current_picture.qscale_table[left_xy[1]] + 1)>>1) <= qp_thresh)
806
           && (top_xy   < 0 || ((qp + s->current_picture.qscale_table[top_xy ] + 1)>>1) <= qp_thresh)){
807
            return 1;
808
        }
809 809

  
810 810
        *((uint64_t*)&h->non_zero_count_cache[0+8*1])= *((uint64_t*)&h->non_zero_count[mb_xy][ 0]);
811 811
        *((uint64_t*)&h->non_zero_count_cache[0+8*2])= *((uint64_t*)&h->non_zero_count[mb_xy][ 8]);
......
866 866
        left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0;
867 867
        left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0;
868 868

  
869
    if(IS_INTRA(mb_type)){
870
        int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1;
871
        h->topleft_samples_available=
872
        h->top_samples_available=
873
        h->left_samples_available= 0xFFFF;
874
        h->topright_samples_available= 0xEEEA;
875

  
876
        if(!(top_type & type_mask)){
877
            h->topleft_samples_available= 0xB3FF;
878
            h->top_samples_available= 0x33FF;
879
            h->topright_samples_available= 0x26EA;
880
        }
881
        if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[0])){
882
            if(IS_INTERLACED(mb_type)){
883
                if(!(left_type[0] & type_mask)){
884
                    h->topleft_samples_available&= 0xDFFF;
885
                    h->left_samples_available&= 0x5FFF;
886
                }
887
                if(!(left_type[1] & type_mask)){
888
                    h->topleft_samples_available&= 0xFF5F;
889
                    h->left_samples_available&= 0xFF5F;
869
        if(IS_INTRA(mb_type)){
870
            int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1;
871
            h->topleft_samples_available=
872
            h->top_samples_available=
873
            h->left_samples_available= 0xFFFF;
874
            h->topright_samples_available= 0xEEEA;
875

  
876
            if(!(top_type & type_mask)){
877
                h->topleft_samples_available= 0xB3FF;
878
                h->top_samples_available= 0x33FF;
879
                h->topright_samples_available= 0x26EA;
880
            }
881
            if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[0])){
882
                if(IS_INTERLACED(mb_type)){
883
                    if(!(left_type[0] & type_mask)){
884
                        h->topleft_samples_available&= 0xDFFF;
885
                        h->left_samples_available&= 0x5FFF;
886
                    }
887
                    if(!(left_type[1] & type_mask)){
888
                        h->topleft_samples_available&= 0xFF5F;
889
                        h->left_samples_available&= 0xFF5F;
890
                    }
891
                }else{
892
                    int left_typei = h->slice_table[left_xy[0] + s->mb_stride ] == h->slice_num
893
                                    ? s->current_picture.mb_type[left_xy[0] + s->mb_stride] : 0;
894
                    assert(left_xy[0] == left_xy[1]);
895
                    if(!((left_typei & type_mask) && (left_type[0] & type_mask))){
896
                        h->topleft_samples_available&= 0xDF5F;
897
                        h->left_samples_available&= 0x5F5F;
898
                    }
890 899
                }
891 900
            }else{
892
                int left_typei = h->slice_table[left_xy[0] + s->mb_stride ] == h->slice_num
893
                                ? s->current_picture.mb_type[left_xy[0] + s->mb_stride] : 0;
894
                assert(left_xy[0] == left_xy[1]);
895
                if(!((left_typei & type_mask) && (left_type[0] & type_mask))){
901
                if(!(left_type[0] & type_mask)){
896 902
                    h->topleft_samples_available&= 0xDF5F;
897 903
                    h->left_samples_available&= 0x5F5F;
898 904
                }
899 905
            }
900
        }else{
901
            if(!(left_type[0] & type_mask)){
902
                h->topleft_samples_available&= 0xDF5F;
903
                h->left_samples_available&= 0x5F5F;
904
            }
905
        }
906 906

  
907
        if(!(topleft_type & type_mask))
908
            h->topleft_samples_available&= 0x7FFF;
907
            if(!(topleft_type & type_mask))
908
                h->topleft_samples_available&= 0x7FFF;
909 909

  
910
        if(!(topright_type & type_mask))
911
            h->topright_samples_available&= 0xFBFF;
910
            if(!(topright_type & type_mask))
911
                h->topright_samples_available&= 0xFBFF;
912 912

  
913
        if(IS_INTRA4x4(mb_type)){
914
            if(IS_INTRA4x4(top_type)){
915
                h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode[top_xy][4];
916
                h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode[top_xy][5];
917
                h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode[top_xy][6];
918
                h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3];
919
            }else{
920
                int pred;
921
                if(!(top_type & type_mask))
922
                    pred= -1;
923
                else{
924
                    pred= 2;
925
                }
926
                h->intra4x4_pred_mode_cache[4+8*0]=
927
                h->intra4x4_pred_mode_cache[5+8*0]=
928
                h->intra4x4_pred_mode_cache[6+8*0]=
929
                h->intra4x4_pred_mode_cache[7+8*0]= pred;
930
            }
931
            for(i=0; i<2; i++){
932
                if(IS_INTRA4x4(left_type[i])){
933
                    h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[0+2*i]];
934
                    h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]];
913
            if(IS_INTRA4x4(mb_type)){
914
                if(IS_INTRA4x4(top_type)){
915
                    h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode[top_xy][4];
916
                    h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode[top_xy][5];
917
                    h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode[top_xy][6];
918
                    h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3];
935 919
                }else{
936 920
                    int pred;
937
                    if(!(left_type[i] & type_mask))
921
                    if(!(top_type & type_mask))
938 922
                        pred= -1;
939 923
                    else{
940 924
                        pred= 2;
941 925
                    }
942
                    h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]=
943
                    h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred;
926
                    h->intra4x4_pred_mode_cache[4+8*0]=
927
                    h->intra4x4_pred_mode_cache[5+8*0]=
928
                    h->intra4x4_pred_mode_cache[6+8*0]=
929
                    h->intra4x4_pred_mode_cache[7+8*0]= pred;
930
                }
931
                for(i=0; i<2; i++){
932
                    if(IS_INTRA4x4(left_type[i])){
933
                        h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[0+2*i]];
934
                        h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]];
935
                    }else{
936
                        int pred;
937
                        if(!(left_type[i] & type_mask))
938
                            pred= -1;
939
                        else{
940
                            pred= 2;
941
                        }
942
                        h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]=
943
                        h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred;
944
                    }
944 945
                }
945 946
            }
946 947
        }
947 948
    }
948
    }
949 949

  
950 950

  
951 951
/*
......
960 960
    if(top_type){
961 961
        *(uint32_t*)&h->non_zero_count_cache[4+8*0]= *(uint32_t*)&h->non_zero_count[top_xy][4+3*8];
962 962
        if(!for_deblock){
963
        h->non_zero_count_cache[1+8*0]= h->non_zero_count[top_xy][1+1*8];
964
        h->non_zero_count_cache[2+8*0]= h->non_zero_count[top_xy][2+1*8];
963
            h->non_zero_count_cache[1+8*0]= h->non_zero_count[top_xy][1+1*8];
964
            h->non_zero_count_cache[2+8*0]= h->non_zero_count[top_xy][2+1*8];
965 965

  
966
        h->non_zero_count_cache[1+8*3]= h->non_zero_count[top_xy][1+2*8];
967
        h->non_zero_count_cache[2+8*3]= h->non_zero_count[top_xy][2+2*8];
966
            h->non_zero_count_cache[1+8*3]= h->non_zero_count[top_xy][1+2*8];
967
            h->non_zero_count_cache[2+8*3]= h->non_zero_count[top_xy][2+2*8];
968 968
        }
969 969
    }else{
970 970
        if(for_deblock){
971 971
            *(uint32_t*)&h->non_zero_count_cache[4+8*0]= 0;
972 972
        }else{
973 973

  
974
        h->non_zero_count_cache[1+8*0]=
975
        h->non_zero_count_cache[2+8*0]=
974
            h->non_zero_count_cache[1+8*0]=
975
            h->non_zero_count_cache[2+8*0]=
976 976

  
977
        h->non_zero_count_cache[1+8*3]=
978
        h->non_zero_count_cache[2+8*3]=
979
        *(uint32_t*)&h->non_zero_count_cache[4+8*0]= CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
977
            h->non_zero_count_cache[1+8*3]=
978
            h->non_zero_count_cache[2+8*3]=
979
            *(uint32_t*)&h->non_zero_count_cache[4+8*0]= CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
980 980
        }
981 981

  
982 982
    }
......
986 986
            h->non_zero_count_cache[3+8*1 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+0+2*i]];
987 987
            h->non_zero_count_cache[3+8*2 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[8+1+2*i]];
988 988
            if(!for_deblock){
989
            h->non_zero_count_cache[0+8*1 +   8*i]= h->non_zero_count[left_xy[i]][left_block[8+4+2*i]];
990
            h->non_zero_count_cache[0+8*4 +   8*i]= h->non_zero_count[left_xy[i]][left_block[8+5+2*i]];
989
                h->non_zero_count_cache[0+8*1 +   8*i]= h->non_zero_count[left_xy[i]][left_block[8+4+2*i]];
990
                h->non_zero_count_cache[0+8*4 +   8*i]= h->non_zero_count[left_xy[i]][left_block[8+5+2*i]];
991 991
            }
992 992
        }else{
993 993
            if(for_deblock){
994 994
                h->non_zero_count_cache[3+8*1 + 2*8*i]=
995 995
                h->non_zero_count_cache[3+8*2 + 2*8*i]= 0;
996 996
            }else{
997
            h->non_zero_count_cache[3+8*1 + 2*8*i]=
998
            h->non_zero_count_cache[3+8*2 + 2*8*i]=
999
            h->non_zero_count_cache[0+8*1 +   8*i]=
1000
            h->non_zero_count_cache[0+8*4 +   8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64;
997
                h->non_zero_count_cache[3+8*1 + 2*8*i]=
998
                h->non_zero_count_cache[3+8*2 + 2*8*i]=
999
                h->non_zero_count_cache[0+8*1 +   8*i]=
1000
                h->non_zero_count_cache[0+8*4 +   8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64;
1001 1001
            }
1002 1002
        }
1003 1003
    }
......
1087 1087
                    h->ref_cache[list][scan8[0] + 2 - 1*8]=
1088 1088
                    h->ref_cache[list][scan8[0] + 3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]];
1089 1089
                }else{
1090
                h->ref_cache[list][scan8[0] + 0 - 1*8]=
1091
                h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0];
1092
                h->ref_cache[list][scan8[0] + 2 - 1*8]=
1093
                h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1];
1090
                    h->ref_cache[list][scan8[0] + 0 - 1*8]=
1091
                    h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0];
1092
                    h->ref_cache[list][scan8[0] + 2 - 1*8]=
1093
                    h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1];
1094 1094
                }
1095 1095
            }else{
1096 1096
                *(uint32_t*)h->mv_cache [list][scan8[0] + 0 - 1*8]=
......
1112 1112
                        h->ref_cache[list][cache_idx  ]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)]];
1113 1113
                        h->ref_cache[list][cache_idx+8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)]];
1114 1114
                    }else{
1115
                    h->ref_cache[list][cache_idx  ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)];
1116
                    h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)];
1115
                        h->ref_cache[list][cache_idx  ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)];
1116
                        h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)];
1117 1117
                    }
1118 1118
                }else{
1119 1119
                    *(uint32_t*)h->mv_cache [list][cache_idx  ]=
......
1262 1262
#endif
1263 1263

  
1264 1264
    if(!for_deblock)
1265
    h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[0]);
1265
        h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[0]);
1266 1266
    return 0;
1267 1267
}
1268 1268

  

Also available in: Unified diff