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
This commit is contained in:
Angie Chiang
2015-11-19 18:27:09 -08:00
parent 96baa73ed9
commit a245d9f88c
3 changed files with 111 additions and 85 deletions

View File

@@ -1244,3 +1244,66 @@ void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
} }
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #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

View File

@@ -24,6 +24,16 @@
extern "C" { extern "C" {
#endif #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 void (*transform_1d)(const tran_low_t*, tran_low_t*);
typedef struct { typedef struct {
@@ -51,7 +61,8 @@ void vp10_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
int stride, int eob, TX_TYPE tx_type); int stride, int eob, TX_TYPE tx_type);
void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
int stride, int eob, TX_TYPE tx_type); 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 #if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride, void vp10_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
int eob, int bd); int eob, int bd);
@@ -74,6 +85,8 @@ void vp10_highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
int stride, int eob, int bd, int stride, int eob, int bd,
TX_TYPE tx_type); 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 #endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"

View File

@@ -588,7 +588,7 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
uint8_t *dst; uint8_t *dst;
ENTROPY_CONTEXT *a, *l; 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 #if CONFIG_VAR_TX
int i; int i;
const int bwl = b_width_log2_lookup[plane_bsize]; const int bwl = b_width_log2_lookup[plane_bsize];
@@ -697,62 +697,21 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
if (p->eobs[block] == 0) if (p->eobs[block] == 0)
return; 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 CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
switch (tx_size) { inv_txfm_param.bd = xd->bd;
case TX_32X32: highbd_inv_txfm_add(dqcoeff, dst, pd->dst.stride, &inv_txfm_param);
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;
}
return; return;
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
inv_txfm_add(dqcoeff, dst, pd->dst.stride, &inv_txfm_param);
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;
}
} }
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
@@ -932,6 +891,9 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
int tx1d_size = get_tx1d_size(tx_size); int tx1d_size = get_tx1d_size(tx_size);
FWD_TXFM_PARAM fwd_txfm_param; 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_type = tx_type;
fwd_txfm_param.tx_size = 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_NORMAL;
@@ -946,6 +908,7 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
vp10_predict_intra_block(xd, bwl, bhl, tx_size, mode, dst, dst_stride, vp10_predict_intra_block(xd, bwl, bhl, tx_size, mode, dst, dst_stride,
dst, dst_stride, blk_col, blk_row, plane); dst, dst_stride, blk_col, blk_row, plane);
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
vpx_highbd_subtract_block(tx1d_size, tx1d_size, src_diff, diff_stride, vpx_highbd_subtract_block(tx1d_size, tx1d_size, src_diff, diff_stride,
@@ -960,9 +923,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
qcoeff, dqcoeff, pd->dequant, eob, qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan); scan_order->scan, scan_order->iscan);
} }
if (*eob)
vp10_highbd_inv_txfm_add_32x32(dqcoeff, dst, dst_stride, *eob, xd->bd,
tx_type);
break; break;
case TX_16X16: case TX_16X16:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -971,9 +931,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, pd->dequant, eob,
scan_order->scan, scan_order->iscan); scan_order->scan, scan_order->iscan);
} }
if (*eob)
vp10_highbd_inv_txfm_add_16x16(dqcoeff, dst, dst_stride, *eob, xd->bd,
tx_type);
break; break;
case TX_8X8: case TX_8X8:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -982,9 +939,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, pd->dequant, eob,
scan_order->scan, scan_order->iscan); scan_order->scan, scan_order->iscan);
} }
if (*eob)
vp10_highbd_inv_txfm_add_8x8(dqcoeff, dst, dst_stride, *eob, xd->bd,
tx_type);
break; break;
case TX_4X4: case TX_4X4:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -993,20 +947,22 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, pd->dequant, eob,
scan_order->scan, scan_order->iscan); 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; break;
default: default:
assert(0); assert(0);
return; 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; *(args->skip) = 0;
}
return; return;
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
@@ -1023,8 +979,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, scan_order->scan, pd->dequant, eob, scan_order->scan,
scan_order->iscan); scan_order->iscan);
} }
if (*eob)
vp10_inv_txfm_add_32x32(dqcoeff, dst, dst_stride, *eob, tx_type);
break; break;
case TX_16X16: case TX_16X16:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -1033,8 +987,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, scan_order->scan, pd->dequant, eob, scan_order->scan,
scan_order->iscan); scan_order->iscan);
} }
if (*eob)
vp10_inv_txfm_add_16x16(dqcoeff, dst, dst_stride, *eob, tx_type);
break; break;
case TX_8X8: case TX_8X8:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -1043,8 +995,6 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, scan_order->scan, pd->dequant, eob, scan_order->scan,
scan_order->iscan); scan_order->iscan);
} }
if (*eob)
vp10_inv_txfm_add_8x8(dqcoeff, dst, dst_stride, *eob, tx_type);
break; break;
case TX_4X4: case TX_4X4:
if (!x->skip_recode) { if (!x->skip_recode) {
@@ -1053,22 +1003,22 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col,
pd->dequant, eob, scan_order->scan, pd->dequant, eob, scan_order->scan,
scan_order->iscan); 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; break;
default: default:
assert(0); assert(0);
break; 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; *(args->skip) = 0;
} }
}
void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
const MACROBLOCKD *const xd = &x->e_mbd; const MACROBLOCKD *const xd = &x->e_mbd;