ref: c74b33a413f43d76c0a3239f32d42a0980d07ff3
parent: 760223264264a64ed458a895296a09229d7b9fff
author: Ronald S. Bultje <[email protected]>
date: Tue Sep 22 10:01:48 EDT 2015
vp10: remove MACROBLOCK.fwd_txm4x4 function pointer. This is preparatory work for allowing per-segment lossless coding. See issue 1035. Change-Id: Idd72e2a42d90fa7319c10122032d1a7c7a54dc05
--- a/vp10/encoder/block.h
+++ b/vp10/encoder/block.h
@@ -133,7 +133,6 @@
// the visual quality at the boundary of moving color objects.
uint8_t color_sensitivity[2];
- void (*fwd_txm4x4)(const int16_t *input, tran_low_t *output, int stride);
void (*itxm_add)(const tran_low_t *input, uint8_t *dest, int stride, int eob);
#if CONFIG_VP9_HIGHBITDEPTH
void (*highbd_itxm_add)(const tran_low_t *input, uint8_t *dest, int stride,
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -2697,14 +2697,8 @@
cm->uv_ac_delta_q == 0;
#if CONFIG_VP9_HIGHBITDEPTH
- if (cm->use_highbitdepth)
- x->fwd_txm4x4 = xd->lossless ? vp10_highbd_fwht4x4 : vpx_highbd_fdct4x4;
- else
- x->fwd_txm4x4 = xd->lossless ? vp10_fwht4x4 : vpx_fdct4x4;
x->highbd_itxm_add = xd->lossless ? vp10_highbd_iwht4x4_add :
vp10_highbd_idct4x4_add;
-#else
- x->fwd_txm4x4 = xd->lossless ? vp10_fwht4x4 : vpx_fdct4x4;
#endif // CONFIG_VP9_HIGHBITDEPTH
x->itxm_add = xd->lossless ? vp10_iwht4x4_add : vp10_idct4x4_add;
--- a/vp10/encoder/encodemb.c
+++ b/vp10/encoder/encodemb.c
@@ -367,7 +367,11 @@
scan_order->scan, scan_order->iscan);
break;
case TX_4X4:
- x->fwd_txm4x4(src_diff, coeff, diff_stride);
+ if (xd->lossless) {
+ vp10_highbd_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ vpx_highbd_fdct4x4(src_diff, coeff, diff_stride);
+ }
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,
@@ -403,7 +407,11 @@
scan_order->scan, scan_order->iscan);
break;
case TX_4X4:
- x->fwd_txm4x4(src_diff, coeff, diff_stride);
+ if (xd->lossless) {
+ vp10_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ vpx_fdct4x4(src_diff, coeff, diff_stride);
+ }
vp10_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp,
p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
pd->dequant, eob,
@@ -453,7 +461,11 @@
pd->dequant[0], eob);
break;
case TX_4X4:
- x->fwd_txm4x4(src_diff, coeff, diff_stride);
+ if (xd->lossless) {
+ vp10_highbd_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ vpx_highbd_fdct4x4(src_diff, coeff, diff_stride);
+ }
vpx_highbd_quantize_dc(coeff, 16, x->skip_block, p->round,
p->quant_fp[0], qcoeff, dqcoeff,
pd->dequant[0], eob);
@@ -485,7 +497,11 @@
pd->dequant[0], eob);
break;
case TX_4X4:
- x->fwd_txm4x4(src_diff, coeff, diff_stride);
+ if (xd->lossless) {
+ vp10_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ vpx_fdct4x4(src_diff, coeff, diff_stride);
+ }
vpx_quantize_dc(coeff, 16, x->skip_block, p->round,
p->quant_fp[0], qcoeff, dqcoeff,
pd->dequant[0], eob);
@@ -496,22 +512,24 @@
}
}
-void vp10_fwd_txfm_4x4(const int16_t *src_diff,
- tran_low_t *coeff, int diff_stride, TX_TYPE tx_type,
- void (*fwd_txm4x4)(const int16_t *input,
- tran_low_t *output, int stride)) {
- switch (tx_type) {
- case DCT_DCT:
- fwd_txm4x4(src_diff, coeff, diff_stride);
- break;
- case ADST_DCT:
- case DCT_ADST:
- case ADST_ADST:
- vp10_fht4x4(src_diff, coeff, diff_stride, tx_type);
- break;
- default:
- assert(0);
- break;
+void vp10_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
+ int diff_stride, TX_TYPE tx_type, int lossless) {
+ if (lossless) {
+ vp10_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ switch (tx_type) {
+ case DCT_DCT:
+ vpx_fdct4x4(src_diff, coeff, diff_stride);
+ break;
+ case ADST_DCT:
+ case DCT_ADST:
+ case ADST_ADST:
+ vp10_fht4x4(src_diff, coeff, diff_stride, tx_type);
+ break;
+ default:
+ assert(0);
+ break;
+ }
}
}
@@ -565,21 +583,24 @@
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
- int diff_stride, TX_TYPE tx_type,
- void (*highbd_fwd_txm4x4)(const int16_t *input,
- tran_low_t *output, int stride)) {
- switch (tx_type) {
- case DCT_DCT:
- highbd_fwd_txm4x4(src_diff, coeff, diff_stride);
- break;
- case ADST_DCT:
- case DCT_ADST:
- case ADST_ADST:
- vp10_highbd_fht4x4(src_diff, coeff, diff_stride, tx_type);
- break;
- default:
- assert(0);
- break;
+ int diff_stride, TX_TYPE tx_type, int lossless) {
+ if (lossless) {
+ assert(tx_type == DCT_DCT);
+ vp10_highbd_fwht4x4(src_diff, coeff, diff_stride);
+ } else {
+ switch (tx_type) {
+ case DCT_DCT:
+ vpx_highbd_fdct4x4(src_diff, coeff, diff_stride);
+ break;
+ case ADST_DCT:
+ case DCT_ADST:
+ case ADST_ADST:
+ vp10_highbd_fht4x4(src_diff, coeff, diff_stride, tx_type);
+ break;
+ default:
+ assert(0);
+ break;
+ }
}
}
@@ -681,7 +702,7 @@
break;
case TX_4X4:
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type,
- x->fwd_txm4x4);
+ xd->lossless);
vpx_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
pd->dequant, eob,
@@ -717,7 +738,7 @@
scan_order->scan, scan_order->iscan);
break;
case TX_4X4:
- vp10_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, x->fwd_txm4x4);
+ vp10_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, xd->lossless);
vpx_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
pd->dequant, eob,
@@ -999,7 +1020,7 @@
vpx_highbd_subtract_block(4, 4, src_diff, diff_stride,
src, src_stride, dst, dst_stride, xd->bd);
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type,
- x->fwd_txm4x4);
+ xd->lossless);
vpx_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
pd->dequant, eob,
@@ -1068,7 +1089,7 @@
if (!x->skip_recode) {
vpx_subtract_block(4, 4, src_diff, diff_stride,
src, src_stride, dst, dst_stride);
- vp10_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, x->fwd_txm4x4);
+ vp10_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, xd->lossless);
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,
--- a/vp10/encoder/encodemb.h
+++ b/vp10/encoder/encodemb.h
@@ -39,16 +39,12 @@
void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
-void vp10_fwd_txfm_4x4(const int16_t *src_diff,
- tran_low_t *coeff, int diff_stride, TX_TYPE tx_type,
- void (*fwd_txm4x4)(const int16_t *input,
- tran_low_t *output, int stride));
+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
void vp10_highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
- int diff_stride, TX_TYPE tx_type,
- void (*highbd_fwd_txm4x4)(const int16_t *input,
- tran_low_t *output, int stride));
+ int diff_stride, TX_TYPE tx_type, int lossless);
#endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus
--- a/vp10/encoder/encoder.c
+++ b/vp10/encoder/encoder.c
@@ -4086,19 +4086,14 @@
}
if (oxcf->pass == 1) {
- const int lossless = is_lossless_requested(oxcf);
+ cpi->td.mb.e_mbd.lossless = is_lossless_requested(oxcf);
#if CONFIG_VP9_HIGHBITDEPTH
- if (cpi->oxcf.use_highbitdepth)
- cpi->td.mb.fwd_txm4x4 = lossless ?
- vp10_highbd_fwht4x4 : vpx_highbd_fdct4x4;
- else
- cpi->td.mb.fwd_txm4x4 = lossless ? vp10_fwht4x4 : vpx_fdct4x4;
- cpi->td.mb.highbd_itxm_add = lossless ? vp10_highbd_iwht4x4_add :
- vp10_highbd_idct4x4_add;
-#else
- cpi->td.mb.fwd_txm4x4 = lossless ? vp10_fwht4x4 : vpx_fdct4x4;
+ cpi->td.mb.highbd_itxm_add =
+ cpi->td.mb.e_mbd.lossless ? vp10_highbd_iwht4x4_add
+ : vp10_highbd_idct4x4_add;
#endif // CONFIG_VP9_HIGHBITDEPTH
- cpi->td.mb.itxm_add = lossless ? vp10_iwht4x4_add : vp10_idct4x4_add;
+ cpi->td.mb.itxm_add = cpi->td.mb.e_mbd.lossless ? vp10_iwht4x4_add
+ : vp10_idct4x4_add;
vp10_first_pass(cpi, source);
} else if (oxcf->pass == 2) {
Pass2Encode(cpi, size, dest, frame_flags);
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -798,8 +798,7 @@
if (xd->lossless) {
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
const scan_order *so = get_scan(TX_4X4, tx_type);
- vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT,
- vp10_highbd_fwht4x4);
+ vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
so->scan, so->neighbors,
@@ -814,8 +813,7 @@
int64_t unused;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
const scan_order *so = get_scan(TX_4X4, tx_type);
- vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, tx_type,
- vpx_highbd_fdct4x4);
+ vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
so->scan, so->neighbors,
@@ -901,7 +899,7 @@
if (xd->lossless) {
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
const scan_order *so = get_scan(TX_4X4, tx_type);
- vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, vp10_fwht4x4);
+ vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
so->scan, so->neighbors,
@@ -915,7 +913,7 @@
int64_t unused;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
const scan_order *so = get_scan(TX_4X4, tx_type);
- vp10_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, vpx_fdct4x4);
+ vp10_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
so->scan, so->neighbors,
@@ -1290,6 +1288,8 @@
const int width = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
const int height = 4 * num_4x4_blocks_high_lookup[plane_bsize];
int idx, idy;
+ void (*fwd_txm4x4)(const int16_t *input, tran_low_t *output, int stride);
+
const uint8_t *const src =
&p->src.buf[vp10_raster_block_offset(BLOCK_8X8, i, p->src.stride)];
uint8_t *const dst = &pd->dst.buf[vp10_raster_block_offset(BLOCK_8X8, i,
@@ -1303,6 +1303,16 @@
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+ fwd_txm4x4 = xd->lossless ? vp10_highbd_fwht4x4 : vpx_highbd_fdct4x4;
+ } else {
+ fwd_txm4x4 = xd->lossless ? vp10_fwht4x4 : vpx_fdct4x4;
+ }
+#else
+ fwd_txm4x4 = xd->lossless ? vp10_fwht4x4 : vpx_fdct4x4;
+#endif // CONFIG_VP9_HIGHBITDEPTH
+
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vpx_highbd_subtract_block(
height, width, vp10_raster_block_offset_int16(BLOCK_8X8, i, p->src_diff),
8, src, p->src.stride, dst, pd->dst.stride, xd->bd);
@@ -1325,8 +1335,8 @@
k += (idy * 2 + idx);
coeff = BLOCK_OFFSET(p->coeff, k);
- x->fwd_txm4x4(vp10_raster_block_offset_int16(BLOCK_8X8, k, p->src_diff),
- coeff, 8);
+ fwd_txm4x4(vp10_raster_block_offset_int16(BLOCK_8X8, k, p->src_diff),
+ coeff, 8);
vp10_regular_quantize_b_4x4(x, 0, k, so->scan, so->iscan);
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {