[LMCS] Enable LMCS per slice according to the pre-analyzer

This commit is contained in:
Marko Viitanen 2021-05-26 16:48:57 +03:00
parent be9776e40f
commit a5ff9284a8
2 changed files with 18 additions and 17 deletions

View file

@ -647,7 +647,7 @@ static void encoder_state_worker_encode_lcu(void * opaque)
}
if (state->encoder_control->cfg.lmcs_enable) {
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_pixel* luma = &state->tile->frame->rec->y[lcu->position_px.x + lcu->position_px.y * state->tile->frame->rec->stride];
for (int y = 0; y < LCU_WIDTH; y++) {
if (lcu->position_px.y + y < state->tile->frame->rec->height) {
@ -784,7 +784,7 @@ static void encoder_state_worker_encode_lcu_search(void * opaque)
set_cu_qps(state, lcu->position_px.x, lcu->position_px.y, 0, &last_qp, &prev_qp);
}
if (state->encoder_control->cfg.lmcs_enable) {
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_pixel* luma = &state->tile->frame->rec->y[lcu->position_px.x + lcu->position_px.y * state->tile->frame->rec->stride];
for (int y = 0; y < LCU_WIDTH; y++) {
if (lcu->position_px.y+y < state->tile->frame->rec->height) {
@ -1107,7 +1107,7 @@ static void encoder_state_encode(encoder_state_t * const main_state) {
);
if (sub_state->encoder_control->cfg.lmcs_enable) {
if (sub_state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_image_free(sub_state->tile->frame->source_lmcs);
sub_state->tile->frame->source_lmcs = NULL;
@ -1379,7 +1379,7 @@ 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) {
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
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);
}
@ -1660,6 +1660,7 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
// ToDo: support other signal types in LMCS
kvz_lmcs_preanalyzer(state, state->tile->frame, state->tile->frame->lmcs_aps, RESHAPE_SIGNAL_SDR);
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_construct_reshaper_lmcs(state->tile->frame->lmcs_aps);
kvz_pixel* luma = state->tile->frame->source->y;
@ -1673,7 +1674,7 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
}
state->tile->frame->source_lmcs_mapped = true;
state->tile->frame->lmcs_top_level = true;
}
}
encoder_state_init_children(state);
@ -1779,7 +1780,7 @@ void kvz_encoder_prepare(encoder_state_t *state)
state->tile->frame->cu_array = kvz_cu_array_alloc(width, height);
}
if (state->encoder_control->cfg.lmcs_enable) {
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_image_free(state->tile->frame->source_lmcs);
state->tile->frame->source_lmcs = NULL;

View file

@ -1293,7 +1293,7 @@ void kvz_encode_lmcs_adaptive_parameter_set(encoder_state_t* const state)
{
bitstream_t* const stream = &state->stream;
if (state->encoder_control->cfg.lmcs_enable) {
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.sliceReshaperEnableFlag) {
kvz_nal_write(stream, NAL_UNIT_PREFIX_APS, 0, state->frame->first_nal);
state->frame->first_nal = false;