Revision 6d7e6b26

View differences:

libavcodec/h264.c
2087 2087
    }
2088 2088

  
2089 2089
    for(j=0; j<2; j++){
2090
        int id_list[16];
2090 2091
        int *ref2frm= h->ref2frm[h->slice_num&(MAX_SLICES-1)][j];
2092
        for(i=0; i<16; i++){
2093
            id_list[i]= 60;
2094
            if(h->ref_list[j][i].data[0]){
2095
                int k;
2096
                uint8_t *base= h->ref_list[j][i].base[0];
2097
                for(k=0; k<h->short_ref_count; k++)
2098
                    if(h->short_ref[k]->base[0] == base){
2099
                        id_list[i]= k;
2100
                        break;
2101
                    }
2102
                for(k=0; k<h->long_ref_count; k++)
2103
                    if(h->long_ref[k] && h->long_ref[k]->base[0] == base){
2104
                        id_list[i]= h->short_ref_count + k;
2105
                        break;
2106
                    }
2107
            }
2108
        }
2109

  
2091 2110
        ref2frm[0]=
2092 2111
        ref2frm[1]= -1;
2093 2112
        for(i=0; i<16; i++)
2094
            ref2frm[i+2]= 4*h->ref_list[j][i].frame_num
2113
            ref2frm[i+2]= 4*id_list[i]
2095 2114
                          +(h->ref_list[j][i].reference&3);
2096 2115
        ref2frm[18+0]=
2097 2116
        ref2frm[18+1]= -1;
2098 2117
        for(i=16; i<48; i++)
2099
            ref2frm[i+4]= 4*h->ref_list[j][i].frame_num
2118
            ref2frm[i+4]= 4*id_list[(i-16)>>1]
2100 2119
                          +(h->ref_list[j][i].reference&3);
2101 2120
    }
2102 2121

  
libavcodec/h264.h
834 834
                }
835 835

  
836 836
                ref = &s->current_picture.ref_index[list][h->mb2b8_xy[mb_xy]];
837
                if(for_deblock){
838
                    int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
839
                    *(uint32_t*)&h->ref_cache[list][scan8[ 0]] =
840
                    *(uint32_t*)&h->ref_cache[list][scan8[ 2]] = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101;
841
                    ref += h->b8_stride;
842
                    *(uint32_t*)&h->ref_cache[list][scan8[ 8]] =
843
                    *(uint32_t*)&h->ref_cache[list][scan8[10]] = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101;
844
                }else{
837 845
                *(uint32_t*)&h->ref_cache[list][scan8[ 0]] =
838 846
                *(uint32_t*)&h->ref_cache[list][scan8[ 2]] = (pack16to32(ref[0],ref[1])&0x00FF00FF)*0x0101;
839 847
                ref += h->b8_stride;
840 848
                *(uint32_t*)&h->ref_cache[list][scan8[ 8]] =
841 849
                *(uint32_t*)&h->ref_cache[list][scan8[10]] = (pack16to32(ref[0],ref[1])&0x00FF00FF)*0x0101;
850
                }
842 851

  
843 852
                b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
844 853
                for(y=0; y<4; y++){
......
1029 1038
                *(uint32_t*)h->mv_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 1];
1030 1039
                *(uint32_t*)h->mv_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 2];
1031 1040
                *(uint32_t*)h->mv_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 3];
1041
                if(for_deblock){
1042
                    int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
1043
                    h->ref_cache[list][scan8[0] + 0 - 1*8]=
1044
                    h->ref_cache[list][scan8[0] + 1 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 0]];
1045
                    h->ref_cache[list][scan8[0] + 2 - 1*8]=
1046
                    h->ref_cache[list][scan8[0] + 3 - 1*8]= ref2frm[list][s->current_picture.ref_index[list][b8_xy + 1]];
1047
                }else{
1032 1048
                h->ref_cache[list][scan8[0] + 0 - 1*8]=
1033 1049
                h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0];
1034 1050
                h->ref_cache[list][scan8[0] + 2 - 1*8]=
1035 1051
                h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1];
1052
                }
