Commit 2a2db86d authored by Kieran Kunhya's avatar Kieran Kunhya Committed by Fiona 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.
parent 415aac4f
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment