diff --git a/vp10/encoder/block.h b/vp10/encoder/block.h index 9eff31a2e..d8a5d911d 100644 --- a/vp10/encoder/block.h +++ b/vp10/encoder/block.h @@ -133,7 +133,6 @@ struct macroblock { // 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, diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c index c3b6265e3..8e5dfae91 100644 --- a/vp10/encoder/encodeframe.c +++ b/vp10/encoder/encodeframe.c @@ -2697,14 +2697,8 @@ static void encode_frame_internal(VP10_COMP *cpi) { 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; diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c index 65692ddd8..9d65abe97 100644 --- a/vp10/encoder/encodemb.c +++ b/vp10/encoder/encodemb.c @@ -367,7 +367,11 @@ void vp10_xform_quant_fp(MACROBLOCK *x, int plane, int block, 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 @@ void vp10_xform_quant_fp(MACROBLOCK *x, int plane, int block, 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 @@ void vp10_xform_quant_dc(MACROBLOCK *x, int plane, int block, 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 @@ void vp10_xform_quant_dc(MACROBLOCK *x, int plane, int block, 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_xform_quant_dc(MACROBLOCK *x, int plane, int block, } } -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 @@ static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff, #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 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, 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 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, 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 @@ void vp10_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, 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 @@ void vp10_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, 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, diff --git a/vp10/encoder/encodemb.h b/vp10/encoder/encodemb.h index 928be6c5e..62a7db4a2 100644 --- a/vp10/encoder/encodemb.h +++ b/vp10/encoder/encodemb.h @@ -39,16 +39,12 @@ void vp10_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, 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 diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c index 6ae4c5ebe..7dc33f44f 100644 --- a/vp10/encoder/encoder.c +++ b/vp10/encoder/encoder.c @@ -4086,19 +4086,14 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, } 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); diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index 20b7d50ec..1772775ce 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -798,8 +798,7 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, 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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, 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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, 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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, 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 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, 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, @@ -1301,6 +1301,16 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, vp10_build_inter_predictor_sub8x8(xd, 0, i, ir, ic, mi_row, mi_col); +#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( @@ -1325,8 +1335,8 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, 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) {