Refactor sub8x8 block transform and quantization process
This commit refactors the transform and quantization process for sub8x8 blocks and unifies the related functions. Change-Id: I005f61f3eb49eec44f947b906c4e308cab9935a2
This commit is contained in:
parent
db78fa9abb
commit
bbe1b2217b
@ -23,7 +23,7 @@ static INLINE void fdct32x32(int rd_transform, const int16_t *src,
|
|||||||
vpx_fdct32x32(src, dst, src_stride);
|
vpx_fdct32x32(src, dst, src_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp10_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
||||||
int diff_stride, TX_TYPE tx_type, int lossless) {
|
int diff_stride, TX_TYPE tx_type, int lossless) {
|
||||||
if (lossless) {
|
if (lossless) {
|
||||||
assert(tx_type == DCT_DCT);
|
assert(tx_type == DCT_DCT);
|
||||||
@ -173,7 +173,7 @@ static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
void vp10_highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
||||||
int diff_stride, TX_TYPE tx_type, int lossless,
|
int diff_stride, TX_TYPE tx_type, int lossless,
|
||||||
const int bd) {
|
const int bd) {
|
||||||
if (lossless) {
|
if (lossless) {
|
||||||
@ -345,7 +345,7 @@ void fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
|
|||||||
fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
|
fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
|
||||||
break;
|
break;
|
||||||
case TX_4X4:
|
case TX_4X4:
|
||||||
vp10_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless);
|
fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -376,7 +376,7 @@ void highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
|
|||||||
fwd_txfm_opt, bd);
|
fwd_txfm_opt, bd);
|
||||||
break;
|
break;
|
||||||
case TX_4X4:
|
case TX_4X4:
|
||||||
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type,
|
highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type,
|
||||||
lossless, bd);
|
lossless, bd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -32,15 +32,10 @@ extern "C" {
|
|||||||
|
|
||||||
void fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
|
void fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
|
||||||
FWD_TXFM_PARAM *fwd_txfm_param);
|
FWD_TXFM_PARAM *fwd_txfm_param);
|
||||||
void vp10_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
|
||||||
int diff_stride, TX_TYPE tx_type, int lossless);
|
|
||||||
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
void highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
|
void highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
|
||||||
int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param);
|
int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param);
|
||||||
void vp10_highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
|
|
||||||
int diff_stride, TX_TYPE tx_type, int lossless,
|
|
||||||
const int bd);
|
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
|
|
||||||
static INLINE int get_tx1d_size(TX_SIZE tx_size) {
|
static INLINE int get_tx1d_size(TX_SIZE tx_size) {
|
||||||
|
@ -1156,32 +1156,6 @@ void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr,
|
|||||||
}
|
}
|
||||||
#endif
|
#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;
|
|
||||||
struct macroblock_plane *p = &x->plane[plane];
|
|
||||||
struct macroblockd_plane *pd = &xd->plane[plane];
|
|
||||||
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
|
||||||
vpx_highbd_quantize_b(BLOCK_OFFSET(p->coeff, block),
|
|
||||||
16, x->skip_block,
|
|
||||||
p->zbin, p->round, p->quant, p->quant_shift,
|
|
||||||
BLOCK_OFFSET(p->qcoeff, block),
|
|
||||||
BLOCK_OFFSET(pd->dqcoeff, block),
|
|
||||||
pd->dequant, &p->eobs[block],
|
|
||||||
scan, iscan);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
vpx_quantize_b(BLOCK_OFFSET(p->coeff, block),
|
|
||||||
16, x->skip_block,
|
|
||||||
p->zbin, p->round, p->quant, p->quant_shift,
|
|
||||||
BLOCK_OFFSET(p->qcoeff, block),
|
|
||||||
BLOCK_OFFSET(pd->dqcoeff, block),
|
|
||||||
pd->dequant, &p->eobs[block], scan, iscan);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void invert_quant(int16_t *quant, int16_t *shift, int d) {
|
static void invert_quant(int16_t *quant, int16_t *shift, int d) {
|
||||||
unsigned t;
|
unsigned t;
|
||||||
int l;
|
int l;
|
||||||
|
@ -59,8 +59,6 @@ typedef struct {
|
|||||||
DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
|
DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
|
||||||
} QUANTS;
|
} QUANTS;
|
||||||
|
|
||||||
void vp10_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
|
|
||||||
const int16_t *scan, const int16_t *iscan);
|
|
||||||
struct VP10_COMP;
|
struct VP10_COMP;
|
||||||
struct VP10Common;
|
struct VP10Common;
|
||||||
|
|
||||||
|
@ -2132,7 +2132,6 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
|
|||||||
int16_t *const src_diff = vp10_raster_block_offset_int16(BLOCK_8X8,
|
int16_t *const src_diff = vp10_raster_block_offset_int16(BLOCK_8X8,
|
||||||
block,
|
block,
|
||||||
p->src_diff);
|
p->src_diff);
|
||||||
tran_low_t *const coeff = BLOCK_OFFSET(x->plane[0].coeff, block);
|
|
||||||
xd->mi[0]->bmi[block].as_mode = mode;
|
xd->mi[0]->bmi[block].as_mode = mode;
|
||||||
vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride,
|
vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride,
|
||||||
dst, dst_stride,
|
dst, dst_stride,
|
||||||
@ -2146,8 +2145,8 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
|
|||||||
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
||||||
*(templ + idy));
|
*(templ + idy));
|
||||||
#endif // CONFIG_VAR_TX
|
#endif // CONFIG_VAR_TX
|
||||||
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1, xd->bd);
|
vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
|
||||||
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
|
TX_4X4, VP10_XFORM_QUANT_B);
|
||||||
#if CONFIG_VAR_TX
|
#if CONFIG_VAR_TX
|
||||||
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
||||||
so->neighbors, cpi->sf.use_fast_coef_costing);
|
so->neighbors, cpi->sf.use_fast_coef_costing);
|
||||||
@ -2173,8 +2172,8 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
|
|||||||
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
||||||
*(templ + idy));
|
*(templ + idy));
|
||||||
#endif // CONFIG_VAR_TX
|
#endif // CONFIG_VAR_TX
|
||||||
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0, xd->bd);
|
vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
|
||||||
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
|
TX_4X4, VP10_XFORM_QUANT_B);
|
||||||
#if CONFIG_VAR_TX
|
#if CONFIG_VAR_TX
|
||||||
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
||||||
so->neighbors, cpi->sf.use_fast_coef_costing);
|
so->neighbors, cpi->sf.use_fast_coef_costing);
|
||||||
@ -2257,7 +2256,6 @@ next_highbd:
|
|||||||
uint8_t *const dst = &dst_init[idx * 4 + idy * 4 * dst_stride];
|
uint8_t *const dst = &dst_init[idx * 4 + idy * 4 * dst_stride];
|
||||||
int16_t *const src_diff =
|
int16_t *const src_diff =
|
||||||
vp10_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff);
|
vp10_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff);
|
||||||
tran_low_t *const coeff = BLOCK_OFFSET(x->plane[0].coeff, block);
|
|
||||||
xd->mi[0]->bmi[block].as_mode = mode;
|
xd->mi[0]->bmi[block].as_mode = mode;
|
||||||
vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride,
|
vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride,
|
||||||
dst, dst_stride, col + idx, row + idy, 0);
|
dst, dst_stride, col + idx, row + idy, 0);
|
||||||
@ -2270,8 +2268,8 @@ next_highbd:
|
|||||||
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
||||||
*(templ + idy));
|
*(templ + idy));
|
||||||
#endif
|
#endif
|
||||||
vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1);
|
vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
|
||||||
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
|
TX_4X4, VP10_XFORM_QUANT_B);
|
||||||
#if CONFIG_VAR_TX
|
#if CONFIG_VAR_TX
|
||||||
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
||||||
so->neighbors, cpi->sf.use_fast_coef_costing);
|
so->neighbors, cpi->sf.use_fast_coef_costing);
|
||||||
@ -2296,8 +2294,8 @@ next_highbd:
|
|||||||
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
|
||||||
*(templ + idy));
|
*(templ + idy));
|
||||||
#endif
|
#endif
|
||||||
vp10_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0);
|
vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
|
||||||
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
|
TX_4X4, VP10_XFORM_QUANT_B);
|
||||||
#if CONFIG_VAR_TX
|
#if CONFIG_VAR_TX
|
||||||
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
|
||||||
so->neighbors, cpi->sf.use_fast_coef_costing);
|
so->neighbors, cpi->sf.use_fast_coef_costing);
|
||||||
@ -4525,8 +4523,6 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi,
|
|||||||
for (idy = 0; idy < height / 4; ++idy) {
|
for (idy = 0; idy < height / 4; ++idy) {
|
||||||
for (idx = 0; idx < width / 4; ++idx) {
|
for (idx = 0; idx < width / 4; ++idx) {
|
||||||
int64_t dist, ssz, rd, rd1, rd2;
|
int64_t dist, ssz, rd, rd1, rd2;
|
||||||
const int16_t *src_diff;
|
|
||||||
tran_low_t* coeff;
|
|
||||||
#if CONFIG_VAR_TX
|
#if CONFIG_VAR_TX
|
||||||
int coeff_ctx;
|
int coeff_ctx;
|
||||||
#endif
|
#endif
|
||||||
@ -4535,23 +4531,8 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi,
|
|||||||
coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)),
|
coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)),
|
||||||
*(tl + (k >> 1)));
|
*(tl + (k >> 1)));
|
||||||
#endif
|
#endif
|
||||||
coeff = BLOCK_OFFSET(p->coeff, k);
|
vp10_xform_quant(x, 0, k, idy + (i >> 1), idx + (i & 0x01), BLOCK_8X8,
|
||||||
|
TX_4X4, VP10_XFORM_QUANT_B);
|
||||||
src_diff = vp10_raster_block_offset_int16(BLOCK_8X8, k, p->src_diff);
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
|
||||||
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT,
|
|
||||||
xd->lossless[mi->mbmi.segment_id], xd->bd);
|
|
||||||
} else {
|
|
||||||
vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT,
|
|
||||||
xd->lossless[mi->mbmi.segment_id]);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT,
|
|
||||||
xd->lossless[mi->mbmi.segment_id]);
|
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
|
|
||||||
vp10_regular_quantize_b_4x4(x, 0, k, so->scan, so->iscan);
|
|
||||||
dist_block(cpi, x, 0, k, idy + (i >> 1), idx + (i & 0x1), TX_4X4,
|
dist_block(cpi, x, 0, k, idy + (i >> 1), idx + (i & 0x1), TX_4X4,
|
||||||
&dist, &ssz);
|
&dist, &ssz);
|
||||||
thisdistortion += dist;
|
thisdistortion += dist;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user