]> git.sesse.net Git - x264/commitdiff
Save a few bits in slice headers
authorKieran Kunhya <kieran@kunhya.com>
Fri, 5 Mar 2010 20:43:02 +0000 (20:43 +0000)
committerFiona Glaser <fiona@x264.com>
Sat, 27 Mar 2010 19:47:08 +0000 (12:47 -0700)
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.

common/set.h
encoder/encoder.c
encoder/set.c

index f55e6e347fb8232af5ec9d6ec1c9a8e1042edad6..978311873ac649486afdcedc72c71e83b8a34689 100644 (file)
@@ -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;
index 2f192915c2d166bd7ff5515fe1ed2d0424cd754e..61a0c75d10180769767b60585ab0228a07bf1418 100644 (file)
@@ -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;
index 974fb53de72177d1cca60be820440b2718e9ec04..41d5ae25374a6e4ebf157543b8a80823e6297b3c 100644 (file)
@@ -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 );