1036 1053
            }else{
1037 1054
                *(uint32_t*)h->mv_cache [list][scan8[0] + 0 - 1*8]=
1038 1055
                *(uint32_t*)h->mv_cache [list][scan8[0] + 1 - 1*8]=
1039 1056
                *(uint32_t*)h->mv_cache [list][scan8[0] + 2 - 1*8]=
1040 1057
                *(uint32_t*)h->mv_cache [list][scan8[0] + 3 - 1*8]= 0;
1041
                *(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101;
1058
                *(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= (((for_deblock||top_type) ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101;
1042 1059
            }
1043 1060

  
1044 1061
            for(i=0; i<2; i++){
......
1048 1065
                    const int b8_xy= h->mb2b8_xy[left_xy[i]] + 1;
1049 1066
                    *(uint32_t*)h->mv_cache[list][cache_idx  ]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0+i*2]];
1050 1067
                    *(uint32_t*)h->mv_cache[list][cache_idx+8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1+i*2]];
1068
                    if(for_deblock){
1069
                        int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[i]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
1070
                        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)]];
1071
                        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)]];
1072
                    }else{
1051 1073
                    h->ref_cache[list][cache_idx  ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)];
1052 1074
                    h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)];
1075
                    }
1053 1076
                }else{
1054 1077
                    *(uint32_t*)h->mv_cache [list][cache_idx  ]=
1055 1078
                    *(uint32_t*)h->mv_cache [list][cache_idx+8]= 0;
1056 1079
                    h->ref_cache[list][cache_idx  ]=
1057
                    h->ref_cache[list][cache_idx+8]= left_type[i] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
1080
                    h->ref_cache[list][cache_idx+8]= (for_deblock||left_type[i]) ? LIST_NOT_USED : PART_NOT_AVAILABLE;
1058 1081
                }
1059 1082
            }
1060 1083

  
libavcodec/h264_loopfilter.c
445 445
    int edge;
446 446
    const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
447 447
    const int mbm_type = s->current_picture.mb_type[mbm_xy];
448
    int (*ref2frm) [64] = h->ref2frm[ h->slice_num          &(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
449
    int (*ref2frmm)[64] = h->ref2frm[ h->slice_table[mbm_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
450 448
    int start = h->slice_table[mbm_xy] == 0xFFFF ? 1 : 0;
451 449

  
452 450
    const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP))
......
513 511
        /* mbn_xy: neighbor macroblock */
514 512
        const int mbn_xy = edge > 0 ? mb_xy : mbm_xy;
515 513
        const int mbn_type = s->current_picture.mb_type[mbn_xy];
516
        int (*ref2frmn)[64] = edge > 0 ? ref2frm : ref2frmm;
517 514
        int16_t bS[4];
518 515
        int qp;
519 516

  
......
553 550
                int v = 0;
554 551

  
555 552
                for( l = 0; !v && l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) {
556
                    v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] |
553
                    v |= h->ref_cache[l][b_idx] != h->ref_cache[l][bn_idx] |
557 554
                         h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] + 3 >= 7U |
558 555
                         FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit;
559 556
                }
......
562 559
                    v=0;
563 560
                    for( l = 0; !v && l < 2; l++ ) {
564 561
                        int ln= 1-l;
565
                        v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] |
562
                        v |= h->ref_cache[l][b_idx] != h->ref_cache[ln][bn_idx] |
566 563
                            h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] + 3 >= 7U |
567 564
                            FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit;
568 565
                    }
......
588 585
                {
589 586
                    bS[i] = 0;
590 587
                    for( l = 0; l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) {
591
                        if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] |
588
                        if( h->ref_cache[l][b_idx] != h->ref_cache[l][bn_idx] |
592 589
                            h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] + 3 >= 7U |
593 590
                            FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) {
594 591
                            bS[i] = 1;
......
600 597
                        bS[i] = 0;
601 598
                        for( l = 0; l < 2; l++ ) {
602 599
                            int ln= 1-l;
603
                            if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] |
600
                            if( h->ref_cache[l][b_idx] != h->ref_cache[ln][bn_idx] |
604 601
                                h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] + 3 >= 7U |
605 602
                                FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit ) {
606 603
                                bS[i] = 1;

Also available in: Unified diff