]> git.videolan.org Git - x264.git/commitdiff
invalidate_reference fixes
authorJason Garrett-Glaser <darkshikari@gmail.com>
Wed, 28 Jul 2010 21:23:53 +0000 (14:23 -0700)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Thu, 29 Jul 2010 02:29:38 +0000 (19:29 -0700)
invalidate_reference didn't actually invalidate the immediate previous frame, only frames that came before that.
Make sure that reordering is forced when invalidate_reference is used, so that the reference list is correct decoder-side.

encoder/encoder.c

index ae82059d921aa3ba664d9143d0f9337cb1467670..513c159275ff4226514fde7a224e46fd86da07ee 100644 (file)
@@ -1396,13 +1396,21 @@ int x264_encoder_headers( x264_t *h, x264_nal_t **pp_nal, int *pi_nal )
  * from the standard's default. */
 static inline void x264_reference_check_reorder( x264_t *h )
 {
+    /* The reorder check doesn't check for missing frames, so just
+     * force a reorder if one of the reference list is corrupt. */
+    for( int i = 0; h->frames.reference[i]; i++ )
+        if( h->frames.reference[i]->b_corrupt )
+        {
+            h->b_ref_reorder[0] = 1;
+            return;
+        }
     for( int i = 0; i < h->i_ref0 - 1; i++ )
         /* P and B-frames use different default orders. */
         if( h->sh.i_type == SLICE_TYPE_P ? h->fref0[i]->i_frame_num < h->fref0[i+1]->i_frame_num
                                          : h->fref0[i]->i_poc < h->fref0[i+1]->i_poc )
         {
             h->b_ref_reorder[0] = 1;
-            break;
+            return;
         }
 }
 
@@ -2231,9 +2239,13 @@ int x264_encoder_invalidate_reference( x264_t *h, int64_t pts )
     }
     h = h->thread[h->i_thread_phase];
     if( pts >= h->i_last_idr_pts )
+    {
         for( int i = 0; h->frames.reference[i]; i++ )
             if( pts <= h->frames.reference[i]->i_pts )
                 h->frames.reference[i]->b_corrupt = 1;
+        if( pts <= h->fdec->i_pts )
+            h->fdec->b_corrupt = 1;
+    }
     return 0;
 }