Change ref_index structure so it matches how its organized in h264.
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 23 Mar 2010 02:17:04 +0000 (02:17 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 23 Mar 2010 02:17:04 +0000 (02:17 +0000)
Also revert the related error concealment hotfix.

Originally committed as revision 22640 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/error_resilience.c
libavcodec/h263.c
libavcodec/motion_est.c
libavcodec/mpeg12.c
libavcodec/mpeg4video.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c

index 5dd52eb..fffe19c 100644 (file)
@@ -486,7 +486,7 @@ int score_sum=0;
                             sum_x+= mv_predictor[j][0];
                             sum_y+= mv_predictor[j][1];
                             sum_r+= ref[j];
-                            if(j && ref[j] != ref[j-1] && s->codec_id == CODEC_ID_H264)
+                            if(j && ref[j] != ref[j-1])
                                 goto skip_mean_and_median;
                         }
 
@@ -549,7 +549,7 @@ skip_mean_and_median:
                         s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
                         s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
 
-                        if(ref[j]<0 && s->codec_id == CODEC_ID_H264) //predictor intra or otherwise not available
+                        if(ref[j]<0) //predictor intra or otherwise not available
                             continue;
 
                         decode_mb(s, ref[j]);
@@ -767,7 +767,6 @@ void ff_er_frame_end(MpegEncContext *s){
         pic->motion_subsample_log2= 3;
         s->current_picture= *s->current_picture_ptr;
     }
-    pic->ref_index[0]= av_realloc(pic->ref_index[0], s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
 
     if(s->avctx->debug&FF_DEBUG_ER){
         for(mb_y=0; mb_y<s->mb_height; mb_y++){
index 2eb1ff5..d5d5c38 100644 (file)
@@ -71,10 +71,10 @@ void ff_h263_update_motion_val(MpegEncContext * s){
                 s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
                 s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
             }
-            s->current_picture.ref_index[0][xy           ]=
-            s->current_picture.ref_index[0][xy        + 1]= s->field_select[0][0];
-            s->current_picture.ref_index[0][xy + wrap    ]=
-            s->current_picture.ref_index[0][xy + wrap + 1]= s->field_select[0][1];
+            s->current_picture.ref_index[0][4*mb_xy    ]=
+            s->current_picture.ref_index[0][4*mb_xy + 1]= s->field_select[0][0];
+            s->current_picture.ref_index[0][4*mb_xy + 2]=
+            s->current_picture.ref_index[0][4*mb_xy + 3]= s->field_select[0][1];
         }
 
         /* no update if 8X8 because it has been done during parsing */
index 1f5dbc7..75a664b 100644 (file)
@@ -850,8 +850,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
         }
 
         if(USES_LIST(mb_type, 0)){
-            int field_select0= p->ref_index[0][xy ];
-            int field_select1= p->ref_index[0][xy2];
+            int field_select0= p->ref_index[0][4*mb_xy  ];
+            int field_select1= p->ref_index[0][4*mb_xy+2];
             assert(field_select0==0 ||field_select0==1);
             assert(field_select1==0 ||field_select1==1);
             init_interlaced_ref(s, 0);
@@ -878,8 +878,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);
         }
         if(USES_LIST(mb_type, 1)){
-            int field_select0= p->ref_index[1][xy ];
-            int field_select1= p->ref_index[1][xy2];
+            int field_select0= p->ref_index[1][4*mb_xy  ];
+            int field_select1= p->ref_index[1][4*mb_xy+2];
             assert(field_select0==0 ||field_select0==1);
             assert(field_select1==0 ||field_select1==1);
             init_interlaced_ref(s, 2);
index 4ae5b64..1cd9acc 100644 (file)
@@ -1760,6 +1760,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
         if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs
             const int wrap = s->b8_stride;
             int xy = s->mb_x*2 + s->mb_y*2*wrap;
+            int b8_xy= 4*(s->mb_x + s->mb_y*s->mb_stride);
             int motion_x, motion_y, dir, i;
 
             for(i=0; i<2; i++){
@@ -1778,11 +1779,12 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
                     s->current_picture.motion_val[dir][xy    ][1] = motion_y;
                     s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
                     s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
-                    s->current_picture.ref_index [dir][xy    ]=
-                    s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i];
+                    s->current_picture.ref_index [dir][b8_xy    ]=
+                    s->current_picture.ref_index [dir][b8_xy + 1]= s->field_select[dir][i];
                     assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1);
                 }
                 xy += wrap;
+                b8_xy +=2;
             }
         }
 
index a647960..dd4dd8a 100644 (file)
@@ -137,7 +137,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
     } else if(IS_INTERLACED(colocated_mb_type)){
         s->mv_type = MV_TYPE_FIELD;
         for(i=0; i<2; i++){
-            int field_select= s->next_picture.ref_index[0][s->block_index[2*i]];
+            int field_select= s->next_picture.ref_index[0][4*mb_index + 2*i];
             s->field_select[0][i]= field_select;
             s->field_select[1][i]= i;
             if(s->top_field_first){
index 1dbe7ed..b47ff9a 100644 (file)
@@ -296,7 +296,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
             for(i=0; i<2; i++){
                 FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail)
                 pic->motion_val[i]= pic->motion_val_base[i]+4;
-                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], b8_array_size * sizeof(uint8_t), fail)
+                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
             }
             pic->motion_subsample_log2= 3;
         }
index 44a0d81..aa68bec 100644 (file)
@@ -197,7 +197,7 @@ static void copy_picture_attributes(MpegEncContext *s, AVFrame *dst, AVFrame *sr
                 memcpy(dst->motion_val[i], src->motion_val[i], 2*stride*height*sizeof(int16_t));
             }
             if(src->ref_index[i] && src->ref_index[i] != dst->ref_index[i]){
-                memcpy(dst->ref_index[i], src->ref_index[i], s->b8_stride*2*s->mb_height*sizeof(int8_t));
+                memcpy(dst->ref_index[i], src->ref_index[i], s->mb_stride*4*s->mb_height*sizeof(int8_t));
             }
         }
     }