diff error_resilience.c @ 1668:30746f429df6 libavcodec

move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>) cleanups & fixes by me
author michael
date Tue, 09 Dec 2003 01:49:56 +0000
parents 932d306bf1dc
children 8bccf5eda14b
line wrap: on
line diff
--- a/error_resilience.c	Mon Dec 08 18:26:22 2003 +0000
+++ b/error_resilience.c	Tue Dec 09 01:49:56 2003 +0000
@@ -209,8 +209,8 @@
             int left_damage =  left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
             int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
             int offset= b_x*8 + b_y*stride*8;
-            int16_t *left_mv=  s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x   <<(1-is_luma))];
-            int16_t *right_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))];
+            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))];
+            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))];
             
             if(!(left_damage||right_damage)) continue; // both undamaged
             
@@ -269,8 +269,8 @@
             int top_damage =      top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
             int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
             int offset= b_x*8 + b_y*stride*8;
-            int16_t *top_mv=    s->motion_val[s->block_wrap[0]*(( b_y   <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
-            int16_t *bottom_mv= s->motion_val[s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))];
+            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))];
+            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))];
             
             if(!(top_damage||bottom_damage)) continue; // both undamaged
             
@@ -380,8 +380,8 @@
                     int best_pred=0;
                     const int mot_stride= mb_width*2+2;
                     const int mot_index= mb_x*2 + 1 + (mb_y*2+1)*mot_stride;
-                    int prev_x= s->motion_val[mot_index][0];
-                    int prev_y= s->motion_val[mot_index][1];
+                    int prev_x= s->current_picture.motion_val[0][mot_index][0];
+                    int prev_y= s->current_picture.motion_val[0][mot_index][1];
 
                     if((mb_x^mb_y^pass)&1) continue;
                     
@@ -406,23 +406,23 @@
                     none_left=0;
                     
                     if(mb_x>0 && fixed[mb_xy-1]){
-                        mv_predictor[pred_count][0]= s->motion_val[mot_index - 2][0];
-                        mv_predictor[pred_count][1]= s->motion_val[mot_index - 2][1];
+                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - 2][0];
+                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - 2][1];
                         pred_count++;
                     }
                     if(mb_x+1<mb_width && fixed[mb_xy+1]){
-                        mv_predictor[pred_count][0]= s->motion_val[mot_index + 2][0];
-                        mv_predictor[pred_count][1]= s->motion_val[mot_index + 2][1];
+                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + 2][0];
+                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + 2][1];
                         pred_count++;
                     }
                     if(mb_y>0 && fixed[mb_xy-mb_stride]){
-                        mv_predictor[pred_count][0]= s->motion_val[mot_index - mot_stride*2][0];
-                        mv_predictor[pred_count][1]= s->motion_val[mot_index - mot_stride*2][1];
+                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*2][0];
+                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*2][1];
                         pred_count++;
                     }
                     if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
-                        mv_predictor[pred_count][0]= s->motion_val[mot_index + mot_stride*2][0];
-                        mv_predictor[pred_count][1]= s->motion_val[mot_index + mot_stride*2][1];
+                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*2][0];
+                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*2][1];
                         pred_count++;
                     }
                     if(pred_count==0) continue;
@@ -467,8 +467,8 @@
                     pred_count++;
 
                     /* last MV */
-                    mv_predictor[pred_count][0]= s->motion_val[mot_index][0];
-                    mv_predictor[pred_count][1]= s->motion_val[mot_index][1];
+                    mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0];
+                    mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1];
                     pred_count++;                    
                     
                     s->mv_dir = MV_DIR_FORWARD;
@@ -485,8 +485,8 @@
                         int score=0;
                         uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
 
-                        s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
-                        s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
+                        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];
 
                         decode_mb(s);
                         
@@ -517,9 +517,9 @@
                         }
                     }
 score_sum+= best_score;
-//FIXME no need to set s->motion_val[mot_index][0] explicit
-                    s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0];
-                    s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1];
+//FIXME no need to set s->current_picture.motion_val[0][mot_index][0] explicit
+                    s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0];
+                    s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1];
 
                     decode_mb(s);
 
@@ -671,12 +671,12 @@
 
     av_log(s->avctx, AV_LOG_INFO, "concealing errors\n");
     
-    if(s->motion_val == NULL){
+    if(s->current_picture.motion_val[0] == NULL){
         int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
         
         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
         
-        s->motion_val= av_mallocz(size * 2 * sizeof(int16_t));
+        s->current_picture.motion_val[0]= av_mallocz(size * 2 * sizeof(int16_t)); //FIXME
     }
     
     if(s->avctx->debug&FF_DEBUG_ER){
@@ -843,13 +843,13 @@
                 int j;
                 s->mv_type = MV_TYPE_8X8;
                 for(j=0; j<4; j++){
-                    s->mv[0][j][0] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0];
-                    s->mv[0][j][1] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1];
+                    s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0];
+                    s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1];
                 }
             }else{
                 s->mv_type = MV_TYPE_16X16;
-                s->mv[0][0][0] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0];
-                s->mv[0][0][1] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][1];
+                s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0];
+                s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][1];
             }
         
 	    s->dsp.clear_blocks(s->block[0]);
@@ -882,10 +882,10 @@
                     int time_pp= s->pp_time;
                     int time_pb= s->pb_time;
             
-                    s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp;
-                    s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp;
-                    s->mv[1][0][0] = s->motion_val[xy][0]*(time_pb - time_pp)/time_pp;
-                    s->mv[1][0][1] = s->motion_val[xy][1]*(time_pb - time_pp)/time_pp;
+                    s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp;
+                    s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp;
+                    s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
+                    s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;
                 }else{
                     s->mv[0][0][0]= 0;
                     s->mv[0][0][1]= 0;