[LMCS] Actually allocate the source_lmcs and rec_lmcs

This commit is contained in:
Marko Viitanen 2021-05-25 14:27:21 +03:00
parent e5684b0be1
commit 3dae3f072e
3 changed files with 8 additions and 5 deletions

View file

@ -1371,6 +1371,10 @@ static void encoder_set_source_picture(encoder_state_t * const state, kvz_pictur
}
state->tile->frame->rec_lmcs = state->tile->frame->rec;
if (state->encoder_control->cfg.lmcs_enable) {
state->tile->frame->rec_lmcs = kvz_image_alloc(state->encoder_control->chroma_format, frame->width, frame->height);
state->tile->frame->source_lmcs = kvz_image_alloc(state->encoder_control->chroma_format, frame->width, frame->height);
}
kvz_videoframe_set_poc(state->tile->frame, state->frame->poc);
}
@ -1644,7 +1648,8 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
state->tile->frame->lmcs_aps->m_reshapeCW.rspPicSize = state->tile->frame->width * state->tile->frame->height;
state->tile->frame->lmcs_aps->m_reshapeCW.rspBaseQP = state->encoder_control->cfg.qp;
state->tile->frame->lmcs_aps->m_reshapeCW.rspFpsToIp = 16;
state->tile->frame->lmcs_aps->m_reshapeCW.updateCtrl = 1; //ToDo: change "LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP"
// ToDo: support other signal types in LMCS
kvz_lmcs_preanalyzer(state, state->tile->frame, state->tile->frame->lmcs_aps, RESHAPE_SIGNAL_SDR);
kvz_construct_reshaper_lmcs(state->tile->frame->lmcs_aps);

View file

@ -943,6 +943,7 @@ static void init_lcu_t(const encoder_state_t * const state, const int x, const i
int x_max_c = x_max / 2;
int y_max_c = y_max / 2;
// Use LMCS pixels for luma if they are available, otherwise source_lmcs is mapped to normal source
kvz_pixels_blit(&frame->source_lmcs->y[x + y * frame->source->stride], lcu->ref.y,
x_max, y_max, frame->source->stride, LCU_WIDTH);
if (state->encoder_control->chroma_format != KVZ_CSP_400) {

View file

@ -64,13 +64,10 @@ videoframe_t * kvz_videoframe_alloc(int32_t width,
*/
int kvz_videoframe_free(videoframe_t * const frame)
{
if (frame->lmcs_top_level) {
if (frame->source_lmcs_mapped) {
kvz_image_free(frame->source_lmcs);
kvz_image_free(frame->rec_lmcs);
frame->source_lmcs_mapped = false;
} else if(frame->source_lmcs_mapped){
FREE_POINTER(frame->source_lmcs);
FREE_POINTER(frame->rec_lmcs);
}
kvz_image_free(frame->source);