From: Angie Chiang Date: Wed, 25 Nov 2015 21:07:13 +0000 (-0800) Subject: Refactor vp10_xform_quant X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88cae8b422ad67ebef02419a5097e0b88252fa26;p=libvpx Refactor vp10_xform_quant 1) Add facade to quantize b/fp/dc version so that their interface are the same. 2) Merge vp10_xform_quant b/fp/dc version to one function so that the code flow in encodemb.c is clear Change-Id: Ib62d6215438fc2d07f4e7e72393f964832d6746f --- diff --git a/vp10/common/blockd.h b/vp10/common/blockd.h index 0ea70d371..ba3a49f7b 100644 --- a/vp10/common/blockd.h +++ b/vp10/common/blockd.h @@ -171,7 +171,7 @@ struct buf_2d { int stride; }; -struct macroblockd_plane { +typedef struct macroblockd_plane { tran_low_t *dqcoeff; PLANE_TYPE plane_type; int subsampling_x; @@ -190,7 +190,7 @@ struct macroblockd_plane { // encoder const int16_t *dequant; -}; +} MACROBLOCKD_PLANE; #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) diff --git a/vp10/encoder/block.h b/vp10/encoder/block.h index 55ec46eec..4ffd26b18 100644 --- a/vp10/encoder/block.h +++ b/vp10/encoder/block.h @@ -24,7 +24,7 @@ typedef struct { unsigned int var; } diff; -struct macroblock_plane { +typedef struct macroblock_plane { DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]); tran_low_t *qcoeff; tran_low_t *coeff; @@ -40,7 +40,7 @@ struct macroblock_plane { int16_t *round; int64_t quant_thred[2]; -}; +} MACROBLOCK_PLANE; /* The [2] dimension is for whether we skip the EOB node (i.e. if previous * coefficient in this block was zero) or not. */ diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c index c52dde158..4b53191fa 100644 --- a/vp10/encoder/encodemb.c +++ b/vp10/encoder/encodemb.c @@ -24,6 +24,7 @@ #include "vp10/encoder/encodemb.h" #include "vp10/encoder/hybrid_fwd_txfm.h" +#include "vp10/encoder/quantize.h" #include "vp10/encoder/rd.h" #include "vp10/encoder/tokenize.h" @@ -307,185 +308,43 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, return final_eob; } -void vp10_xform_quant_fp(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { - MACROBLOCKD *const xd = &x->e_mbd; - const struct macroblock_plane *const p = &x->plane[plane]; - const struct macroblockd_plane *const pd = &xd->plane[plane]; - PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV; - TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); - const scan_order *const scan_order = - get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi)); - tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); - tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); - tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); - uint16_t *const eob = &p->eobs[block]; - const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; - const int16_t *src_diff; - - FWD_TXFM_PARAM fwd_txfm_param; - fwd_txfm_param.tx_type = get_tx_type(plane_type, xd, block, tx_size); - fwd_txfm_param.tx_size = tx_size; - fwd_txfm_param.fwd_txfm_opt = FWD_TXFM_OPT_NORMAL; - fwd_txfm_param.rd_transform = x->use_lp32x32fdct; - fwd_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id]; - - src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)]; - #if CONFIG_VP9_HIGHBITDEPTH - if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vp10_highbd_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin, - p->round_fp, p->quant_fp, p->quant_shift, - qcoeff, dqcoeff, pd->dequant, - eob, scan_order->scan, - scan_order->iscan); - break; - case TX_16X16: - vp10_highbd_quantize_fp(coeff, 256, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_8X8: - vp10_highbd_quantize_fp(coeff, 64, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_4X4: - vp10_highbd_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - default: - assert(0); - } - return; - } -#endif // CONFIG_VP9_HIGHBITDEPTH - - fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vp10_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, scan_order->scan, - scan_order->iscan); - break; - case TX_16X16: - vp10_quantize_fp(coeff, 256, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_8X8: - vp10_quantize_fp(coeff, 64, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_4X4: - vp10_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp, - p->quant_fp, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - default: - assert(0); - break; - } -} - -void vp10_xform_quant_dc(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { - MACROBLOCKD *const xd = &x->e_mbd; - const struct macroblock_plane *const p = &x->plane[plane]; - const struct macroblockd_plane *const pd = &xd->plane[plane]; - PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV; - tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); - tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); - tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); - uint16_t *const eob = &p->eobs[block]; - const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; - const int16_t *src_diff; +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_ls[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}}; - FWD_TXFM_PARAM fwd_txfm_param; - fwd_txfm_param.tx_type = get_tx_type(plane_type, xd, block, tx_size); - fwd_txfm_param.tx_size = tx_size; - fwd_txfm_param.fwd_txfm_opt = FWD_TXFM_OPT_DC; - fwd_txfm_param.rd_transform = 0; - fwd_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id]; +#else +typedef enum QUANT_FUNC { + QUANT_FUNC_LOWBD = 0, + QUANT_FUNC_LOWBD_32 = 1, + QUANT_FUNC_LAST = 2 +} QUANT_FUNC; - src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)]; +static VP10_QUANT_FACADE quant_func_ls[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}}; -#if CONFIG_VP9_HIGHBITDEPTH - if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vpx_highbd_quantize_dc_32x32(coeff, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_16X16: - vpx_highbd_quantize_dc(coeff, 256, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_8X8: - vpx_highbd_quantize_dc(coeff, 64, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_4X4: - vpx_highbd_quantize_dc(coeff, 16, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - default: - assert(0); - } - return; - } -#endif // CONFIG_VP9_HIGHBITDEPTH +#endif - fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vpx_quantize_dc_32x32(coeff, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_16X16: - vpx_quantize_dc(coeff, 256, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_8X8: - vpx_quantize_dc(coeff, 64, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - case TX_4X4: - vpx_quantize_dc(coeff, 16, x->skip_block, p->round, - p->quant_fp[0], qcoeff, dqcoeff, - pd->dequant[0], eob); - break; - default: - assert(0); - break; - } -} +static FWD_TXFM_OPT fwd_txfm_opt_ls[VP10_XFORM_QUANT_LAST] = { + FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_DC}; -void vp10_xform_quant(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { +void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, + int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + VP10_XFORM_QUANT xform_quant_idx) { MACROBLOCKD *const xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -499,11 +358,13 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, uint16_t *const eob = &p->eobs[block]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int16_t *src_diff; + const int tx1d_size = get_tx1d_size(tx_size); + 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); fwd_txfm_param.tx_size = tx_size; - fwd_txfm_param.fwd_txfm_opt = FWD_TXFM_OPT_NORMAL; + fwd_txfm_param.fwd_txfm_opt = fwd_txfm_opt_ls[xform_quant_idx]; fwd_txfm_param.rd_transform = x->use_lp32x32fdct; fwd_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id]; @@ -512,67 +373,30 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vpx_highbd_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, - p->round, p->quant, p->quant_shift, qcoeff, - dqcoeff, pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_16X16: - vpx_highbd_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_8X8: - vpx_highbd_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_4X4: - vpx_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - default: - assert(0); + if (x->skip_block) { + vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob); + } else { + if (tx_size == TX_32X32) + quant_func_ls[xform_quant_idx][QUANT_FUNC_HIGHBD_32]( + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order); + else + quant_func_ls[xform_quant_idx][QUANT_FUNC_HIGHBD]( + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order); } return; } #endif // CONFIG_VP9_HIGHBITDEPTH fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); - switch (tx_size) { - case TX_32X32: - vpx_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, scan_order->scan, - scan_order->iscan); - break; - case TX_16X16: - vpx_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_8X8: - vpx_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - case TX_4X4: - vpx_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, - p->quant, p->quant_shift, qcoeff, dqcoeff, - pd->dequant, eob, - scan_order->scan, scan_order->iscan); - break; - default: - assert(0); - break; + if (x->skip_block) { + vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob); + } else { + if (tx_size == TX_32X32) + quant_func_ls[xform_quant_idx][QUANT_FUNC_LOWBD_32]( + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order); + else + quant_func_ls[xform_quant_idx][QUANT_FUNC_LOWBD]( + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order); } } @@ -621,20 +445,20 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, *a = *l = 0; return; } else { - vp10_xform_quant_fp(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, VP10_XFORM_QUANT_FP); } } else { if (max_txsize_lookup[plane_bsize] == tx_size) { int txfm_blk_index = (plane << 2) + (block >> (tx_size << 1)); if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_NONE) { // full forward transform and quantization - vp10_xform_quant(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, VP10_XFORM_QUANT_B); } else if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_AC_ONLY) { // fast path forward transform and quantization - vp10_xform_quant_dc(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, VP10_XFORM_QUANT_DC); } else { // skip forward transform p->eobs[block] = 0; @@ -644,8 +468,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, #endif } } else { - vp10_xform_quant(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, VP10_XFORM_QUANT_B); } } } @@ -778,7 +602,8 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col, uint8_t *dst; dst = &pd->dst.buf[4 * blk_row * pd->dst.stride + 4 * blk_col]; - vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, VP10_XFORM_QUANT_B); if (p->eobs[block] > 0) { #if CONFIG_VP9_HIGHBITDEPTH diff --git a/vp10/encoder/encodemb.h b/vp10/encoder/encodemb.h index 3e5bce3c6..05ecc257b 100644 --- a/vp10/encoder/encodemb.h +++ b/vp10/encoder/encodemb.h @@ -23,17 +23,20 @@ struct encode_b_args { struct optimize_ctx *ctx; int8_t *skip; }; + +typedef enum VP10_XFORM_QUANT { + VP10_XFORM_QUANT_FP = 0, + VP10_XFORM_QUANT_B = 1, + VP10_XFORM_QUANT_DC = 2, + VP10_XFORM_QUANT_LAST = 3 +} VP10_XFORM_QUANT; + void vp10_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize); void vp10_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize); -void vp10_xform_quant_fp(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size); -void vp10_xform_quant_dc(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size); void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size); + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + VP10_XFORM_QUANT xform_quant_idx); void vp10_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane); diff --git a/vp10/encoder/quantize.c b/vp10/encoder/quantize.c index 86b324f1a..739a06dea 100644 --- a/vp10/encoder/quantize.c +++ b/vp10/encoder/quantize.c @@ -10,16 +10,194 @@ #include #include "./vpx_dsp_rtcd.h" +#include "vpx_dsp/quantize.h" #include "vpx_mem/vpx_mem.h" #include "vpx_ports/mem.h" #include "vp10/common/quant_common.h" +#include "vp10/common/scan.h" #include "vp10/common/seg_common.h" #include "vp10/encoder/encoder.h" #include "vp10/encoder/quantize.h" #include "vp10/encoder/rd.h" +void vp10_quantize_skip(intptr_t n_coeffs, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { + memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); + memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); + *eob_ptr = 0; +} + +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) { + // 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); +} + +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) { + // 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); +} + +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) { + // obsolete skip_block + const int skip_block = 0; + + (void)sc; + + vpx_quantize_dc(coeff_ptr, n_coeffs, 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) { + // 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); +} + +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) { + // 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); +} + +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) { + // obsolete skip_block + const int skip_block = 0; + + (void)sc; + + vpx_highbd_quantize_dc(coeff_ptr, 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); +} +#endif // CONFIG_VP9_HIGHBITDEPTH + void vp10_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, diff --git a/vp10/encoder/quantize.h b/vp10/encoder/quantize.h index b44088ecc..9c0ab3fbf 100644 --- a/vp10/encoder/quantize.h +++ b/vp10/encoder/quantize.h @@ -12,12 +12,20 @@ #define VP10_ENCODER_QUANTIZE_H_ #include "./vpx_config.h" +#include "vp10/common/scan.h" #include "vp10/encoder/block.h" #ifdef __cplusplus extern "C" { #endif +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); + typedef struct { DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]); @@ -38,7 +46,7 @@ typedef struct { } QUANTS; void vp10_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block, - const int16_t *scan, const int16_t *iscan); + const int16_t *scan, const int16_t *iscan); struct VP10_COMP; struct VP10Common; @@ -55,6 +63,81 @@ int vp10_quantizer_to_qindex(int quantizer); int vp10_qindex_to_quantizer(int qindex); +void vp10_quantize_skip(intptr_t n_coeffs, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); + +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); + +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); + +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); +#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); + +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); + +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); +#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 diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index 7fff6e394..379ff1be4 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -621,15 +621,15 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, SKIP_TXFM_NONE) { // full forward transform and quantization vp10_xform_quant(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + plane_bsize, tx_size, VP10_XFORM_QUANT_B); dist_block(x, plane, block, tx_size, &dist, &sse); } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == SKIP_TXFM_AC_ONLY) { // compute DC coefficient tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); - vp10_xform_quant_dc(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, + plane_bsize, tx_size, VP10_XFORM_QUANT_DC); sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; dist = sse; if (x->plane[plane].eobs[block]) { @@ -653,7 +653,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, } } else { // full forward transform and quantization - vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, + VP10_XFORM_QUANT_B); dist_block(x, plane, block, tx_size, &dist, &sse); } @@ -1961,7 +1962,8 @@ static void tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); - vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, + VP10_XFORM_QUANT_B); vpx_convolve_copy(dst, pd->dst.stride, rec_buffer, 32, NULL, 0, NULL, 0, bh, bh);