[x264-devel] commit: Save a few bits in slice headers (Kieran Kunhya )

git at videolan.org git at videolan.org
Sun Mar 28 04:44:22 CEST 2010


x264 | branch: master | Kieran Kunhya <kieran at kunhya.com> | Fri Mar  5 20:43:02 2010 +0000| [db2bae305ef658d053c7c174703c4631a2534b1a] | committer: Jason Garrett-Glaser 

Save a few bits in slice headers
Don't override the maximum ref index in the slice header if it's the same as the default.
Also update the naming of the relevant variables in the PPS.

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

 common/set.h      |    4 ++--
 encoder/encoder.c |    7 +++++--
 encoder/set.c     |    8 ++++----
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/common/set.h b/common/set.h
index f55e6e3..9783118 100644
--- a/common/set.h
+++ b/common/set.h
@@ -163,8 +163,8 @@ typedef struct
     int b_pic_order;
     int i_num_slice_groups;
 
-    int i_num_ref_idx_l0_active;
-    int i_num_ref_idx_l1_active;
+    int i_num_ref_idx_l0_default_active;
+    int i_num_ref_idx_l1_default_active;
 
     int b_weighted_pred;
     int b_weighted_bipred;
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 5aa2d87..c5ee306 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1732,10 +1732,13 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )
     {
         x264_slice_header_init( h, &h->sh, h->sps, h->pps, -1, h->i_frame_num, i_global_qp );
 
-        /* always set the real higher num of ref frame used */
-        h->sh.b_num_ref_idx_override = 1;
         h->sh.i_num_ref_idx_l0_active = h->i_ref0 <= 0 ? 1 : h->i_ref0;
         h->sh.i_num_ref_idx_l1_active = h->i_ref1 <= 0 ? 1 : h->i_ref1;
+        if( h->sh.i_num_ref_idx_l0_active != h->pps->i_num_ref_idx_l0_default_active ||
+            (h->sh.i_type == SLICE_TYPE_B && h->sh.i_num_ref_idx_l1_active != h->pps->i_num_ref_idx_l1_default_active) )
+        {
+            h->sh.b_num_ref_idx_override = 1;
+        }
     }
 
     h->fdec->i_frame_num = h->sh.i_frame_num;
diff --git a/encoder/set.c b/encoder/set.c
index 974fb53..41d5ae2 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -426,8 +426,8 @@ void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *
     pps->b_pic_order = param->b_interlaced;
     pps->i_num_slice_groups = 1;
 
-    pps->i_num_ref_idx_l0_active = 1;
-    pps->i_num_ref_idx_l1_active = 1;
+    pps->i_num_ref_idx_l0_default_active = param->i_frame_reference;
+    pps->i_num_ref_idx_l1_default_active = 1;
 
     pps->b_weighted_pred = param->analyse.i_weighted_pred > 0;
     pps->b_weighted_bipred = param->analyse.b_weighted_bipred ? 2 : 0;
@@ -485,8 +485,8 @@ void x264_pps_write( bs_t *s, x264_pps_t *pps )
     bs_write( s, 1, pps->b_pic_order );
     bs_write_ue( s, pps->i_num_slice_groups - 1 );
 
-    bs_write_ue( s, pps->i_num_ref_idx_l0_active - 1 );
-    bs_write_ue( s, pps->i_num_ref_idx_l1_active - 1 );
+    bs_write_ue( s, pps->i_num_ref_idx_l0_default_active - 1 );
+    bs_write_ue( s, pps->i_num_ref_idx_l1_default_active - 1 );
     bs_write( s, 1, pps->b_weighted_pred );
     bs_write( s, 2, pps->b_weighted_bipred );
 



More information about the x264-devel mailing list