Add facade to inverse txfm
Add inv_txfm and highbd_inv_txfm as facades of inverse transform
such that the code flow in encodemb.c can be simpler
Change-Id: Iea45fd22dd8b173f8eb3919ca6502636f7bcfcf7
diff --git a/vp10/common/idct.c b/vp10/common/idct.c
index 3b806dd..cc9b7a1 100644
--- a/vp10/common/idct.c
+++ b/vp10/common/idct.c
@@ -1244,3 +1244,66 @@
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
+
+void inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
+ INV_TXFM_PARAM *inv_txfm_param) {
+ const TX_TYPE tx_type = inv_txfm_param->tx_type;
+ const TX_SIZE tx_size = inv_txfm_param->tx_size;
+ const int eob = inv_txfm_param->eob;
+ const int lossless = inv_txfm_param->lossless;
+
+ switch (tx_size) {
+ case TX_32X32:
+ vp10_inv_txfm_add_32x32(input, dest, stride, eob, tx_type);
+ break;
+ case TX_16X16:
+ vp10_inv_txfm_add_16x16(input, dest, stride, eob, tx_type);
+ break;
+ case TX_8X8:
+ vp10_inv_txfm_add_8x8(input, dest, stride, eob, tx_type);
+ break;
+ case TX_4X4:
+ // this is like vp10_short_idct4x4 but has a special case around eob<=1
+ // which is significant (not just an optimization) for the lossless
+ // case.
+ vp10_inv_txfm_add_4x4(input, dest, stride, eob, tx_type,
+ lossless);
+ break;
+ default:
+ assert(0 && "Invalid transform size");
+ break;
+ }
+}
+
+#if CONFIG_VP9_HIGHBITDEPTH
+void highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
+ INV_TXFM_PARAM *inv_txfm_param) {
+ const TX_TYPE tx_type = inv_txfm_param->tx_type;
+ const TX_SIZE tx_size = inv_txfm_param->tx_size;
+ const int eob = inv_txfm_param->eob;
+ const int bd = inv_txfm_param->bd;
+ const int lossless = inv_txfm_param->lossless;
+
+ switch (tx_size) {
+ case TX_32X32:
+ vp10_highbd_inv_txfm_add_32x32(input, dest, stride, eob, bd, tx_type);
+ break;
+ case TX_16X16:
+ vp10_highbd_inv_txfm_add_16x16(input, dest, stride, eob, bd, tx_type);
+ break;
+ case TX_8X8:
+ vp10_highbd_inv_txfm_add_8x8(input, dest, stride, eob, bd, tx_type);
+ break;
+ case TX_4X4:
+ // this is like vp10_short_idct4x4 but has a special case around eob<=1
+ // which is significant (not just an optimization) for the lossless
+ // case.
+ vp10_highbd_inv_txfm_add_4x4(input, dest, stride, eob, bd, tx_type,
+ lossless);
+ break;
+ default:
+ assert(0 && "Invalid transform size");
+ break;
+ }
+}
+#endif // CONFIG_VP9_HIGHBITDEPTH
diff --git a/vp10/common/idct.h b/vp10/common/idct.h
index 0883398..31b26b8 100644
--- a/vp10/common/idct.h
+++ b/vp10/common/idct.h
@@ -24,6 +24,16 @@
extern "C" {
#endif
+typedef struct INV_TXFM_PARAM {
+ TX_TYPE tx_type;
+ TX_SIZE tx_size;
+ int eob;
+ int lossless;
+#if CONFIG_VP9_HIGHBITDEPTH
+ int bd;
+#endif
+} INV_TXFM_PARAM;
+
typedef void (*transform_1d)(const tran_low_t*, tran_low_t*);
typedef struct {
@@ -51,7 +61,8 @@
int stride, int eob, TX_TYPE tx_type);
void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
int stride, int eob, TX_TYPE tx_type);
-
+void inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
+ INV_TXFM_PARAM *inv_txfm_param);
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
int eob, int bd);
@@ -74,6 +85,8 @@
void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
int stride, int eob, int bd,
TX_TYPE tx_type);
+void highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
+ INV_TXFM_PARAM *inv_txfm_param);
#endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"
diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c
index 94a7eed..c52dde1 100644
--- a/vp10/encoder/encodemb.c
+++ b/vp10/encoder/encodemb.c
@@ -588,7 +588,7 @@
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
uint8_t *dst;
ENTROPY_CONTEXT *a, *l;
- TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
+ INV_TXFM_PARAM inv_txfm_param;
#if CONFIG_VAR_TX
int i;
const int bwl = b_width_log2_lookup[plane_bsize];
@@ -697,62 +697,21 @@
if (p->eobs[block] == 0)
return;
+
+ // inverse transform parameters
+ inv_txfm_param.tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
+ inv_txfm_param.tx_size = tx_size;
+ inv_txfm_param.eob = p->eobs[block];
+ inv_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
+
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- switch (tx_size) {
- case TX_32X32:
- vp10_highbd_inv_txfm_add_32x32(dqcoeff, dst, pd->dst.stride,
- p->eobs[block], xd->bd, tx_type);
- break;
- case TX_16X16:
- vp10_highbd_inv_txfm_add_16x16(dqcoeff, dst, pd->dst.stride,
- p->eobs[block], xd->bd, tx_type);
- break;
- case TX_8X8:
- vp10_highbd_inv_txfm_add_8x8(dqcoeff, dst, pd->dst.stride,
- p->eobs[block], xd->bd, tx_type);
- break;
- case TX_4X4:
- // this is like vp10_short_idct4x4 but has a special case around eob<=1
- // which is significant (not just an optimization) for the lossless
- // case.
- vp10_highbd_inv_txfm_add_4x4(dqcoeff, dst, pd->dst.stride,
- p->eobs[block], xd->bd, tx_type,
- xd->lossless[xd->mi[0]->mbmi.segment_id]);
- break;
- default:
- assert(0 && "Invalid transform size");
- break;
- }
-
+ inv_txfm_param.bd = xd->bd;
+ highbd_inv_txfm_add(dqcoeff, dst, pd->dst.stride, &inv_txfm_param);
return;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-
- switch (tx_size) {
- case TX_32X32:
- vp10_inv_txfm_add_32x32(dqcoeff, dst, pd->dst.stride, p->eobs[block],
- tx_type);
- break;
- case TX_16X16:
- vp10_inv_txfm_add_16x16(dqcoeff, dst, pd->dst.stride, p->eobs[block],
- tx_type);
- break;
- case TX_8X8:
- vp10_inv_txfm_add_8x8(dqcoeff, dst, pd->dst.stride, p->eobs[block],
- tx_type);
- break;
- case TX_4X4:
- // this is like vp10_short_idct4x4 but has a special case around eob<=1
- // which is significant (not just an optimization) for the lossless
- // case.
- vp10_inv_txfm_add_4x4(dqcoeff, dst, pd->dst.stride, p->eobs[block],
- tx_type, xd->lossless[xd->mi[0]->mbmi.segment_id]);
- break;
- default:
- assert(0 && "Invalid transform size");
- break;
- }
+ inv_txfm_add(dqcoeff, dst, pd->dst.stride, &inv_txfm_param);
}
#if CONFIG_VAR_TX
@@ -932,6 +891,9 @@
int tx1d_size = get_tx1d_size(tx_size);
FWD_TXFM_PARAM fwd_txfm_param;
+ INV_TXFM_PARAM inv_txfm_param;
+
+ // foward transform parameters
fwd_txfm_param.tx_type = tx_type;
fwd_txfm_param.tx_size = tx_size;
fwd_txfm_param.fwd_txfm_opt = FWD_TXFM_OPT_NORMAL;
@@ -946,6 +908,7 @@
vp10_predict_intra_block(xd, bwl, bhl, tx_size, mode, dst, dst_stride,
dst, dst_stride, blk_col, blk_row, plane);
+
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vpx_highbd_subtract_block(tx1d_size, tx1d_size, src_diff, diff_stride,
@@ -960,9 +923,6 @@
qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan);
}
- if (*eob)
- vp10_highbd_inv_txfm_add_32x32(dqcoeff, dst, dst_stride, *eob, xd->bd,
- tx_type);
break;
case TX_16X16:
if (!x->skip_recode) {
@@ -971,9 +931,6 @@
pd->dequant, eob,
scan_order->scan, scan_order->iscan);
}
- if (*eob)
- vp10_highbd_inv_txfm_add_16x16(dqcoeff, dst, dst_stride, *eob, xd->bd,
- tx_type);
break;
case TX_8X8:
if (!x->skip_recode) {
@@ -982,9 +939,6 @@
pd->dequant, eob,
scan_order->scan, scan_order->iscan);
}
- if (*eob)
- vp10_highbd_inv_txfm_add_8x8(dqcoeff, dst, dst_stride, *eob, xd->bd,
- tx_type);
break;
case TX_4X4:
if (!x->skip_recode) {
@@ -993,20 +947,22 @@
pd->dequant, eob,
scan_order->scan, scan_order->iscan);
}
-
- if (*eob)
- // this is like vp10_short_idct4x4 but has a special case around
- // eob<=1 which is significant (not just an optimization) for the
- // lossless case.
- vp10_highbd_inv_txfm_add_4x4(dqcoeff, dst, dst_stride, *eob, xd->bd,
- tx_type, xd->lossless[mbmi->segment_id]);
break;
default:
assert(0);
return;
}
- if (*eob)
+ if (*eob) {
+ // inverse transform parameters
+ inv_txfm_param.tx_type = tx_type;
+ inv_txfm_param.tx_size = tx_size;
+ inv_txfm_param.eob = *eob;
+ inv_txfm_param.lossless = xd->lossless[mbmi->segment_id];
+ inv_txfm_param.bd = xd->bd;
+
+ highbd_inv_txfm_add(dqcoeff, dst, dst_stride, &inv_txfm_param);
*(args->skip) = 0;
+ }
return;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -1023,8 +979,6 @@
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
}
- if (*eob)
- vp10_inv_txfm_add_32x32(dqcoeff, dst, dst_stride, *eob, tx_type);
break;
case TX_16X16:
if (!x->skip_recode) {
@@ -1033,8 +987,6 @@
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
}
- if (*eob)
- vp10_inv_txfm_add_16x16(dqcoeff, dst, dst_stride, *eob, tx_type);
break;
case TX_8X8:
if (!x->skip_recode) {
@@ -1043,8 +995,6 @@
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
}
- if (*eob)
- vp10_inv_txfm_add_8x8(dqcoeff, dst, dst_stride, *eob, tx_type);
break;
case TX_4X4:
if (!x->skip_recode) {
@@ -1053,21 +1003,21 @@
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
}
-
- if (*eob) {
- // this is like vp10_short_idct4x4 but has a special case around eob<=1
- // which is significant (not just an optimization) for the lossless
- // case.
- vp10_inv_txfm_add_4x4(dqcoeff, dst, dst_stride, *eob, tx_type,
- xd->lossless[xd->mi[0]->mbmi.segment_id]);
- }
break;
default:
assert(0);
break;
}
- if (*eob)
+ if (*eob) {
+ // inverse transform parameters
+ inv_txfm_param.tx_type = tx_type;
+ inv_txfm_param.tx_size = tx_size;
+ inv_txfm_param.eob = *eob;
+ inv_txfm_param.lossless = xd->lossless[mbmi->segment_id];
+
+ inv_txfm_add(dqcoeff, dst, dst_stride, &inv_txfm_param);
*(args->skip) = 0;
+ }
}
void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {