Merge changes I359aa49c,Ic8ca5afb into nextgenv2

* changes:
  Generalize txfm scale in highbd quantizer
  Parameterize transform scale for quantizer
This commit is contained in:
Angie Chiang
2016-04-12 18:02:05 +00:00
committed by Gerrit Code Review
8 changed files with 208 additions and 260 deletions

View File

@@ -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;

View File

@@ -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,

View File

@@ -662,11 +662,11 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/int64_t vp10_highbd_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd";
specialize qw/vp10_highbd_block_error sse2/;
add_proto qw/void vp10_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
add_proto qw/void vp10_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const int log_scale";
specialize qw/vp10_highbd_quantize_fp/;
add_proto qw/void vp10_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/vp10_highbd_quantize_fp_32x32/;
add_proto qw/void vp10_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const int log_scale";
specialize qw/vp10_highbd_quantize_b/;
# fdct functions
add_proto qw/void vp10_highbd_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";

View File

@@ -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];

View File

@@ -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;
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}};
#else
typedef enum QUANT_FUNC {
QUANT_FUNC_LOWBD = 0,
QUANT_FUNC_LOWBD_32 = 1,
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_quantize_b_facade, vp10_quantize_b_32x32_facade},
{vp10_quantize_dc_facade, vp10_quantize_dc_32x32_facade},
{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_LAST = 1
} QUANT_FUNC;
static VP10_QUANT_FACADE
quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = {
{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);
}
}
}

View File

