Commit 64413a6c authored by Angie Chiang's avatar Angie Chiang

Parameterize transform scale for quantizer

This is to facilitate changing transform scale later

Change-Id: Ic8ca5afba57d2489ebd191ccc40c1b31605a0d8c
parent 25520d8d
......@@ -19,6 +19,23 @@
#include "vpx_dsp/inv_txfm.h"
#include "vpx_ports/mem.h"
int get_tx_scale(const MACROBLOCKD *const xd, const TX_TYPE tx_type,
const TX_SIZE tx_size) {
(void) tx_type;
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
if (xd->bd == BITDEPTH_10) {
return 0;
} else {
return tx_size == TX_32X32;
}
}
#else
(void)xd;
#endif
return tx_size == TX_32X32;
}
#if CONFIG_EXT_TX
static void iidtx4_c(const tran_low_t *input, tran_low_t *output) {
int i;
......
......@@ -14,6 +14,7 @@
#include <assert.h>
#include "./vpx_config.h"
#include "vp10/common/blockd.h"
#include "vp10/common/common.h"
#include "vp10/common/enums.h"
#include "vpx_dsp/inv_txfm.h"
......@@ -48,6 +49,10 @@ typedef struct {
} highbd_transform_2d;
#endif // CONFIG_VP9_HIGHBITDEPTH
#define MAX_TX_SCALE 1
int get_tx_scale(const MACROBLOCKD *const xd, const TX_TYPE tx_type,
const TX_SIZE tx_size);
void vp10_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
int eob);
void vp10_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
......
......@@ -15,9 +15,7 @@
#include "vp10/common/blockd.h"
#include "vp10/common/common.h"
#include "vp10/common/entropy.h"
#if CONFIG_COEFFICIENT_RANGE_CHECKING
#include "vp10/common/idct.h"
#endif
#include "vp10/decoder/detokenize.h"
......@@ -113,15 +111,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
cat6_prob = vp10_cat6_prob;
#endif
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
dq_shift = 0;
} else {
dq_shift = (tx_size == TX_32X32);
}
#else
dq_shift = (tx_size == TX_32X32);
#endif
dq_shift = get_tx_scale(xd, 0, tx_size);
while (c < max_eob) {
int val = -1;
......@@ -257,15 +247,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
const uint8_t *cat5_prob;
const uint8_t *cat6_prob;
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
dq_shift = 0;
} else {
dq_shift = (tx_size == TX_32X32);
}
#else
dq_shift = (tx_size == TX_32X32);
#endif
dq_shift = get_tx_scale(xd, 0, tx_size);
if (counts) {
coef_counts = counts->coef[tx_size][type][ref];
......
......@@ -129,15 +129,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
assert((!type && !plane) || (type && plane));
assert(eob <= default_eob);
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
mul = 1;
} else {
mul = 1 + (tx_size == TX_32X32);
}
#else
mul = 1 + (tx_size == TX_32X32);
#endif
mul = 1 << get_tx_scale(xd, tx_type, tx_size);
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
if (!ref)
......@@ -323,35 +315,29 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
#if CONFIG_VP9_HIGHBITDEPTH
typedef enum QUANT_FUNC {
QUANT_FUNC_LOWBD = 0,
QUANT_FUNC_LOWBD_32 = 1,
QUANT_FUNC_HIGHBD = 2,
QUANT_FUNC_HIGHBD_32 = 3,
QUANT_FUNC_LAST = 4
QUANT_FUNC_HIGHBD = 1,
QUANT_FUNC_LAST = 2
} QUANT_FUNC;
static VP10_QUANT_FACADE
quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = {
{vp10_quantize_fp_facade, vp10_quantize_fp_32x32_facade,
vp10_highbd_quantize_fp_facade, vp10_highbd_quantize_fp_32x32_facade},
{vp10_quantize_b_facade, vp10_quantize_b_32x32_facade,
vp10_highbd_quantize_b_facade, vp10_highbd_quantize_b_32x32_facade},
{vp10_quantize_dc_facade, vp10_quantize_dc_32x32_facade,
vp10_highbd_quantize_dc_facade, vp10_highbd_quantize_dc_32x32_facade},
{NULL, NULL, NULL, NULL}};
{vp10_quantize_fp_facade, vp10_highbd_quantize_fp_facade},
{vp10_quantize_b_facade, vp10_highbd_quantize_b_facade},
{vp10_quantize_dc_facade, vp10_highbd_quantize_dc_facade},
{NULL, NULL}};
#else
typedef enum QUANT_FUNC {
QUANT_FUNC_LOWBD = 0,
QUANT_FUNC_LOWBD_32 = 1,
QUANT_FUNC_LAST = 2
QUANT_FUNC_LAST = 1
} QUANT_FUNC;
static VP10_QUANT_FACADE
quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = {
{vp10_quantize_fp_facade, vp10_quantize_fp_32x32_facade},
{vp10_quantize_b_facade, vp10_quantize_b_32x32_facade},
{vp10_quantize_dc_facade, vp10_quantize_dc_32x32_facade},
{NULL, NULL}};
{vp10_quantize_fp_facade},
{vp10_quantize_b_facade},
{vp10_quantize_dc_facade},
{NULL}};
#endif
static FWD_TXFM_OPT fwd_txfm_opt_list[VP10_XFORM_QUANT_LAST] = {
......@@ -378,7 +364,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
const int tx2d_size = tx1d_size * tx1d_size;
FWD_TXFM_PARAM fwd_txfm_param;
fwd_txfm_param.tx_type = get_tx_type(plane_type, xd, block, tx_size);
QUANT_PARAM qparam;
fwd_txfm_param.tx_type = tx_type;
fwd_txfm_param.tx_size = tx_size;
fwd_txfm_param.fwd_txfm_opt = fwd_txfm_opt_list[xform_quant_idx];
fwd_txfm_param.rd_transform = x->use_lp32x32fdct;
......@@ -386,6 +374,7 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)];
qparam.log_scale = get_tx_scale(xd, tx_type, tx_size);
#if CONFIG_VP9_HIGHBITDEPTH
fwd_txfm_param.bd = xd->bd;
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
......@@ -394,12 +383,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
if (x->skip_block) {
vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
} else {
if (tx_size == TX_32X32 && xd->bd != 10)
quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD_32](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
else
quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob,
scan_order, &qparam);
}
}
return;
......@@ -411,12 +397,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
if (x->skip_block) {
vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
} else {
if (tx_size == TX_32X32)
quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD_32](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
else
quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob,
scan_order, &qparam);
}
}
}
......
This diff is collapsed.
......@@ -19,12 +19,17 @@
extern "C" {
#endif
typedef struct QUANT_PARAM {
int log_scale;
} QUANT_PARAM;
typedef void (*VP10_QUANT_FACADE)(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
const scan_order *sc,
const QUANT_PARAM *qparam);
typedef struct {
// 0: dc 1: ac 2-8: ac repeated to SIMD width
......@@ -48,7 +53,6 @@ typedef struct {
void vp10_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
const int16_t *scan, const int16_t *iscan);
struct VP10_COMP;
struct VP10Common;
......@@ -71,74 +75,41 @@ void vp10_quantize_fp_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
const scan_order *sc, const QUANT_PARAM *qparam);
void vp10_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
const scan_order *sc, const QUANT_PARAM *qparam);
void vp10_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
const scan_order *sc, const QUANT_PARAM *qparam);
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_quantize_fp_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
const QUANT_PARAM *qparam);
void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
const scan_order *sc,
const QUANT_PARAM *qparam);
void vp10_highbd_quantize_dc_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
const QUANT_PARAM *qparam);
#endif // CONFIG_VP9_HIGHBITDEPTH
void vp10_quantize_fp_32x32_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
void vp10_quantize_b_32x32_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
void vp10_quantize_dc_32x32_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const scan_order *sc);
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_quantize_fp_32x32_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
void vp10_highbd_quantize_b_32x32_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
void vp10_highbd_quantize_dc_32x32_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
#endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -1003,7 +1003,7 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane,
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
int64_t this_sse;
int shift = tx_size == TX_32X32 ? 0 : 2;
int shift = (MAX_TX_SCALE - get_tx_scale(xd, 0, tx_size)) * 2;
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
#if CONFIG_VP9_HIGHBITDEPTH
......@@ -1177,19 +1177,11 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
const int64_t orig_sse = (int64_t)coeff[0] * coeff[0];
const int64_t resd_sse = coeff[0] - dqcoeff[0];
int64_t dc_correct = orig_sse - resd_sse * resd_sse;
int shift = (MAX_TX_SCALE - get_tx_scale(xd, 0, tx_size)) * 2;
#if CONFIG_VP9_HIGHBITDEPTH
dc_correct >>= ((xd->bd - 8) * 2);
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH &&
xd->bd == BITDEPTH_10) {
dc_correct >>= 2;
} else {
if (tx_size != TX_32X32)
dc_correct >>= 2;
}
#else
if (tx_size != TX_32X32)
dc_correct >>= 2;
#endif
dc_correct >>= shift;
dist = VPXMAX(0, sse - dc_correct);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment