Browse code

Change ref_index structure so it matches how its organized in h264. Also revert the related error concealment hotfix.

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

Michael Niedermayer authored on 2010/03/23 11:17:04
Showing 7 changed files
... ...
@@ -486,7 +486,7 @@ int score_sum=0;
486 486
                             sum_x+= mv_predictor[j][0];
487 487
                             sum_y+= mv_predictor[j][1];
488 488
                             sum_r+= ref[j];
489
-                            if(j && ref[j] != ref[j-1] && s->codec_id == CODEC_ID_H264)
489
+                            if(j && ref[j] != ref[j-1])
490 490
                                 goto skip_mean_and_median;
491 491
                         }
492 492
 
... ...
@@ -549,7 +549,7 @@ skip_mean_and_median:
549 549
                         s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
550 550
                         s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
551 551
 
552
-                        if(ref[j]<0 && s->codec_id == CODEC_ID_H264) //predictor intra or otherwise not available
552
+                        if(ref[j]<0) //predictor intra or otherwise not available
553 553
                             continue;
554 554
 
555 555
                         decode_mb(s, ref[j]);
... ...
@@ -767,7 +767,6 @@ void ff_er_frame_end(MpegEncContext *s){
767 767
         pic->motion_subsample_log2= 3;
768 768
         s->current_picture= *s->current_picture_ptr;
769 769
     }
770
-    pic->ref_index[0]= av_realloc(pic->ref_index[0], s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
771 770
 
772 771
     if(s->avctx->debug&FF_DEBUG_ER){
773 772
         for(mb_y=0; mb_y<s->mb_height; mb_y++){
... ...
@@ -71,10 +71,10 @@ void ff_h263_update_motion_val(MpegEncContext * s){
71 71
                 s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
72 72
                 s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
73 73
             }
74
-            s->current_picture.ref_index[0][xy           ]=
75
-            s->current_picture.ref_index[0][xy        + 1]= s->field_select[0][0];
76
-            s->current_picture.ref_index[0][xy + wrap    ]=
77
-            s->current_picture.ref_index[0][xy + wrap + 1]= s->field_select[0][1];
74
+            s->current_picture.ref_index[0][4*mb_xy    ]=
75
+            s->current_picture.ref_index[0][4*mb_xy + 1]= s->field_select[0][0];
76
+            s->current_picture.ref_index[0][4*mb_xy + 2]=
77
+            s->current_picture.ref_index[0][4*mb_xy + 3]= s->field_select[0][1];
78 78
         }
79 79
 
80 80
         /* no update if 8X8 because it has been done during parsing */
... ...
@@ -850,8 +850,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
850 850
         }
851 851
 
852 852
         if(USES_LIST(mb_type, 0)){
853
-            int field_select0= p->ref_index[0][xy ];
854
-            int field_select1= p->ref_index[0][xy2];
853
+            int field_select0= p->ref_index[0][4*mb_xy  ];
854
+            int field_select1= p->ref_index[0][4*mb_xy+2];
855 855
             assert(field_select0==0 ||field_select0==1);
856 856
             assert(field_select1==0 ||field_select1==1);
857 857
             init_interlaced_ref(s, 0);
... ...
@@ -878,8 +878,8 @@ static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int
878 878
             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);
879 879
         }
880 880
         if(USES_LIST(mb_type, 1)){
881
-            int field_select0= p->ref_index[1][xy ];
882
-            int field_select1= p->ref_index[1][xy2];
881
+            int field_select0= p->ref_index[1][4*mb_xy  ];
882
+            int field_select1= p->ref_index[1][4*mb_xy+2];
883 883
             assert(field_select0==0 ||field_select0==1);
884 884
             assert(field_select1==0 ||field_select1==1);
885 885
             init_interlaced_ref(s, 2);
... ...
@@ -1760,6 +1760,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
1760 1760
         if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs
1761 1761
             const int wrap = s->b8_stride;
1762 1762
             int xy = s->mb_x*2 + s->mb_y*2*wrap;
1763
+            int b8_xy= 4*(s->mb_x + s->mb_y*s->mb_stride);
1763 1764
             int motion_x, motion_y, dir, i;
1764 1765
 
1765 1766
             for(i=0; i<2; i++){
... ...
@@ -1778,11 +1779,12 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
1778 1778
                     s->current_picture.motion_val[dir][xy    ][1] = motion_y;
1779 1779
                     s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
1780 1780
                     s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
1781
-                    s->current_picture.ref_index [dir][xy    ]=
1782
-                    s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i];
1781
+                    s->current_picture.ref_index [dir][b8_xy    ]=
1782
+                    s->current_picture.ref_index [dir][b8_xy + 1]= s->field_select[dir][i];
1783 1783
                     assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1);
1784 1784
                 }
1785 1785
                 xy += wrap;
1786
+                b8_xy +=2;
1786 1787
             }
1787 1788
         }
1788 1789
 
... ...
@@ -137,7 +137,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
137 137
     } else if(IS_INTERLACED(colocated_mb_type)){
138 138
         s->mv_type = MV_TYPE_FIELD;
139 139
         for(i=0; i<2; i++){
140
-            int field_select= s->next_picture.ref_index[0][s->block_index[2*i]];
140
+            int field_select= s->next_picture.ref_index[0][4*mb_index + 2*i];
141 141
             s->field_select[0][i]= field_select;
142 142
             s->field_select[1][i]= i;
143 143
             if(s->top_field_first){
... ...
@@ -296,7 +296,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
296 296
             for(i=0; i<2; i++){
297 297
                 FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail)
298 298
                 pic->motion_val[i]= pic->motion_val_base[i]+4;
299
-                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], b8_array_size * sizeof(uint8_t), fail)
299
+                FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
300 300
             }
301 301
             pic->motion_subsample_log2= 3;
302 302
         }
... ...
@@ -197,7 +197,7 @@ static void copy_picture_attributes(MpegEncContext *s, AVFrame *dst, AVFrame *sr
197 197
                 memcpy(dst->motion_val[i], src->motion_val[i], 2*stride*height*sizeof(int16_t));
198 198
             }
199 199
             if(src->ref_index[i] && src->ref_index[i] != dst->ref_index[i]){
200
-                memcpy(dst->ref_index[i], src->ref_index[i], s->b8_stride*2*s->mb_height*sizeof(int8_t));
200
+                memcpy(dst->ref_index[i], src->ref_index[i], s->mb_stride*4*s->mb_height*sizeof(int8_t));
201 201
             }
202 202
         }
203 203
     }