[x264-devel] commit: Remove reordering restrictions from weightp (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Sat Apr 24 00:40:06 CEST 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Mon Apr 19 11:02:27 2010 -0700| [c76069fec1b7711c754fea593abaf470901e54c3] | committer: Jason Garrett-Glaser 

Remove reordering restrictions from weightp
Apparently the spec does allow two consecutive copies of the same frame in the reference list.
This involves an incredibly ugly hack to wrap around the frame number.
Very slight compression improvement.

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

 encoder/encoder.c     |   19 ++-----------------
 encoder/ratecontrol.c |    5 ++---
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 0f9ba87..f641f63 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -140,10 +140,8 @@ static void x264_slice_header_init( x264_t *h, x264_slice_header_t *sh,
         for( int i = 0; i < h->i_ref0; i++ )
         {
             int diff = h->fref0[i]->i_frame_num - pred_frame_num;
-            if( diff == 0 )
-                x264_log( h, X264_LOG_ERROR, "diff frame num == 0\n" );
             sh->ref_pic_list_order[0][i].idc = ( diff > 0 );
-            sh->ref_pic_list_order[0][i].arg = abs( diff ) - 1;
+            sh->ref_pic_list_order[0][i].arg = (abs(diff) - 1) & ((1 << sps->i_log2_max_frame_num) - 1);
             pred_frame_num = h->fref0[i]->i_frame_num;
         }
     }
@@ -1336,24 +1334,11 @@ static inline void x264_reference_check_reorder( x264_t *h )
 int x264_weighted_reference_duplicate( x264_t *h, int i_ref, const x264_weight_t *w )
 {
     int i = h->i_ref0;
-    int j;
+    int j = 1;
     x264_frame_t *newframe;
     if( i <= 1 ) /* empty list, definitely can't duplicate frame */
         return -1;
 
-    /* Find a place to insert the duplicate in the reference list. */
-    for( j = 0; j < i; j++ )
-        if( h->fref0[i_ref]->i_frame != h->fref0[j]->i_frame )
-        {
-            /* found a place, after j, make sure there is not already a duplicate there */
-            if( j == i-1 || ( h->fref0[i_ref]->i_frame != h->fref0[j+1]->i_frame ) )
-                break;
-        }
-
-    if( j == i ) /* No room in the reference list for the duplicate. */
-        return -1;
-    j++;
-
     newframe = x264_frame_pop_blank_unused( h );
 
     //FIXME: probably don't need to copy everything
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 1b4dda4..c29e8c5 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -375,9 +375,8 @@ int x264_reference_build_list_optimal( x264_t *h )
         int bestref = 1;
 
         for( int i = 1; i < h->i_ref0; i++ )
-            if( !frames[i]->b_duplicate || frames[i]->i_frame != h->fref0[ref-1]->i_frame )
-                /* Favor lower POC as a tiebreaker. */
-                COPY2_IF_GT( max, refcount[i], bestref, i );
+            /* Favor lower POC as a tiebreaker. */
+            COPY2_IF_GT( max, refcount[i], bestref, i );
 
         /* FIXME: If there are duplicates from frames other than ref0 then it is possible
          * that the optimal ordering doesnt place every duplicate. */



More information about the x264-devel mailing list