@@ -33,52 +33,72 @@ 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) {
// obsolete skip_block
const int skip_block = 0;
vp10_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
if (qparam->log_scale == 0) {
vp10_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
} else {
vp10_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
p->round_fp, p->quant_fp, p->quant_shift, qcoeff_ptr,
dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
sc->iscan);
}
}
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) {
// obsolete skip_block
const int skip_block = 0;
vpx_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round, p->quant,
p->quant_shift, qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
sc->scan, sc->iscan);
if (qparam->log_scale == 0) {
vpx_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round, p->quant,
p->quant_shift, qcoeff_ptr, dqcoeff_ptr, pd->dequant,
eob_ptr, sc->scan, sc->iscan);
} else {
vpx_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
}
}
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) {
// obsolete skip_block
const int skip_block = 0;
(void)sc;
vpx_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
eob_ptr);
if (qparam->log_scale == 0) {
vpx_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
eob_ptr);
} else {
vpx_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
qcoeff_ptr, dqcoeff_ptr, pd->dequant[0], eob_ptr);
}
}
#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) {
// obsolete skip_block
const int skip_block = 0;
vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin,
p->round_fp, p->quant_fp, p->quant_shift,
qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
sc->scan, sc->iscan, qparam->log_scale);
}
void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
@@ -86,114 +106,30 @@ void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
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) {
// obsolete skip_block
const int skip_block = 0;
vpx_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
vp10_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan,
qparam->log_scale);
}
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) {
// obsolete skip_block
const int skip_block = 0;
(void)sc;
vpx_highbd_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
vp10_highbd_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr,
pd->dequant[0], eob_ptr);
}
#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) {
// obsolete skip_block
const int skip_block = 0;
vp10_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
}
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) {
// obsolete skip_block
const int skip_block = 0;
vpx_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
pd->dequant, eob_ptr, sc->scan, sc->iscan);
}
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) {
// obsolete skip_block
const int skip_block = 0;
(void)sc;
(void)n_coeffs;
vpx_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
qcoeff_ptr, dqcoeff_ptr, pd->dequant[0], eob_ptr);
}
#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) {
// obsolete skip_block
const int skip_block = 0;
vp10_highbd_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
p->round_fp, p->quant_fp, p->quant_shift,
qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
sc->scan, sc->iscan);
}
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) {
// obsolete skip_block
const int skip_block = 0;
vpx_highbd_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
p->round, p->quant, p->quant_shift, qcoeff_ptr,
dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
sc->iscan);
}
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) {
// obsolete skip_block
const int skip_block = 0;
(void)sc;
(void)n_coeffs;
vpx_highbd_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
eob_ptr);
pd->dequant[0], eob_ptr, qparam->log_scale);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -250,9 +186,11 @@ void vp10_highbd_quantize_fp_c(const tran_low_t *coeff_ptr,
const int16_t *dequant_ptr,
uint16_t *eob_ptr,
const int16_t *scan,
const int16_t *iscan) {
const int16_t *iscan, const int log_scale) {
int i;
int eob = -1;
const int scale = 1 << log_scale;
const int shift = 16 - log_scale;
// TODO(jingning) Decide the need of these arguments after the
// quantization process is completed.
(void)zbin_ptr;
@@ -271,9 +209,10 @@ void vp10_highbd_quantize_fp_c(const tran_low_t *coeff_ptr,
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int64_t tmp = abs_coeff + round_ptr[rc != 0];
const uint32_t abs_qcoeff = (uint32_t)((tmp * quant_ptr[rc != 0]) >> 16);
const uint32_t abs_qcoeff =
(uint32_t)((tmp * quant_ptr[rc != 0]) >> shift);
qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0];
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale;
if (abs_qcoeff)
eob = i;
}
@@ -325,49 +264,101 @@ void vp10_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
}
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_quantize_fp_32x32_c(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, int skip_block,
const int16_t *zbin_ptr,
const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr,
uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int i, eob = -1;
(void)zbin_ptr;
(void)quant_shift_ptr;
void vp10_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
int skip_block, const int16_t *zbin_ptr,
const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan, const int log_scale) {
int i, non_zero_count = (int)n_coeffs, eob = -1;
int zbins[2] = {zbin_ptr[0], zbin_ptr[1]};
int round[2] = {round_ptr[0], round_ptr[1]};
int nzbins[2];
int scale = 1;
int shift = 16;
(void)iscan;
if (log_scale > 0) {
zbins[0] = ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale);
zbins[1] = ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale);
round[0] = ROUND_POWER_OF_TWO(round_ptr[0], log_scale);
round[1] = ROUND_POWER_OF_TWO(round_ptr[1], log_scale);
scale = 1 << log_scale;
shift = 16 - log_scale;
}
nzbins[0] = zbins[0] * -1;
nzbins[1] = zbins[1] * -1;
memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
if (!skip_block) {
for (i = 0; i < n_coeffs; i++) {
uint32_t abs_qcoeff = 0;
// Pre-scan pass
for (i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
if (coeff < zbins[rc != 0] && coeff > nzbins[rc != 0])
non_zero_count--;
else
break;
}
// Quantization pass: All coefficients with index >= zero_flag are
// skippable. Note: zero_flag can be zero.
for (i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
if (abs_coeff >= (dequant_ptr[rc != 0] >> 2)) {
const int64_t tmp = abs_coeff
+ ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1);
abs_qcoeff = (uint32_t) ((tmp * quant_ptr[rc != 0]) >> 15);
if (abs_coeff >= zbins[rc != 0]) {
const int64_t tmp1 = abs_coeff + round[rc != 0];
const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
const uint32_t abs_qcoeff =
(uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> shift);
qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2;
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale;
if (abs_qcoeff)
eob = i;
}
if (abs_qcoeff)
eob = i;
}
}
*eob_ptr = eob + 1;
}
#endif
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr,
int n_coeffs, int skip_block,
const int16_t *round_ptr, const int16_t quant,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t dequant_ptr, uint16_t *eob_ptr,
const int log_scale) {
int eob = -1;
memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
if (!skip_block) {
const int coeff = coeff_ptr[0];
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int64_t tmp = abs_coeff + round_ptr[0];
const uint32_t abs_qcoeff = (uint32_t)((tmp * quant) >> (16 - log_scale));
qcoeff_ptr[0] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
dqcoeff_ptr[0] = qcoeff_ptr[0] * dequant_ptr / (1 << log_scale);
if (abs_qcoeff)
eob = 0;
}
*eob_ptr = eob + 1;
}
#endif
void vp10_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
const int16_t *scan, const int16_t *iscan) {
MACROBLOCKD *const xd = &x->e_mbd;

View File

@@ -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,48 @@ 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);
void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr,
int n_coeffs, int skip_block,
const int16_t *round_ptr, const int16_t quant,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t dequant_ptr, uint16_t *eob_ptr,
const int log_scale);
#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

View File

@@ -1001,7 +1001,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
@@ -1175,19 +1175,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);
}