changeset 5432:e0624692025f libavcodec

move some code which was executed for every skipped MB so it is only executed for the first skipped mb in a run
author michael
date Tue, 31 Jul 2007 21:39:09 +0000
parents 192360fa9b06
children ce0db8111f94
files mpeg12.c
diffstat 1 files changed, 30 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mpeg12.c	Tue Jul 31 21:00:17 2007 +0000
+++ b/mpeg12.c	Tue Jul 31 21:39:09 2007 +0000
@@ -221,26 +221,7 @@
     assert(s->mb_skipped==0);
 
     if (s->mb_skip_run-- != 0) {
-        if(s->pict_type == I_TYPE){
-            av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-
-        /* skip mb */
-        s->mb_intra = 0;
-        for(i=0;i<12;i++)
-            s->block_last_index[i] = -1;
-        if(s->picture_structure == PICT_FRAME)
-            s->mv_type = MV_TYPE_16X16;
-        else
-            s->mv_type = MV_TYPE_FIELD;
         if (s->pict_type == P_TYPE) {
-            /* if P type, zero motion vector is implied */
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv[0][0][0] = s->mv[0][0][1] = 0;
-            s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
-            s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
-            s->field_select[0][0]= s->picture_structure - 1;
             s->mb_skipped = 1;
             s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
         } else {
@@ -253,12 +234,6 @@
             if(IS_INTRA(mb_type))
                 return -1;
 
-            /* if B type, reuse previous vectors and directions */
-            s->mv[0][0][0] = s->last_mv[0][0][0];
-            s->mv[0][0][1] = s->last_mv[0][0][1];
-            s->mv[1][0][0] = s->last_mv[1][0][0];
-            s->mv[1][0][1] = s->last_mv[1][0][1];
-
             s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
                 mb_type | MB_TYPE_SKIP;
 //            assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
@@ -1828,6 +1803,36 @@
                     break;
                 }
             }
+            if(s->mb_skip_run){
+                int i;
+                if(s->pict_type == I_TYPE){
+                    av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
+                    return -1;
+                }
+
+                /* skip mb */
+                s->mb_intra = 0;
+                for(i=0;i<12;i++)
+                    s->block_last_index[i] = -1;
+                if(s->picture_structure == PICT_FRAME)
+                    s->mv_type = MV_TYPE_16X16;
+                else
+                    s->mv_type = MV_TYPE_FIELD;
+                if (s->pict_type == P_TYPE) {
+                    /* if P type, zero motion vector is implied */
+                    s->mv_dir = MV_DIR_FORWARD;
+                    s->mv[0][0][0] = s->mv[0][0][1] = 0;
+                    s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
+                    s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
+                    s->field_select[0][0]= s->picture_structure - 1;
+                } else {
+                    /* if B type, reuse previous vectors and directions */
+                    s->mv[0][0][0] = s->last_mv[0][0][0];
+                    s->mv[0][0][1] = s->last_mv[0][0][1];
+                    s->mv[1][0][0] = s->last_mv[1][0][0];
+                    s->mv[1][0][1] = s->last_mv[1][0][1];
+                }
+            }
         }
     }
 eos: // end of slice