From 2a2db86dc2bad14e13b7568ee212435cd4e5f059 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Fri, 5 Mar 2010 20:43:02 +0000 Subject: [PATCH] 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. --- 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 f55e6e34..97831187 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 2f192915..61a0c75d 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 974fb53d..41d5ae25 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 ); -- 2.40.0