[x264-devel] commit: invalidate_reference fixes (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Thu Jul 29 08:17:07 CEST 2010


x264 | branch: stable | Jason Garrett-Glaser <darkshikari at gmail.com> | Wed Jul 28 14:23:53 2010 -0700| [d939ccf006b9b74078303f73e6c7fb83158d46fb] | committer: Jason Garrett-Glaser 

invalidate_reference fixes
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.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=d939ccf006b9b74078303f73e6c7fb83158d46fb
---

 encoder/encoder.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index ae82059..513c159 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -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;
 }
 



More information about the x264-devel mailing list