mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-28 03:34:06 +00:00
[LMCS] Initialize some m_reshapeCW values to avoid division by zero
This commit is contained in:
parent
1def1b3c52
commit
dbc7fd48bf
|
@ -1639,6 +1639,11 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
|
||||||
state->tile->frame->lmcs_aps = calloc(1, sizeof(lmcs_aps));
|
state->tile->frame->lmcs_aps = calloc(1, sizeof(lmcs_aps));
|
||||||
kvz_init_lmcs_aps(state->tile->frame->lmcs_aps, state->encoder_control->cfg.width, state->encoder_control->cfg.height, LCU_CU_WIDTH, LCU_CU_WIDTH, state->encoder_control->bitdepth);
|
kvz_init_lmcs_aps(state->tile->frame->lmcs_aps, state->encoder_control->cfg.width, state->encoder_control->cfg.height, LCU_CU_WIDTH, LCU_CU_WIDTH, state->encoder_control->bitdepth);
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
// ToDo: support other signal types in LMCS
|
// ToDo: support other signal types in LMCS
|
||||||
kvz_lmcs_preanalyzer(state, state->tile->frame, state->tile->frame->lmcs_aps, RESHAPE_SIGNAL_SDR);
|
kvz_lmcs_preanalyzer(state, state->tile->frame, state->tile->frame->lmcs_aps, RESHAPE_SIGNAL_SDR);
|
||||||
kvz_construct_reshaper_lmcs(state->tile->frame->lmcs_aps);
|
kvz_construct_reshaper_lmcs(state->tile->frame->lmcs_aps);
|
||||||
|
@ -1647,7 +1652,7 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
|
||||||
kvz_pixel* luma_lmcs = state->tile->frame->source_lmcs->y;
|
kvz_pixel* luma_lmcs = state->tile->frame->source_lmcs->y;
|
||||||
for (int y = 0; y < state->tile->frame->source->height; y++) {
|
for (int y = 0; y < state->tile->frame->source->height; y++) {
|
||||||
for (int x = 0; x < state->tile->frame->source->width; x++) {
|
for (int x = 0; x < state->tile->frame->source->width; x++) {
|
||||||
//luma[x] = state->tile->frame->lmcs_aps->m_fwdLUT[luma[x]];
|
luma_lmcs[x] = state->tile->frame->lmcs_aps->m_fwdLUT[luma[x]];
|
||||||
}
|
}
|
||||||
luma += state->tile->frame->source->stride;
|
luma += state->tile->frame->source->stride;
|
||||||
luma_lmcs += state->tile->frame->source->stride;
|
luma_lmcs += state->tile->frame->source->stride;
|
||||||
|
|
|
@ -110,7 +110,7 @@ void kvz_calc_seq_stats(struct encoder_state_t* const state, const videoframe_t*
|
||||||
const encoder_control_t* const encoder = state->encoder_control;
|
const encoder_control_t* const encoder = state->encoder_control;
|
||||||
|
|
||||||
int32_t m_binNum = PIC_CODE_CW_BINS;
|
int32_t m_binNum = PIC_CODE_CW_BINS;
|
||||||
kvz_pixel* picY = &frame->source->y[CU_TO_PIXEL(0, 0, 0, frame->source->stride)];
|
kvz_pixel* picY = &frame->source->y[0];
|
||||||
const int width = frame->source->width;
|
const int width = frame->source->width;
|
||||||
const int height = frame->source->height;
|
const int height = frame->source->height;
|
||||||
const int stride = frame->source->stride;
|
const int stride = frame->source->stride;
|
||||||
|
@ -831,7 +831,7 @@ void kvz_lmcs_preanalyzer(struct encoder_state_t* const state, const videoframe_
|
||||||
aps->m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true;
|
aps->m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true;
|
||||||
aps->m_sliceReshapeInfo.sliceReshaperEnableFlag = true;
|
aps->m_sliceReshapeInfo.sliceReshaperEnableFlag = true;
|
||||||
|
|
||||||
int modIP = 0;// state->frame->poc - state->frame->poc / aps->m_reshapeCW.rspFpsToIp * aps->m_reshapeCW.rspFpsToIp;
|
int modIP = state->frame->poc - state->frame->poc / aps->m_reshapeCW.rspFpsToIp * aps->m_reshapeCW.rspFpsToIp;
|
||||||
if (sliceType == KVZ_SLICE_I || (aps->m_reshapeCW.updateCtrl == 2 && modIP == 0))
|
if (sliceType == KVZ_SLICE_I || (aps->m_reshapeCW.updateCtrl == 2 && modIP == 0))
|
||||||
{
|
{
|
||||||
if (aps->m_sliceReshapeInfo.sliceReshaperModelPresentFlag == true)
|
if (aps->m_sliceReshapeInfo.sliceReshaperModelPresentFlag == true)
|
||||||
|
|
|
@ -943,7 +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 x_max_c = x_max / 2;
|
||||||
int y_max_c = y_max / 2;
|
int y_max_c = y_max / 2;
|
||||||
|
|
||||||
kvz_pixels_blit(&frame->source->y[x + y * frame->source->stride], lcu->ref.y,
|
kvz_pixels_blit(&frame->source_lmcs->y[x + y * frame->source->stride], lcu->ref.y,
|
||||||
x_max, y_max, frame->source->stride, LCU_WIDTH);
|
x_max, y_max, frame->source->stride, LCU_WIDTH);
|
||||||
if (state->encoder_control->chroma_format != KVZ_CSP_400) {
|
if (state->encoder_control->chroma_format != KVZ_CSP_400) {
|
||||||
kvz_pixels_blit(&frame->source->u[x_c + y_c * frame->source->stride / 2], lcu->ref.u,
|
kvz_pixels_blit(&frame->source->u[x_c + y_c * frame->source->stride / 2], lcu->ref.u,
|
||||||
|
|
|
@ -665,18 +665,8 @@ int kvz_quantize_residual_avx2(encoder_state_t *const state,
|
||||||
assert(width <= TR_MAX_WIDTH);
|
assert(width <= TR_MAX_WIDTH);
|
||||||
assert(width >= TR_MIN_WIDTH);
|
assert(width >= TR_MIN_WIDTH);
|
||||||
|
|
||||||
int y, x;
|
// Get residual. (ref_in - pred_in -> residual)
|
||||||
// ToDo: do something with the LMCS for better performance
|
get_residual_avx2(ref_in, pred_in, residual, width, in_stride);
|
||||||
if (state->encoder_control->cfg.lmcs_enable && color == COLOR_Y) {
|
|
||||||
for (y = 0; y < width; ++y) {
|
|
||||||
for (x = 0; x < width; ++x) {
|
|
||||||
residual[x + y * width] = (int16_t)(state->tile->frame->lmcs_aps->m_fwdLUT[ref_in[x + y * in_stride]] - pred_in[x + y * in_stride]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Get residual. (ref_in - pred_in -> residual)
|
|
||||||
get_residual_avx2(ref_in, pred_in, residual, width, in_stride);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transform residual. (residual -> coeff)
|
// Transform residual. (residual -> coeff)
|
||||||
if (use_trskip) {
|
if (use_trskip) {
|
||||||
|
|
|
@ -207,18 +207,9 @@ int kvz_quantize_residual_generic(encoder_state_t *const state,
|
||||||
// Get residual. (ref_in - pred_in -> residual)
|
// Get residual. (ref_in - pred_in -> residual)
|
||||||
{
|
{
|
||||||
int y, x;
|
int y, x;
|
||||||
if (state->encoder_control->cfg.lmcs_enable && color == COLOR_Y) {
|
for (y = 0; y < width; ++y) {
|
||||||
for (y = 0; y < width; ++y) {
|
for (x = 0; x < width; ++x) {
|
||||||
for (x = 0; x < width; ++x) {
|
residual[x + y * width] = (int16_t)(ref_in[x + y * in_stride] - pred_in[x + y * in_stride]);
|
||||||
residual[x + y * width] = (int16_t)(state->tile->frame->lmcs_aps->m_fwdLUT[ref_in[x + y * in_stride]] - pred_in[x + y * in_stride]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (y = 0; y < width; ++y) {
|
|
||||||
for (x = 0; x < width; ++x) {
|
|
||||||
residual[x + y * width] = (int16_t)(ref_in[x + y * in_stride] - pred_in[x + y * in_stride]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue