From 30c4065dc0dcca03f7d63c516acaaf439923d2cc Mon Sep 17 00:00:00 2001 From: Arttu Makinen Date: Tue, 15 Dec 2020 13:04:39 +0200 Subject: [PATCH] Headers for threading. --- src/encoder_state-bitstream.c | 29 +++++++++++++++++++++++++---- src/encoderstate.c | 3 +-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index aec50450..e13f9610 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -529,8 +529,8 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, WRITE_UE(stream, encoder->bitdepth-8, "bit_depth_minus8"); - WRITE_U(stream, encoder->cfg.wpp, 1, "entropy_coding_sync_enabled_flag"); - WRITE_U(stream, encoder->tiles_enable, 1, "sps_entry_point_offsets_present_flag"); + WRITE_U(stream, encoder->cfg.wpp, 1, "sps_entropy_coding_sync_enabled_flag"); + WRITE_U(stream, encoder->tiles_enable || encoder->cfg.wpp, 1, "sps_entry_point_offsets_present_flag"); WRITE_U(stream, 1, 4, "log2_max_pic_order_cnt_lsb_minus4"); WRITE_U(stream, 0, 1, "sps_poc_msb_flag"); @@ -960,7 +960,7 @@ static void encoder_state_write_picture_timing_sei_message(encoder_state_t * con } } -/* + // ToDo: Enable tiles/wpp static void encoder_state_entry_points_explore(const encoder_state_t * const state, int * const r_count, int * const r_max_length) { int i; @@ -992,7 +992,6 @@ static void encoder_state_write_bitstream_entry_points_write(bitstream_t * const } } } -*/ static void kvz_encoder_state_write_bitstream_picture_header( struct bitstream_t * const stream, @@ -1201,6 +1200,28 @@ void kvz_encoder_state_write_bitstream_slice_header( } + if (encoder->tiles_enable || encoder->cfg.wpp) { + int num_entry_points = 0; + int max_length_seen = 0; + + if (state->is_leaf) { + num_entry_points = 1; + } + else { + encoder_state_entry_points_explore(state, &num_entry_points, &max_length_seen); + } + + int num_offsets = num_entry_points - 1; + + //WRITE_UE(stream, num_offsets, "num_entry_point_offsets"); + if (num_offsets > 0) { + int entry_points_written = 0; + int offset_len = kvz_math_floor_log2(max_length_seen) + 1; + WRITE_UE(stream, offset_len - 1, "offset_len_minus1"); + encoder_state_write_bitstream_entry_points_write(stream, state, num_entry_points, offset_len, &entry_points_written); + } + } + //WRITE_U(stream, 0, 1, "slice_ts_residual_coding_disabled_flag"); //kvz_bitstream_align(stream); diff --git a/src/encoderstate.c b/src/encoderstate.c index 4244c00d..66cf6ca9 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -692,7 +692,6 @@ static void encoder_state_worker_encode_lcu(void * opaque) const bool end_of_tile = lcu->last_column && lcu->last_row; const bool end_of_wpp_row = encoder->cfg.wpp && lcu->last_column; - if (end_of_tile || end_of_wpp_row) { // end_of_sub_stream_one_bit kvz_cabac_encode_bin_trm(&state->cabac, 1); @@ -1468,7 +1467,7 @@ void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame) { #if KVZ_DEBUG_PRINT_CABAC == 1 kvz_cabac_bins_count = 0; - if (state->frame->num == 1) kvz_cabac_bins_verbose = true; + if (state->frame->num == 0) kvz_cabac_bins_verbose = true; else kvz_cabac_bins_verbose = false; #endif encoder_state_init_new_frame(state, frame);