From a39bc6948296d03fe9f7ca6a978be583bdfb7829 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Mon, 4 Jan 2021 19:04:50 +0200 Subject: [PATCH] Move HMVP arrays to more suitable place --- src/encoder_state-bitstream.c | 4 ++-- src/encoder_state-ctors_dtors.c | 7 +++++++ src/encoderstate.c | 1 + src/encoderstate.h | 5 +++++ src/global.h | 2 ++ src/videoframe.c | 7 ------- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index c2e5f57e..23dfc561 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -674,14 +674,14 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, WRITE_U(stream, 0, 1, "sps_mmvd_enabled_flag"); - WRITE_UE(stream, MRG_MAX_NUM_CANDS - 6, "six_minus_max_num_merge_cand"); + WRITE_UE(stream, 6 - MRG_MAX_NUM_CANDS, "six_minus_max_num_merge_cand"); WRITE_U(stream, 0, 1, "sps_sbt_enabled_flag"); WRITE_U(stream, 0, 1, "sps_affine_enabled_flag"); WRITE_U(stream, 0, 1, "sps_bcw_enabled_flag"); WRITE_U(stream, 0, 1, "sps_ciip_enabled_flag"); - if (6 /*MAX_NUM_MERGE_CAND*/ >= 2) + if (MRG_MAX_NUM_CANDS >= 2) { WRITE_U(stream, 0, 1, "sps_gpm_enabled_flag"); } diff --git a/src/encoder_state-ctors_dtors.c b/src/encoder_state-ctors_dtors.c index 71246058..577e4d62 100644 --- a/src/encoder_state-ctors_dtors.c +++ b/src/encoder_state-ctors_dtors.c @@ -83,6 +83,10 @@ static int encoder_state_config_frame_init(encoder_state_t * const state) { state->frame->new_ratecontrol = kvz_get_rc_data(NULL); + + state->frame->hmvp_lut = malloc(sizeof(cu_info_t) * encoder->in.height_in_lcu * MAX_NUM_HMVP_CANDS); + state->frame->hmvp_size = malloc(sizeof(uint8_t) * encoder->in.height_in_lcu); + return 1; } @@ -96,6 +100,9 @@ static void encoder_state_config_frame_finalize(encoder_state_t * const state) { kvz_image_list_destroy(state->frame->ref); FREE_POINTER(state->frame->lcu_stats); FREE_POINTER(state->frame->aq_offsets); + + FREE_POINTER(state->frame->hmvp_lut); + FREE_POINTER(state->frame->hmvp_size); } static int encoder_state_config_tile_init(encoder_state_t * const state, diff --git a/src/encoderstate.c b/src/encoderstate.c index 3e7e808b..92c2a25e 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -1402,6 +1402,7 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict state->tile->frame->width, state->tile->frame->height ); + memset(state->frame->hmvp_size, 0, sizeof(uint8_t) * state->encoder_control->in.height_in_lcu); // Variance adaptive quantization if (cfg->vaq) { diff --git a/src/encoderstate.h b/src/encoderstate.h index ffb6dd41..19e3759e 100644 --- a/src/encoderstate.h +++ b/src/encoderstate.h @@ -177,6 +177,11 @@ typedef struct encoder_state_config_frame_t { double *c_para; double *k_para; + + + cu_info_t* hmvp_lut; //!< \brief Look-up table for HMVP, one for each LCU row + uint8_t* hmvp_size; //!< \brief HMVP LUT size + } encoder_state_config_frame_t; typedef struct encoder_state_config_tile_t { diff --git a/src/global.h b/src/global.h index b3d24048..96aead32 100644 --- a/src/global.h +++ b/src/global.h @@ -224,6 +224,8 @@ typedef int16_t coeff_t; #define AMVP_MAX_NUM_CANDS_MEM 3 #define MRG_MAX_NUM_CANDS 6 +#define MAX_NUM_HMVP_CANDS 5 + /* Some tools */ #define ABS(a) ((a) >= 0 ? (a) : (-a)) #define MAX(a,b) (((a)>(b))?(a):(b)) diff --git a/src/videoframe.c b/src/videoframe.c index 8df44bc3..81022319 100644 --- a/src/videoframe.c +++ b/src/videoframe.c @@ -49,10 +49,6 @@ videoframe_t * kvz_videoframe_alloc(int32_t width, frame->sao_chroma = MALLOC(sao_info_t, frame->width_in_lcu * frame->height_in_lcu); } - frame->hmvp_lut = calloc(1, sizeof(cu_info_t) * frame->height_in_lcu * MAX_NUM_HMVP_CANDS); - frame->hmvp_size = calloc(1, sizeof(uint8_t) * frame->height_in_lcu); - - return frame; } @@ -82,9 +78,6 @@ int kvz_videoframe_free(videoframe_t * const frame) FREE_POINTER(frame->sao_luma); FREE_POINTER(frame->sao_chroma); - FREE_POINTER(frame->hmvp_lut); - FREE_POINTER(frame->hmvp_size); - free(frame); return 1;