Simplify code in encoder_state-bitstream.

This commit is contained in:
Arttu Ylä-Outinen 2015-10-14 12:32:38 +03:00
parent 4f412422b7
commit db17d33b0b

View file

@ -260,8 +260,8 @@ static void encoder_state_write_bitstream_VUI(encoder_state_t * const state)
//ENDIF
WRITE_U(stream, 0, 1, "neutral_chroma_indication_flag");
WRITE_U(stream, state->encoder_control->vui.field_seq_flag, 1, "field_seq_flag"); // 0: frames, 1: fields
WRITE_U(stream, state->encoder_control->vui.frame_field_info_present_flag, 1, "frame_field_info_present_flag");
WRITE_U(stream, encoder->vui.field_seq_flag, 1, "field_seq_flag"); // 0: frames, 1: fields
WRITE_U(stream, encoder->vui.frame_field_info_present_flag, 1, "frame_field_info_present_flag");
WRITE_U(stream, 0, 1, "default_display_window_flag");
//IF default display window
@ -295,10 +295,10 @@ static void encoder_state_write_bitstream_seq_parameter_set(encoder_state_t * co
encoder_state_write_bitstream_PTL(state);
WRITE_UE(stream, 0, "sps_seq_parameter_set_id");
WRITE_UE(stream, state->encoder_control->in.video_format,
WRITE_UE(stream, encoder->in.video_format,
"chroma_format_idc");
if (state->encoder_control->in.video_format == 3) {
if (encoder->in.video_format == 3) {
WRITE_U(stream, 0, 1, "separate_colour_plane_flag");
}
@ -331,7 +331,7 @@ static void encoder_state_write_bitstream_seq_parameter_set(encoder_state_t * co
WRITE_U(stream, 0, 1, "sps_sub_layer_ordering_info_present_flag");
//for each layer
WRITE_UE(stream, state->encoder_control->cfg->ref_frames + encoder->cfg->gop_len, "sps_max_dec_pic_buffering");
WRITE_UE(stream, encoder->cfg->ref_frames + encoder->cfg->gop_len, "sps_max_dec_pic_buffering");
WRITE_UE(stream, encoder->cfg->gop_len, "sps_num_reorder_pics");
WRITE_UE(stream, 0, "sps_max_latency_increase");
//end for
@ -344,14 +344,14 @@ static void encoder_state_write_bitstream_seq_parameter_set(encoder_state_t * co
WRITE_UE(stream, encoder->tr_depth_intra, "max_transform_hierarchy_depth_intra");
// scaling list
WRITE_U(stream, state->encoder_control->scaling_list.enable, 1, "scaling_list_enable_flag");
if (state->encoder_control->scaling_list.enable) {
WRITE_U(stream, encoder->scaling_list.enable, 1, "scaling_list_enable_flag");
if (encoder->scaling_list.enable) {
WRITE_U(stream, 1, 1, "sps_scaling_list_data_present_flag");
encoder_state_write_bitstream_scaling_list(state);
}
WRITE_U(stream, 0, 1, "amp_enabled_flag");
WRITE_U(stream, state->encoder_control->sao_enable ? 1 : 0, 1,
WRITE_U(stream, encoder->sao_enable ? 1 : 0, 1,
"sample_adaptive_offset_enabled_flag");
WRITE_U(stream, ENABLE_PCM, 1, "pcm_enabled_flag");
#if ENABLE_PCM == 1
@ -403,7 +403,7 @@ static void encoder_state_write_bitstream_pic_parameter_set(encoder_state_t * co
WRITE_UE(stream, 0, "num_ref_idx_l1_default_active_minus1");
WRITE_SE(stream, ((int8_t)encoder->cfg->qp) - 26, "pic_init_qp_minus26");
WRITE_U(stream, 0, 1, "constrained_intra_pred_flag");
WRITE_U(stream, state->encoder_control->trskip_enable, 1, "transform_skip_enabled_flag");
WRITE_U(stream, encoder->trskip_enable, 1, "transform_skip_enabled_flag");
WRITE_U(stream, 0, 1, "cu_qp_delta_enabled_flag");
//if cu_qp_delta_enabled_flag
//WRITE_UE(stream, 0, "diff_cu_qp_delta_depth");
@ -445,13 +445,13 @@ static void encoder_state_write_bitstream_pic_parameter_set(encoder_state_t * co
//IF deblocking_filter
WRITE_U(stream, 0, 1, "deblocking_filter_override_enabled_flag");
WRITE_U(stream, state->encoder_control->deblock_enable ? 0 : 1, 1,
WRITE_U(stream, encoder->deblock_enable ? 0 : 1, 1,
"pps_disable_deblocking_filter_flag");
//IF !disabled
if (state->encoder_control->deblock_enable) {
WRITE_SE(stream, state->encoder_control->beta_offset_div2, "beta_offset_div2");
WRITE_SE(stream, state->encoder_control->tc_offset_div2, "tc_offset_div2");
if (encoder->deblock_enable) {
WRITE_SE(stream, encoder->beta_offset_div2, "beta_offset_div2");
WRITE_SE(stream, encoder->tc_offset_div2, "tc_offset_div2");
}
//ENDIF
@ -639,7 +639,7 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
int j;
int ref_negative = 0;
int ref_positive = 0;
if (state->encoder_control->cfg->gop_len) {
if (encoder->cfg->gop_len) {
for (j = 0; j < state->global->ref->used_size; j++) {
if (state->global->ref->pocs[j] < state->global->poc) {
ref_negative++;
@ -686,10 +686,10 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
for (j = 0; j < ref_negative; j++) {
int8_t delta_poc = 0;
if (state->encoder_control->cfg->gop_len) {
if (encoder->cfg->gop_len) {
int8_t found = 0;
do {
delta_poc = state->encoder_control->cfg->gop[state->global->gop_offset].ref_neg[j + poc_shift];
delta_poc = encoder->cfg->gop[state->global->gop_offset].ref_neg[j + poc_shift];
for (int i = 0; i < state->global->ref->used_size; i++) {
if (state->global->ref->pocs[i] == state->global->poc - delta_poc) {
found = 1;
@ -704,7 +704,7 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
} while (!found);
}
WRITE_UE(stream, state->encoder_control->cfg->gop_len?delta_poc - last_poc - 1:0, "delta_poc_s0_minus1");
WRITE_UE(stream, encoder->cfg->gop_len?delta_poc - last_poc - 1:0, "delta_poc_s0_minus1");
last_poc = delta_poc;
WRITE_U(stream,1,1, "used_by_curr_pic_s0_flag");
}
@ -713,10 +713,10 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
for (j = 0; j < ref_positive; j++) {
int8_t delta_poc = 0;
if (state->encoder_control->cfg->gop_len) {
if (encoder->cfg->gop_len) {
int8_t found = 0;
do {
delta_poc = state->encoder_control->cfg->gop[state->global->gop_offset].ref_pos[j + poc_shift];
delta_poc = encoder->cfg->gop[state->global->gop_offset].ref_pos[j + poc_shift];
for (int i = 0; i < state->global->ref->used_size; i++) {
if (state->global->ref->pocs[i] == state->global->poc + delta_poc) {
found = 1;
@ -731,7 +731,7 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
} while (!found);
}
WRITE_UE(stream, state->encoder_control->cfg->gop_len ? delta_poc - last_poc - 1 : 0, "delta_poc_s1_minus1");
WRITE_UE(stream, encoder->cfg->gop_len ? delta_poc - last_poc - 1 : 0, "delta_poc_s1_minus1");
last_poc = delta_poc;
WRITE_U(stream, 1, 1, "used_by_curr_pic_s1_flag");
}
@ -756,7 +756,7 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
}
{
int slice_qp_delta = state->global->QP - state->encoder_control->cfg->qp;
int slice_qp_delta = state->global->QP - encoder->cfg->qp;
WRITE_SE(stream, slice_qp_delta, "slice_qp_delta");
}
@ -858,7 +858,7 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state)
}
// Send Kvazaar version information only in the first frame.
if (state->global->frame == 0 && state->encoder_control->cfg->add_encoder_info) {
if (state->global->frame == 0 && encoder->cfg->add_encoder_info) {
kvz_nal_write(stream, KVZ_NAL_PREFIX_SEI_NUT, 0, first_nal_in_au);
encoder_state_write_bitstream_prefix_sei_version(state);
@ -867,7 +867,7 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state)
}
//SEI messages for interlacing
if (state->encoder_control->vui.frame_field_info_present_flag){
if (encoder->vui.frame_field_info_present_flag){
// These should be optional, needed for earlier versions
// of HM decoder to accept bitstream
//kvz_nal_write(stream, KVZ_NAL_PREFIX_SEI_NUT, 0, 0);
@ -889,14 +889,14 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state)
{
PERFORMANCE_MEASURE_START(KVZ_PERF_FRAME);
encoder_state_write_bitstream_children(state);
PERFORMANCE_MEASURE_END(KVZ_PERF_FRAME, state->encoder_control->threadqueue, "type=write_bitstream_append,frame=%d,encoder_type=%c", state->global->frame, state->type);
PERFORMANCE_MEASURE_END(KVZ_PERF_FRAME, encoder->threadqueue, "type=write_bitstream_append,frame=%d,encoder_type=%c", state->global->frame, state->type);
}
{
PERFORMANCE_MEASURE_START(KVZ_PERF_FRAME);
// Calculate checksum
add_checksum(state);
PERFORMANCE_MEASURE_END(KVZ_PERF_FRAME, state->encoder_control->threadqueue, "type=write_bitstream_checksum,frame=%d,encoder_type=%c", state->global->frame, state->type);
PERFORMANCE_MEASURE_END(KVZ_PERF_FRAME, encoder->threadqueue, "type=write_bitstream_checksum,frame=%d,encoder_type=%c", state->global->frame, state->type);
}
//Get bitstream length for stats