]> granicus.if.org Git - libx264/commitdiff
fix a bug with cabac + B-frames + mref + slices.
authorLoren Merritt <pengvado@videolan.org>
Wed, 1 Jun 2005 05:31:39 +0000 (05:31 +0000)
committerLoren Merritt <pengvado@videolan.org>
Wed, 1 Jun 2005 05:31:39 +0000 (05:31 +0000)
call visualization per frame instead of per slice.

git-svn-id: svn://svn.videolan.org/x264/trunk@244 df754926-b1dd-0310-bc7b-ec298dee348c

common/macroblock.c
encoder/encoder.c

index 190d726662afe4285de2a7635213ea3defc3ebf4..1f456a62aa1af4c3d7f88524d470a7e09f5db3db 100644 (file)
@@ -911,6 +911,8 @@ void x264_macroblock_slice_init( x264_t *h )
                 }
         }
     }
+    if( h->sh.i_type == SLICE_TYPE_P )
+        memset( h->mb.cache.skip, 0, X264_SCAN8_SIZE * sizeof( int8_t ) );
 }
 
 
@@ -1210,25 +1212,18 @@ void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y )
         }
 
         /* load skip */
-        if( h->param.b_cabac )
+        if( h->sh.i_type == SLICE_TYPE_B && h->param.b_cabac )
         {
-            if( h->sh.i_type == SLICE_TYPE_B )
+            memset( h->mb.cache.skip, 0, X264_SCAN8_SIZE * sizeof( int8_t ) );
+            if( i_left_xy >= 0 )
             {
-                memset( h->mb.cache.skip, 0, X264_SCAN8_SIZE * sizeof( int8_t ) );
-                if( i_left_xy >= 0 )
-                {
-                    h->mb.cache.skip[x264_scan8[0] - 1] = h->mb.skipbp[i_left_xy] & 0x2;
-                    h->mb.cache.skip[x264_scan8[8] - 1] = h->mb.skipbp[i_left_xy] & 0x8;
-                }
-                if( i_top_xy >= 0 )
-                {
-                    h->mb.cache.skip[x264_scan8[0] - 8] = h->mb.skipbp[i_top_xy] & 0x4;
-                    h->mb.cache.skip[x264_scan8[4] - 8] = h->mb.skipbp[i_top_xy] & 0x8;
-                }
+                h->mb.cache.skip[x264_scan8[0] - 1] = h->mb.skipbp[i_left_xy] & 0x2;
+                h->mb.cache.skip[x264_scan8[8] - 1] = h->mb.skipbp[i_left_xy] & 0x8;
             }
-            else if( h->mb.i_mb_xy == 0 && h->sh.i_type == SLICE_TYPE_P )
+            if( i_top_xy >= 0 )
             {
-                memset( h->mb.cache.skip, 0, X264_SCAN8_SIZE * sizeof( int8_t ) );
+                h->mb.cache.skip[x264_scan8[0] - 8] = h->mb.skipbp[i_top_xy] & 0x4;
+                h->mb.cache.skip[x264_scan8[4] - 8] = h->mb.skipbp[i_top_xy] & 0x8;
             }
         }
     }
index 82d54240f26d8afac8f37231ffe5fdffcdad4c10..854aa792cd5e3670200635d48cbd987418cb7c00 100644 (file)
@@ -908,11 +908,6 @@ static int x264_slice_write( x264_t *h )
     h->mb.i_last_qp = h->pps->i_pic_init_qp + h->sh.i_qp_delta;
     h->mb.i_last_dqp = 0;
 
-#if VISUALIZE
-    if( h->param.b_visualize )
-        x264_visualize_init( h );
-#endif
-
     for( mb_xy = h->sh.i_first_mb, i_skip = 0; mb_xy < h->sh.i_last_mb; mb_xy++ )
     {
         const int i_mb_y = mb_xy / h->sps->i_mb_width;
@@ -1012,14 +1007,6 @@ static int x264_slice_write( x264_t *h )
 
     x264_nal_end( h );
 
-#if VISUALIZE
-    if( h->param.b_visualize )
-    {
-        x264_visualize_show( h );
-        x264_visualize_close( h );
-    }
-#endif
-
     /* Compute misc bits */
     h->stat.frame.i_misc_bits = bs_pos( &h->out.bs )
                               + NALU_OVERHEAD * 8
@@ -1032,16 +1019,22 @@ static int x264_slice_write( x264_t *h )
 
 static inline int x264_slices_write( x264_t *h )
 {
+    int i_frame_size;
+
+#if VISUALIZE
+    if( h->param.b_visualize )
+        x264_visualize_init( h );
+#endif
+
     if( h->param.i_threads == 1 )
     {
         x264_slice_write( h );
-        return h->out.nal[h->out.i_nal-1].i_payload;
+        i_frame_size = h->out.nal[h->out.i_nal-1].i_payload;
     }
     else
     {
         int i_nal = h->out.i_nal;
         int i_bs_size = h->out.i_bitstream / h->param.i_threads;
-        int i_frame_size;
         int i;
         /* duplicate contexts */
         for( i = 0; i < h->param.i_threads; i++ )
@@ -1086,8 +1079,17 @@ static inline int x264_slices_write( x264_t *h )
                 ((int*)&h->stat.frame)[j] += ((int*)&t->stat.frame)[j];
         }
         h->out.i_nal = i_nal + h->param.i_threads;
-        return i_frame_size;
     }
+
+#if VISUALIZE
+    if( h->param.b_visualize )
+    {
+        x264_visualize_show( h );
+        x264_visualize_close( h );
+    }
+#endif
+
+    return i_frame_size;
 }
 
 /****************************************************************************