From: Dmitry Kovalev Date: Wed, 24 Jul 2013 19:55:45 +0000 (-0700) Subject: Adding condition inside get_tx_type_{4x4, 8x8, 16x16}. X-Git-Tag: v1.3.0~752^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9139ee0908764ab0455f3a991cfaf57ae3eb5e80;p=libvpx Adding condition inside get_tx_type_{4x4, 8x8, 16x16}. Adding plane type check condition because it was always used outside of get_tx_type_{4x4, 8x8, 16x16}. Change-Id: I02f0bbfee8063474865bd903eb25b54d26e07230 --- diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index dc20f2ad2..129711412 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -359,23 +359,30 @@ static BLOCK_SIZE_TYPE get_subsize(BLOCK_SIZE_TYPE bsize, extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; -static INLINE TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) { - MODE_INFO *const mi = xd->mode_info_context; - MB_MODE_INFO *const mbmi = &mi->mbmi; - - if (xd->lossless || mbmi->ref_frame[0] != INTRA_FRAME) +static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, + const MACROBLOCKD *xd, int ib) { + const MODE_INFO *const mi = xd->mode_info_context; + const MB_MODE_INFO *const mbmi = &mi->mbmi; + + if (plane_type != PLANE_TYPE_Y_WITH_DC || + xd->lossless || + mbmi->ref_frame[0] != INTRA_FRAME) return DCT_DCT; return mode2txfm_map[mbmi->sb_type < BLOCK_SIZE_SB8X8 ? mi->bmi[ib].as_mode : mbmi->mode]; } -static INLINE TX_TYPE get_tx_type_8x8(const MACROBLOCKD *xd) { - return mode2txfm_map[xd->mode_info_context->mbmi.mode]; +static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type, + const MACROBLOCKD *xd) { + return plane_type == PLANE_TYPE_Y_WITH_DC ? + mode2txfm_map[xd->mode_info_context->mbmi.mode] : DCT_DCT; } -static INLINE TX_TYPE get_tx_type_16x16(const MACROBLOCKD *xd) { - return mode2txfm_map[xd->mode_info_context->mbmi.mode]; +static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, + const MACROBLOCKD *xd) { + return plane_type == PLANE_TYPE_Y_WITH_DC ? + mode2txfm_map[xd->mode_info_context->mbmi.mode] : DCT_DCT; } static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) { diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 9928c9f4e..ffec8ea44 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -90,32 +90,32 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, struct macroblockd_plane *pd = &xd->plane[plane]; int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); const int stride = pd->dst.stride; + const int eob = pd->eobs[block]; const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, block, ss_txfrm_size); uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane, raster_block, pd->dst.buf, stride); - TX_TYPE tx_type; - switch (ss_txfrm_size / 2) { - case TX_4X4: - tx_type = plane == 0 ? get_tx_type_4x4(xd, raster_block) : DCT_DCT; + case TX_4X4: { + const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block); if (tx_type == DCT_DCT) - xd->itxm_add(qcoeff, dst, stride, pd->eobs[block]); + xd->itxm_add(qcoeff, dst, stride, eob); else - vp9_iht_add_c(tx_type, qcoeff, dst, stride, pd->eobs[block]); + vp9_iht_add_c(tx_type, qcoeff, dst, stride, eob); break; + } case TX_8X8: - tx_type = plane == 0 ? get_tx_type_8x8(xd) : DCT_DCT; - vp9_iht_add_8x8_c(tx_type, qcoeff, dst, stride, pd->eobs[block]); + vp9_iht_add_8x8_c(get_tx_type_8x8(pd->plane_type, xd), qcoeff, dst, + stride, eob); break; case TX_16X16: - tx_type = plane == 0 ? get_tx_type_16x16(xd) : DCT_DCT; - vp9_iht_add_16x16_c(tx_type, qcoeff, dst, stride, pd->eobs[block]); + vp9_iht_add_16x16_c(get_tx_type_16x16(pd->plane_type, xd), qcoeff, dst, + stride, eob); break; case TX_32X32: - vp9_idct_add_32x32(qcoeff, dst, stride, pd->eobs[block]); + vp9_idct_add_32x32(qcoeff, dst, stride, eob); break; } } diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index fa817444e..709d69e15 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -127,27 +127,21 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, switch (txfm_size) { default: case TX_4X4: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_4x4(xd, block_idx) : DCT_DCT; - scan = get_scan_4x4(tx_type); + scan = get_scan_4x4(get_tx_type_4x4(type, xd, block_idx)); above_ec = A[0] != 0; left_ec = L[0] != 0; band_translate = vp9_coefband_trans_4x4; break; } case TX_8X8: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_8x8(xd) : DCT_DCT; - scan = get_scan_8x8(tx_type); + scan = get_scan_8x8(get_tx_type_8x8(type, xd)); above_ec = (A[0] + A[1]) != 0; left_ec = (L[0] + L[1]) != 0; band_translate = vp9_coefband_trans_8x8plus; break; } case TX_16X16: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_16x16(xd) : DCT_DCT; - scan = get_scan_16x16(tx_type); + scan = get_scan_16x16(get_tx_type_16x16(type, xd)); above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; band_translate = vp9_coefband_trans_8x8plus; diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 4f9a4509b..66e35a991 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -154,27 +154,21 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb, qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); switch (tx_size) { default: - case TX_4X4: { - const TX_TYPE tx_type = plane == 0 ? get_tx_type_4x4(xd, ib) : DCT_DCT; + case TX_4X4: default_eob = 16; - scan = get_scan_4x4(tx_type); + scan = get_scan_4x4(get_tx_type_4x4(type, xd, ib)); band_translate = vp9_coefband_trans_4x4; break; - } - case TX_8X8: { - const TX_TYPE tx_type = plane == 0 ? get_tx_type_8x8(xd) : DCT_DCT; - scan = get_scan_8x8(tx_type); + case TX_8X8: + scan = get_scan_8x8(get_tx_type_8x8(type, xd)); default_eob = 64; band_translate = vp9_coefband_trans_8x8plus; break; - } - case TX_16X16: { - const TX_TYPE tx_type = plane == 0 ? get_tx_type_16x16(xd) : DCT_DCT; - scan = get_scan_16x16(tx_type); + case TX_16X16: + scan = get_scan_16x16(get_tx_type_16x16(type, xd)); default_eob = 256; band_translate = vp9_coefband_trans_8x8plus; break; - } case TX_32X32: scan = vp9_default_scan_32x32; default_eob = 1024; @@ -644,7 +638,7 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride); break; case TX_16X16: - tx_type = plane == 0 ? get_tx_type_16x16(xd) : DCT_DCT; + tx_type = get_tx_type_16x16(pd->plane_type, xd); scan = get_scan_16x16(tx_type); iscan = get_iscan_16x16(tx_type); mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; @@ -673,7 +667,7 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, } break; case TX_8X8: - tx_type = plane == 0 ? get_tx_type_8x8(xd) : DCT_DCT; + tx_type = get_tx_type_8x8(pd->plane_type, xd); scan = get_scan_8x8(tx_type); iscan = get_iscan_8x8(tx_type); mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; @@ -702,7 +696,7 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, } break; case TX_4X4: - tx_type = plane == 0 ? get_tx_type_4x4(xd, block) : DCT_DCT; + tx_type = get_tx_type_4x4(pd->plane_type, xd, block); scan = get_scan_4x4(tx_type); iscan = get_iscan_4x4(tx_type); if (mbmi->sb_type < BLOCK_SIZE_SB8X8 && plane == 0) { diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index dcb09d0ff..b20302b7b 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -794,21 +794,24 @@ static void super_block_yrd_for_txfm(VP9_COMMON *const cm, MACROBLOCK *x, sizeof(ENTROPY_CONTEXT) * bw); vpx_memcpy(&args.t_left, pd->left_context, sizeof(ENTROPY_CONTEXT) * bh); - get_scan_nb_4x4(get_tx_type_4x4(xd, 0), &args.scan, &args.nb); + get_scan_nb_4x4(get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, 0), + &args.scan, &args.nb); break; case TX_8X8: for (i = 0; i < bw; i += 2) args.t_above[i] = !!*(uint16_t *)&pd->above_context[i]; for (i = 0; i < bh; i += 2) args.t_left[i] = !!*(uint16_t *)&pd->left_context[i]; - get_scan_nb_8x8(get_tx_type_8x8(xd), &args.scan, &args.nb); + get_scan_nb_8x8(get_tx_type_8x8(PLANE_TYPE_Y_WITH_DC, xd), + &args.scan, &args.nb); break; case TX_16X16: for (i = 0; i < bw; i += 4) args.t_above[i] = !!*(uint32_t *)&pd->above_context[i]; for (i = 0; i < bh; i += 4) args.t_left[i] = !!*(uint32_t *)&pd->left_context[i]; - get_scan_nb_16x16(get_tx_type_16x16(xd), &args.scan, &args.nb); + get_scan_nb_16x16(get_tx_type_16x16(PLANE_TYPE_Y_WITH_DC, xd), + &args.scan, &args.nb); break; case TX_32X32: for (i = 0; i < bw; i += 8) @@ -1246,7 +1249,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, src, src_stride, dst, dst_stride); - tx_type = get_tx_type_4x4(xd, block); + tx_type = get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, block); if (tx_type != DCT_DCT) { vp9_short_fht4x4(src_diff, coeff, 8, tx_type); x->quantize_b_4x4(x, block, tx_type, 16); @@ -1255,7 +1258,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, x->quantize_b_4x4(x, block, tx_type, 16); } - scan = get_scan_4x4(get_tx_type_4x4(xd, block)); + scan = get_scan_4x4(get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, block)); ratey += cost_coeffs(cm, x, 0, block, PLANE_TYPE_Y_WITH_DC, tempa + idx, templ + idy, TX_4X4, scan, vp9_get_coef_neighbors_handle(scan)); diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 6b7cc47d8..6faa15886 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -104,7 +104,6 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, VP9_COMP *cpi = args->cpi; MACROBLOCKD *xd = args->xd; TOKENEXTRA **tp = args->tp; - PLANE_TYPE type = plane ? PLANE_TYPE_UV : PLANE_TYPE_Y_WITH_DC; TX_SIZE tx_size = ss_txfrm_size / 2; int dry_run = args->dry_run; @@ -113,6 +112,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, int c = 0, rc = 0; TOKENEXTRA *t = *tp; /* store tokens starting here */ const int eob = xd->plane[plane].eobs[block]; + const PLANE_TYPE type = xd->plane[plane].plane_type; const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); const BLOCK_SIZE_TYPE sb_type = (mbmi->sb_type < BLOCK_SIZE_SB8X8) ? BLOCK_SIZE_SB8X8 : mbmi->sb_type; @@ -138,36 +138,27 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, coef_probs = cpi->common.fc.coef_probs[tx_size]; switch (tx_size) { default: - case TX_4X4: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_4x4(xd, block) : DCT_DCT; + case TX_4X4: above_ec = A[0] != 0; left_ec = L[0] != 0; seg_eob = 16; - scan = get_scan_4x4(tx_type); + scan = get_scan_4x4(get_tx_type_4x4(type, xd, block)); band_translate = vp9_coefband_trans_4x4; break; - } - case TX_8X8: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_8x8(xd) : DCT_DCT; + case TX_8X8: above_ec = (A[0] + A[1]) != 0; left_ec = (L[0] + L[1]) != 0; seg_eob = 64; - scan = get_scan_8x8(tx_type); + scan = get_scan_8x8(get_tx_type_8x8(type, xd)); band_translate = vp9_coefband_trans_8x8plus; break; - } - case TX_16X16: { - const TX_TYPE tx_type = type == PLANE_TYPE_Y_WITH_DC ? - get_tx_type_16x16(xd) : DCT_DCT; + case TX_16X16: above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; seg_eob = 256; - scan = get_scan_16x16(tx_type); + scan = get_scan_16x16(get_tx_type_16x16(type, xd)); band_translate = vp9_coefband_trans_8x8plus; break; - } case TX_32X32: above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0; left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0;