Revision 137c8468 libavcodec/error_resilience.c

View differences:

libavcodec/error_resilience.c
45 45
{
46 46
    int dc, dcu, dcv, y, i;
47 47
    for(i=0; i<4; i++){
48
        dc= s->dc_val[0][mb_x*2+1 + (i&1) + (mb_y*2+1 + (i>>1))*(s->mb_width*2+2)];
48
        dc= s->dc_val[0][mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride];
49 49
        if(dc<0) dc=0;
50 50
        else if(dc>2040) dc=2040;
51 51
        for(y=0; y<8; y++){
......
55 55
            }
56 56
        }
57 57
    }
58
    dcu = s->dc_val[1][mb_x+1 + (mb_y+1)*(s->mb_width+2)];
59
    dcv = s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)];
58
    dcu = s->dc_val[1][mb_x + mb_y*s->mb_stride];
59
    dcv = s->dc_val[2][mb_x + mb_y*s->mb_stride];
60 60
    if     (dcu<0   ) dcu=0;
61 61
    else if(dcu>2040) dcu=2040;
62 62
    if     (dcv<0   ) dcv=0;
......
209 209
            int left_damage =  left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
210 210
            int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
211 211
            int offset= b_x*8 + b_y*stride*8;
212
            int16_t *left_mv=  s->current_picture.motion_val[0][s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x   <<(1-is_luma))];
213
            int16_t *right_mv= s->current_picture.motion_val[0][s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))];
212
            int16_t *left_mv=  s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ( b_x   <<(1-is_luma))];
213
            int16_t *right_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ((b_x+1)<<(1-is_luma))];
214 214
            
215 215
            if(!(left_damage||right_damage)) continue; // both undamaged
216 216
            
......
269 269
            int top_damage =      top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
270 270
            int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
271 271
            int offset= b_x*8 + b_y*stride*8;
272
            int16_t *top_mv=    s->current_picture.motion_val[0][s->block_wrap[0]*(( b_y   <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
273
            int16_t *bottom_mv= s->current_picture.motion_val[0][s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
272
            int16_t *top_mv=    s->current_picture.motion_val[0][s->b8_stride*( b_y   <<(1-is_luma)) + (b_x<<(1-is_luma))];
273
            int16_t *bottom_mv= s->current_picture.motion_val[0][s->b8_stride*((b_y+1)<<(1-is_luma)) + (b_x<<(1-is_luma))];
274 274
            
275 275
            if(!(top_damage||bottom_damage)) continue; // both undamaged
276 276
            
......
378 378
                    int j;
379 379
                    int best_score=256*256*256*64;
380 380
                    int best_pred=0;
381
                    const int mot_stride= mb_width*2+2;
382
                    const int mot_index= mb_x*2 + 1 + (mb_y*2+1)*mot_stride;
381
                    const int mot_stride= s->b8_stride;
382
                    const int mot_index= mb_x*2 + mb_y*2*mot_stride;
383 383
                    int prev_x= s->current_picture.motion_val[0][mot_index][0];
384 384
                    int prev_y= s->current_picture.motion_val[0][mot_index][1];
385 385

  
......
672 672
    av_log(s->avctx, AV_LOG_INFO, "concealing errors\n");
673 673
    
674 674
    if(s->current_picture.motion_val[0] == NULL){
675
        int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
675
        int size = s->b8_stride * 2 * s->mb_height;
676 676
        Picture *pic= s->current_picture_ptr;
677 677
        
678 678
        av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
679 679
            
680 680
        for(i=0; i<2; i++){
681
            pic->motion_val_base[i]= av_mallocz((size+1) * 2 * sizeof(uint16_t)); //FIXME size
682
            pic->motion_val[i]= pic->motion_val_base[i]+1;
681
            pic->motion_val_base[i]= av_mallocz((size+2) * 2 * sizeof(uint16_t));
682
            pic->motion_val[i]= pic->motion_val_base[i]+2;
683 683
        }
684 684
        pic->motion_subsample_log2= 3;
685 685
        s->current_picture= *s->current_picture_ptr;
......
845 845
            s->mb_intra=0;
846 846
            s->mb_skiped=0;
847 847
            if(IS_8X8(mb_type)){
848
                int mb_index= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0];
848
                int mb_index= mb_x*2 + mb_y*2*s->b8_stride;
849 849
                int j;
850 850
                s->mv_type = MV_TYPE_8X8;
851 851
                for(j=0; j<4; j++){
852
                    s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0];
853
                    s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1];
852
                    s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][0];
853
                    s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][1];
854 854
                }
855 855
            }else{
856 856
                s->mv_type = MV_TYPE_16X16;
857
                s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0];
