mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-12-18 03:04:06 +00:00
[isp] Modify inverse transform to handle non-square blocks.
This commit is contained in:
parent
626c9b02ea
commit
6a3ddfd0bc
|
@ -716,7 +716,7 @@ int uvg_quantize_residual_avx2(encoder_state_t *const state,
|
||||||
uvg_itransformskip(state->encoder_control, residual, coeff, width);
|
uvg_itransformskip(state->encoder_control, residual, coeff, width);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uvg_itransform2d(state->encoder_control, residual, coeff, width, color, cur_cu);
|
uvg_itransform2d(state->encoder_control, residual, coeff, width, height, color, cur_cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
||||||
|
|
|
@ -2499,8 +2499,8 @@ static void mts_dct_generic(
|
||||||
{
|
{
|
||||||
tr_type_t type_hor;
|
tr_type_t type_hor;
|
||||||
tr_type_t type_ver;
|
tr_type_t type_ver;
|
||||||
// ISP_TODO: height passed but not used
|
|
||||||
|
|
||||||
|
// ISP_TODO: height
|
||||||
uvg_get_tr_type(width, color, tu, &type_hor, &type_ver, mts_idx);
|
uvg_get_tr_type(width, color, tu, &type_hor, &type_ver, mts_idx);
|
||||||
|
|
||||||
if (type_hor == DCT2 && type_ver == DCT2 && !tu->lfnst_idx && !tu->cr_lfnst_idx || width != height)
|
if (type_hor == DCT2 && type_ver == DCT2 && !tu->lfnst_idx && !tu->cr_lfnst_idx || width != height)
|
||||||
|
@ -2514,6 +2514,7 @@ static void mts_dct_generic(
|
||||||
int skip_height = (type_ver != DCT2 && height == 32) ? 16 : (height > 32 ? height - 32 : 0);
|
int skip_height = (type_ver != DCT2 && height == 32) ? 16 : (height > 32 ? height - 32 : 0);
|
||||||
const int log2_width_minus2 = uvg_g_convert_to_bit[width];
|
const int log2_width_minus2 = uvg_g_convert_to_bit[width];
|
||||||
const int log2_height_minus2 = uvg_g_convert_to_bit[height];
|
const int log2_height_minus2 = uvg_g_convert_to_bit[height];
|
||||||
|
|
||||||
if(tu->lfnst_idx || tu->cr_lfnst_idx) {
|
if(tu->lfnst_idx || tu->cr_lfnst_idx) {
|
||||||
if ((width == 4 && height > 4) || (width > 4 && height == 4))
|
if ((width == 4 && height > 4) || (width > 4 && height == 4))
|
||||||
{
|
{
|
||||||
|
@ -2545,6 +2546,7 @@ static void mts_idct_generic(
|
||||||
const color_t color,
|
const color_t color,
|
||||||
const cu_info_t* tu,
|
const cu_info_t* tu,
|
||||||
const int8_t width,
|
const int8_t width,
|
||||||
|
const int8_t height,
|
||||||
const int16_t* input,
|
const int16_t* input,
|
||||||
int16_t* output,
|
int16_t* output,
|
||||||
const int8_t mts_idx)
|
const int8_t mts_idx)
|
||||||
|
@ -2552,26 +2554,38 @@ static void mts_idct_generic(
|
||||||
tr_type_t type_hor;
|
tr_type_t type_hor;
|
||||||
tr_type_t type_ver;
|
tr_type_t type_ver;
|
||||||
|
|
||||||
|
// ISP_TODO: height
|
||||||
uvg_get_tr_type(width, color, tu, &type_hor, &type_ver, mts_idx);
|
uvg_get_tr_type(width, color, tu, &type_hor, &type_ver, mts_idx);
|
||||||
|
|
||||||
if (type_hor == DCT2 && type_ver == DCT2)
|
if (type_hor == DCT2 && type_ver == DCT2 && !tu->lfnst_idx && !tu->cr_lfnst_idx || width != height)
|
||||||
{
|
{
|
||||||
dct_func *idct_func = uvg_get_idct_func(width, color, tu->type);
|
dct_func *idct_func = uvg_get_idct_func(width, color, tu->type);
|
||||||
idct_func(bitdepth, input, output);
|
idct_func(bitdepth, input, output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int height = width;
|
int skip_width = (type_hor != DCT2 && width == 32) ? 16 : width > 32 ? width - 32 : 0;
|
||||||
const int skip_width = (type_hor != DCT2 && width == 32) ? 16 : width > 32 ? width - 32 : 0;
|
int skip_height = (type_ver != DCT2 && height == 32) ? 16 : height > 32 ? height - 32 : 0;
|
||||||
const int skip_height = (type_ver != DCT2 && height == 32) ? 16 : height > 32 ? height - 32 : 0;
|
|
||||||
const int log2_width_minus2 = uvg_g_convert_to_bit[width];
|
const int log2_width_minus2 = uvg_g_convert_to_bit[width];
|
||||||
|
const int log2_height_minus2 = uvg_g_convert_to_bit[height];
|
||||||
|
|
||||||
|
if (tu->lfnst_idx || tu->cr_lfnst_idx) {
|
||||||
|
if ((width == 4 && height > 4) || (width > 4 && height == 4)) {
|
||||||
|
skip_width == width - 4;
|
||||||
|
skip_height == height - 4;
|
||||||
|
}
|
||||||
|
else if ((width >= 8 && height >= 8)) {
|
||||||
|
skip_width = width - 8;
|
||||||
|
skip_height = height - 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
partial_tr_func* idct_hor = idct_table[type_hor][log2_width_minus2];
|
partial_tr_func* idct_hor = idct_table[type_hor][log2_width_minus2];
|
||||||
partial_tr_func* idct_ver = idct_table[type_ver][log2_width_minus2];
|
partial_tr_func* idct_ver = idct_table[type_ver][log2_width_minus2];
|
||||||
|
|
||||||
int16_t tmp[32 * 32];
|
int16_t tmp[32 * 32];
|
||||||
const int32_t shift_1st = 7;
|
const int32_t shift_1st = log2_width_minus2 - 7;
|
||||||
const int32_t shift_2nd = 20 - bitdepth;
|
const int32_t shift_2nd = log2_height_minus2 + 8;
|
||||||
|
|
||||||
idct_ver(input, tmp, shift_1st, width, skip_width, skip_height);
|
idct_ver(input, tmp, shift_1st, width, skip_width, skip_height);
|
||||||
idct_hor(tmp, output, shift_2nd, height, 0, skip_width);
|
idct_hor(tmp, output, shift_2nd, height, 0, skip_width);
|
||||||
|
|
|
@ -349,7 +349,7 @@ int uvg_quant_cbcr_residual_generic(
|
||||||
uvg_inv_lfnst(cur_cu, width, width, COLOR_UV, cur_cu->cr_lfnst_idx, coeff, tree_type);
|
uvg_inv_lfnst(cur_cu, width, width, COLOR_UV, cur_cu->cr_lfnst_idx, coeff, tree_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
uvg_itransform2d(state->encoder_control, combined_residual, coeff, width, cur_cu->joint_cb_cr == 1 ? COLOR_V : COLOR_U, cur_cu);
|
uvg_itransform2d(state->encoder_control, combined_residual, coeff, width, height, cur_cu->joint_cb_cr == 1 ? COLOR_V : COLOR_U, cur_cu);
|
||||||
|
|
||||||
|
|
||||||
//if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
//if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
||||||
|
@ -537,7 +537,7 @@ int uvg_quantize_residual_generic(encoder_state_t *const state,
|
||||||
uvg_itransformskip(state->encoder_control, residual, coeff, width);
|
uvg_itransformskip(state->encoder_control, residual, coeff, width);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uvg_itransform2d(state->encoder_control, residual, coeff, width, color, cur_cu);
|
uvg_itransform2d(state->encoder_control, residual, coeff, width, height, color, cur_cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
if (state->tile->frame->lmcs_aps->m_sliceReshapeInfo.enableChromaAdj && color != COLOR_Y) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ void(*uvg_mts_idct)(int8_t bitdepth,
|
||||||
color_t color,
|
color_t color,
|
||||||
const cu_info_t *tu,
|
const cu_info_t *tu,
|
||||||
int8_t width,
|
int8_t width,
|
||||||
|
int8_t height,
|
||||||
const int16_t *input,
|
const int16_t *input,
|
||||||
int16_t *output,
|
int16_t *output,
|
||||||
const int8_t mts_idx);
|
const int8_t mts_idx);
|
||||||
|
|
|
@ -77,6 +77,7 @@ typedef void (mts_idct_func)(
|
||||||
color_t color,
|
color_t color,
|
||||||
const cu_info_t* tu,
|
const cu_info_t* tu,
|
||||||
int8_t width,
|
int8_t width,
|
||||||
|
int8_t height,
|
||||||
const int16_t* input,
|
const int16_t* input,
|
||||||
int16_t* output,
|
int16_t* output,
|
||||||
const int8_t mts_idx);
|
const int8_t mts_idx);
|
||||||
|
|
|
@ -266,17 +266,19 @@ void uvg_transform2d(const encoder_control_t * const encoder,
|
||||||
void uvg_itransform2d(const encoder_control_t * const encoder,
|
void uvg_itransform2d(const encoder_control_t * const encoder,
|
||||||
int16_t *block,
|
int16_t *block,
|
||||||
int16_t *coeff,
|
int16_t *coeff,
|
||||||
int8_t block_size,
|
int8_t block_width,
|
||||||
|
int8_t block_height,
|
||||||
color_t color,
|
color_t color,
|
||||||
const cu_info_t *tu)
|
const cu_info_t *tu)
|
||||||
{
|
{
|
||||||
if (encoder->cfg.mts)
|
if (encoder->cfg.mts)
|
||||||
{
|
{
|
||||||
uvg_mts_idct(encoder->bitdepth, color, tu, block_size, coeff, block, encoder->cfg.mts);
|
uvg_mts_idct(encoder->bitdepth, color, tu, block_width, block_height, coeff, block, encoder->cfg.mts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dct_func *idct_func = uvg_get_idct_func(block_size, color, tu->type);
|
// ISP_TODO: block height
|
||||||
|
dct_func *idct_func = uvg_get_idct_func(block_width, color, tu->type);
|
||||||
idct_func(encoder->bitdepth, coeff, block);
|
idct_func(encoder->bitdepth, coeff, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,7 +592,7 @@ void uvg_chroma_transform_search(
|
||||||
if (pred_cu->cr_lfnst_idx) {
|
if (pred_cu->cr_lfnst_idx) {
|
||||||
uvg_inv_lfnst(pred_cu, width, height, COLOR_U, pred_cu->cr_lfnst_idx, &u_coeff[i * trans_offset], tree_type);
|
uvg_inv_lfnst(pred_cu, width, height, COLOR_U, pred_cu->cr_lfnst_idx, &u_coeff[i * trans_offset], tree_type);
|
||||||
}
|
}
|
||||||
uvg_itransform2d(state->encoder_control, u_recon_resi, &u_coeff[i * trans_offset], width,
|
uvg_itransform2d(state->encoder_control, u_recon_resi, &u_coeff[i * trans_offset], width, height,
|
||||||
transforms[i] != JCCR_1 ? COLOR_U : COLOR_V, pred_cu);
|
transforms[i] != JCCR_1 ? COLOR_U : COLOR_V, pred_cu);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -617,7 +619,7 @@ void uvg_chroma_transform_search(
|
||||||
if (pred_cu->cr_lfnst_idx) {
|
if (pred_cu->cr_lfnst_idx) {
|
||||||
uvg_inv_lfnst(pred_cu, width, height, COLOR_V, pred_cu->cr_lfnst_idx, &v_coeff[i * trans_offset], tree_type);
|
uvg_inv_lfnst(pred_cu, width, height, COLOR_V, pred_cu->cr_lfnst_idx, &v_coeff[i * trans_offset], tree_type);
|
||||||
}
|
}
|
||||||
uvg_itransform2d(state->encoder_control, v_recon_resi, &v_coeff[i * trans_offset], width,
|
uvg_itransform2d(state->encoder_control, v_recon_resi, &v_coeff[i * trans_offset], width, height,
|
||||||
transforms[i] != JCCR_1 ? COLOR_U : COLOR_V, pred_cu);
|
transforms[i] != JCCR_1 ? COLOR_U : COLOR_V, pred_cu);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -61,7 +61,8 @@ void uvg_transform2d(const encoder_control_t * const encoder,
|
||||||
void uvg_itransform2d(const encoder_control_t * const encoder,
|
void uvg_itransform2d(const encoder_control_t * const encoder,
|
||||||
int16_t *block,
|
int16_t *block,
|
||||||
int16_t *coeff,
|
int16_t *coeff,
|
||||||
int8_t block_size,
|
int8_t block_width,
|
||||||
|
int8_t block_height,
|
||||||
color_t color,
|
color_t color,
|
||||||
const cu_info_t *tu);
|
const cu_info_t *tu);
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ static void setup_tests()
|
||||||
tu.tr_idx = MTS_DST7_DST7 + trafo;
|
tu.tr_idx = MTS_DST7_DST7 + trafo;
|
||||||
tu.lfnst_idx = 0;
|
tu.lfnst_idx = 0;
|
||||||
tu.cr_lfnst_idx = 0;
|
tu.cr_lfnst_idx = 0;
|
||||||
idct_generic(UVG_BIT_DEPTH, COLOR_Y, &tu, 1 << (LCU_MIN_LOG_W + block), dct_bufs[trafo * NUM_SIZES + block], idct_result[trafo][block], UVG_MTS_BOTH);
|
idct_generic(UVG_BIT_DEPTH, COLOR_Y, &tu, 1 << (LCU_MIN_LOG_W + block), 1 << (LCU_MIN_LOG_W + block), dct_bufs[trafo * NUM_SIZES + block], idct_result[trafo][block], UVG_MTS_BOTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue