Fix picture headers for open-gop

This commit is contained in:
Joose Sainio 2022-03-14 10:32:46 +02:00
parent 25a8a40de0
commit eff8d7cdac
2 changed files with 12 additions and 9 deletions

View file

@ -1120,6 +1120,9 @@ static void kvz_encoder_state_write_bitstream_picture_header(
WRITE_U(stream, 0, 1, "ph_mvd_l1_zero_flag"); WRITE_U(stream, 0, 1, "ph_mvd_l1_zero_flag");
} }
if (encoder->cfg.jccr) {
WRITE_U(stream, 0, 1, "ph_joint_cbcr_sign_flag");
}
// END PICTURE HEADER // END PICTURE HEADER
} }
@ -1223,7 +1226,7 @@ static void kvz_encoder_state_write_bitstream_ref_pic_list(
} }
} }
if (ref_negative > 1 || ref_positive > 1) { if ( (state->frame->slicetype != KVZ_SLICE_I && ref_negative > 1 )|| ref_positive > 1) {
WRITE_U(stream, 1, 1, "sh_num_ref_idx_active_override_flag"); WRITE_U(stream, 1, 1, "sh_num_ref_idx_active_override_flag");
if (ref_negative > 1) for(int list = 0; list < 1 + copy_rpl1_from_rpl0; list++) WRITE_UE(stream, ref_negative - 1, "sh_num_ref_idx_active_minus1[0]"); if (ref_negative > 1) for(int list = 0; list < 1 + copy_rpl1_from_rpl0; list++) WRITE_UE(stream, ref_negative - 1, "sh_num_ref_idx_active_minus1[0]");
if (!copy_rpl1_from_rpl0 && ref_positive > 1) WRITE_UE(stream, ref_positive - 1, "sh_num_ref_idx_active_minus1[1]"); if (!copy_rpl1_from_rpl0 && ref_positive > 1) WRITE_UE(stream, ref_positive - 1, "sh_num_ref_idx_active_minus1[1]");
@ -1239,7 +1242,7 @@ void kvz_encoder_state_write_bitstream_slice_header(
const encoder_control_t * const encoder = state->encoder_control; const encoder_control_t * const encoder = state->encoder_control;
#ifdef KVZ_DEBUG #ifdef KVZ_DEBUG
printf("=========== Slice ===========\n"); printf("=========== Slice =========== %d\n", state->frame->poc);
#endif #endif
/* /*
bool first_slice_segment_in_pic = (state->slice->start_in_rs == 0); bool first_slice_segment_in_pic = (state->slice->start_in_rs == 0);
@ -1254,16 +1257,11 @@ void kvz_encoder_state_write_bitstream_slice_header(
WRITE_U(stream, 1, 1, "picture_header_in_slice_header_flag"); WRITE_U(stream, 1, 1, "picture_header_in_slice_header_flag");
kvz_encoder_state_write_bitstream_picture_header(stream, state); kvz_encoder_state_write_bitstream_picture_header(stream, state);
if (encoder->cfg.jccr) {
WRITE_U(stream, 0, 1, "ph_joint_cbcr_sign_flag");
}
if (state->frame->pictype != KVZ_NAL_IDR_W_RADL if (state->frame->pictype != KVZ_NAL_IDR_W_RADL
&& state->frame->pictype != KVZ_NAL_IDR_N_LP) { && state->frame->pictype != KVZ_NAL_IDR_N_LP) {
WRITE_UE(stream, state->frame->slicetype, "sh_slice_type"); WRITE_UE(stream, state->frame->slicetype, "sh_slice_type");
kvz_encoder_state_write_bitstream_ref_pic_list(stream, state);
} }
if (state->frame->pictype == KVZ_NAL_CRA_NUT || state->frame->pictype == KVZ_NAL_IDR_N_LP || state->frame->pictype == KVZ_NAL_IDR_W_RADL || state->frame->pictype == KVZ_NAL_GDR_NUT) if (state->frame->pictype == KVZ_NAL_CRA_NUT || state->frame->pictype == KVZ_NAL_IDR_N_LP || state->frame->pictype == KVZ_NAL_IDR_W_RADL || state->frame->pictype == KVZ_NAL_GDR_NUT)
@ -1315,6 +1313,11 @@ void kvz_encoder_state_write_bitstream_slice_header(
} }
} }
if (state->frame->pictype != KVZ_NAL_IDR_W_RADL
&& state->frame->pictype != KVZ_NAL_IDR_N_LP) {
kvz_encoder_state_write_bitstream_ref_pic_list(stream, state);
}
if (state->frame->slicetype != KVZ_SLICE_I && state->encoder_control->cfg.tmvp_enable) { if (state->frame->slicetype != KVZ_SLICE_I && state->encoder_control->cfg.tmvp_enable) {
int ref_negative = 0; int ref_negative = 0;
int ref_positive = 0; int ref_positive = 0;

View file

@ -77,7 +77,7 @@ void kvz_nal_write(bitstream_t * const bitstream, const uint8_t nal_type,
printf("%-50s u(%d) : %d\n", "zero_tid_required_flag", 1, 0); printf("%-50s u(%d) : %d\n", "zero_tid_required_flag", 1, 0);
printf("%-50s u(%d) : %d\n", "nuh_temporal_id_plus1", 3, temporal_id + 1); printf("%-50s u(%d) : %d\n", "nuh_temporal_id_plus1", 3, temporal_id + 1);
printf("%-50s u(%d) : %d\n", "nal_unit_type_lsb", 4, nal_type); printf("%-50s u(%d) : %d\n", "nal_unit_type_lsb", 4, nal_type);
printf("%-50s u(%d) : %d\n", "nuh_layer_id_plus1", 7, 0); printf("%-50s u(%d) : %d\n", "nuh_layer_id_plus1", 7, 1);
printf("%-50s u(%d) : %d\n", "nuh_reserved_zero_bit", 1, 0); printf("%-50s u(%d) : %d\n", "nuh_reserved_zero_bit", 1, 0);
#endif #endif
} }