858
                s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][1];
857
                s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][0];
858
                s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][1];
859 859
            }
860 860
        
861 861
	    s->dsp.clear_blocks(s->block[0]);
......
870 870
    if(s->pict_type==B_TYPE){
871 871
        for(mb_y=0; mb_y<s->mb_height; mb_y++){
872 872
            for(mb_x=0; mb_x<s->mb_width; mb_x++){
873
                int xy= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0];
873
                int xy= mb_x*2 + mb_y*2*s->b8_stride;
874 874
                const int mb_xy= mb_x + mb_y * s->mb_stride;
875 875
                const int mb_type= s->current_picture.mb_type[mb_xy];
876 876
                error= s->error_status_table[mb_xy];
......
930 930
            dest_cb= s->current_picture.data[1] + mb_x*8  + mb_y*8 *s->uvlinesize;
931 931
            dest_cr= s->current_picture.data[2] + mb_x*8  + mb_y*8 *s->uvlinesize;
932 932
           
933
            dc_ptr= &s->dc_val[0][mb_x*2+1 + (mb_y*2+1)*(s->mb_width*2+2)];
933
            dc_ptr= &s->dc_val[0][mb_x*2 + mb_y*2*s->b8_stride];
934 934
            for(n=0; n<4; n++){
935 935
                dc=0;
936 936
                for(y=0; y<8; y++){
......
939 939
                       dc+= dest_y[x + (n&1)*8 + (y + (n>>1)*8)*s->linesize];
940 940
                    }
941 941
                }
942
                dc_ptr[(n&1) + (n>>1)*(s->mb_width*2+2)]= (dc+4)>>3;
942
                dc_ptr[(n&1) + (n>>1)*s->b8_stride]= (dc+4)>>3;
943 943
            }
944 944

  
945 945
            dcu=dcv=0;
......
950 950
                    dcv+=dest_cr[x + y*(s->uvlinesize)];
951 951
                }
952 952
            }
953
            s->dc_val[1][mb_x+1 + (mb_y+1)*(s->mb_width+2)]= (dcu+4)>>3;
954
            s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)]= (dcv+4)>>3;   
953
            s->dc_val[1][mb_x + mb_y*s->mb_stride]= (dcu+4)>>3;
954
            s->dc_val[2][mb_x + mb_y*s->mb_stride]= (dcv+4)>>3;   
955 955
        }
956 956
    }
957 957
#if 1
958 958
    /* guess DC for damaged blocks */
959
    guess_dc(s, s->dc_val[0] + s->mb_width*2+3, s->mb_width*2, s->mb_height*2, s->mb_width*2+2, 1);
960
    guess_dc(s, s->dc_val[1] + s->mb_width  +3, s->mb_width  , s->mb_height  , s->mb_width  +2, 0);
961
    guess_dc(s, s->dc_val[2] + s->mb_width  +3, s->mb_width  , s->mb_height  , s->mb_width  +2, 0);
959
    guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1);
960
    guess_dc(s, s->dc_val[1], s->mb_width  , s->mb_height  , s->mb_stride, 0);
961
    guess_dc(s, s->dc_val[2], s->mb_width  , s->mb_height  , s->mb_stride, 0);
962 962
#endif   
963 963
    /* filter luma DC */
964
    filter181(s->dc_val[0] + s->mb_width*2+3, s->mb_width*2, s->mb_height*2, s->mb_width*2+2);
964
    filter181(s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride);
965 965
    
966 966
#if 1
967 967
    /* render DC only intra */

Also available in: Unified diff