diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index b4645f92..20ff50b5 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -1120,6 +1120,9 @@ static void kvz_encoder_state_write_bitstream_picture_header( 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 } @@ -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"); 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]"); @@ -1239,7 +1242,7 @@ void kvz_encoder_state_write_bitstream_slice_header( const encoder_control_t * const encoder = state->encoder_control; #ifdef KVZ_DEBUG - printf("=========== Slice ===========\n"); + printf("=========== Slice =========== %d\n", state->frame->poc); #endif /* 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"); - kvz_encoder_state_write_bitstream_picture_header(stream, state); - - if (encoder->cfg.jccr) { - WRITE_U(stream, 0, 1, "ph_joint_cbcr_sign_flag"); - } + kvz_encoder_state_write_bitstream_picture_header(stream, state); if (state->frame->pictype != KVZ_NAL_IDR_W_RADL && state->frame->pictype != KVZ_NAL_IDR_N_LP) { 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) @@ -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) { int ref_negative = 0; int ref_positive = 0; diff --git a/src/nal.c b/src/nal.c index b494d633..591be07e 100644 --- a/src/nal.c +++ b/src/nal.c @@ -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", "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", "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); #endif }