Commit 3787b174 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Super transform - ported from nextgen branch

Various additional changes were made to make the experiment
compatible with misc_fixes.

derflr: +0.979%
hevcmr: +0.865%

Speed-wise with --enable-supertx the encoder is only about 10%
slower than without. Decoding impact is about 30% slowdown.

Note this does not work with ext-tx or var-tx yet. That is
a TODO.

Change-Id: If25af4241a7a9efbd28f58eda3c4f044c7a7ef4b
parent 717be7bc
......@@ -45,6 +45,8 @@ typedef enum {
#define IsInterpolatingFilter(filter) (1)
#endif // CONFIG_EXT_INTERP && SUPPORT_NONINTERPOLATING_FILTERS
#define MAXTXLEN 32
static INLINE int is_inter_mode(PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWMV;
}
......@@ -291,6 +293,14 @@ static const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES] = {
ADST_ADST, // TM
};
#if CONFIG_SUPERTX
static INLINE int supertx_enabled(const MB_MODE_INFO *mbmi) {
return (int)mbmi->tx_size >
VPXMIN(b_width_log2_lookup[mbmi->sb_type],
b_height_log2_lookup[mbmi->sb_type]);
}
#endif // CONFIG_SUPERTX
#if CONFIG_EXT_TX
#define ALLOW_INTRA_EXT_TX 1
......@@ -469,8 +479,18 @@ static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize,
static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi,
const struct macroblockd_plane *pd) {
#if CONFIG_SUPERTX
if (!supertx_enabled(mbmi)) {
return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type, pd->subsampling_x,
pd->subsampling_y);
} else {
return uvsupertx_size_lookup[mbmi->tx_size][pd->subsampling_x]
[pd->subsampling_y];
}
#else
return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type, pd->subsampling_x,
pd->subsampling_y);
#endif // CONFIG_SUPERTX
}
static INLINE BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize,
......
......@@ -170,6 +170,21 @@ static const struct {
{0, 0 }, // 64X64 - {0b0000, 0b0000}
};
#if CONFIG_SUPERTX
static const TX_SIZE uvsupertx_size_lookup[TX_SIZES][2][2] = {
// ss_x == 0 ss_x == 0 ss_x == 1 ss_x == 1
// ss_y == 0 ss_y == 1 ss_y == 0 ss_y == 1
{{TX_4X4, TX_4X4}, {TX_4X4, TX_4X4}},
{{TX_8X8, TX_4X4}, {TX_4X4, TX_4X4}},
{{TX_16X16, TX_8X8}, {TX_8X8, TX_8X8}},
{{TX_32X32, TX_16X16}, {TX_16X16, TX_16X16}},
};
static const int partition_supertx_context_lookup[PARTITION_TYPES] = {
-1, 0, 0, 1
};
#endif // CONFIG_SUPERTX
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -1174,6 +1174,14 @@ default_intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES]
};
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
static const vpx_prob default_supertx_prob[PARTITION_SUPERTX_CONTEXTS]
[TX_SIZES] = {
{ 1, 160, 160, 170 },
{ 1, 200, 200, 210 },
};
#endif // CONFIG_SUPERTX
// FIXME(someone) need real defaults here
static const struct segmentation_probs default_seg_probs = {
{ 128, 128, 128, 128, 128, 128, 128 },
......@@ -1208,6 +1216,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
vp10_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
vp10_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
vp10_copy(fc->supertx_prob, default_supertx_prob);
#endif // CONFIG_SUPERTX
vp10_copy(fc->seg.tree_probs, default_seg_probs.tree_probs);
vp10_copy(fc->seg.pred_probs, default_seg_probs.pred_probs);
#if CONFIG_EXT_INTRA
......@@ -1346,6 +1357,16 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
}
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
int j;
for (j = 1; j < TX_SIZES; ++j) {
fc->supertx_prob[i][j] = mode_mv_merge_probs(pre_fc->supertx_prob[i][j],
counts->supertx[i][j]);
}
}
#endif // CONFIG_SUPERTX
if (cm->seg.temporal_update) {
for (i = 0; i < PREDICTION_PROBS; i++)
fc->seg.pred_probs[i] = mode_mv_merge_probs(pre_fc->seg.pred_probs[i],
......
......@@ -84,6 +84,9 @@ typedef struct frame_contexts {
vpx_prob intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
[TX_TYPES - 1];
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
vpx_prob supertx_prob[PARTITION_SUPERTX_CONTEXTS][TX_SIZES];
#endif // CONFIG_SUPERTX
struct segmentation_probs seg;
#if CONFIG_EXT_INTRA
vpx_prob ext_intra_probs[PLANE_TYPES];
......@@ -122,6 +125,10 @@ typedef struct FRAME_COUNTS {
unsigned int intra_ext_tx[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
[TX_TYPES];
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
unsigned int supertx[PARTITION_SUPERTX_CONTEXTS][TX_SIZES][2];
unsigned int supertx_size[TX_SIZES];
#endif // CONFIG_SUPERTX
struct seg_counts seg;
#if CONFIG_EXT_INTRA
unsigned int ext_intra[PLANE_TYPES][2];
......
......@@ -246,6 +246,11 @@ typedef TX_SIZE TXFM_CONTEXT;
#define COMP_REFS 2
#endif // CONFIG_EXT_REFS
#if CONFIG_SUPERTX
#define PARTITION_SUPERTX_CONTEXTS 2
#define MAX_SUPERTX_BLOCK_SIZE BLOCK_32X32
#endif // CONFIG_SUPERTX
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -787,10 +787,18 @@ static void build_masks(const loop_filter_info_n *const lfi_n,
// we only update u and v masks on the first block.
static void build_y_mask(const loop_filter_info_n *const lfi_n,
const MODE_INFO *mi, const int shift_y,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif // CONFIG_SUPERTX
LOOP_FILTER_MASK *lfm) {
const MB_MODE_INFO *mbmi = &mi->mbmi;
const BLOCK_SIZE block_size = mbmi->sb_type;
const TX_SIZE tx_size_y = mbmi->tx_size;
#if CONFIG_SUPERTX
const BLOCK_SIZE block_size =
supertx_enabled ? (BLOCK_SIZE)(3 * tx_size_y) : mbmi->sb_type;
#else
const BLOCK_SIZE block_size = mbmi->sb_type;
#endif
const int filter_level = get_filter_level(lfi_n, mbmi);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
uint64_t *const above_y = &lfm->above_y[tx_size_y];
......@@ -899,6 +907,10 @@ void vp10_setup_mask(VP10_COMMON *const cm, const int mi_row, const int mi_col,
break;
case BLOCK_32X16:
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
#if CONFIG_SUPERTX
if (supertx_enabled(&mip[0]->mbmi))
break;
#endif
if (mi_32_row_offset + 2 >= max_rows)
continue;
mip2 = mip + mode_info_stride * 2;
......@@ -906,12 +918,22 @@ void vp10_setup_mask(VP10_COMMON *const cm, const int mi_row, const int mi_col,
break;
case BLOCK_16X32:
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
#if CONFIG_SUPERTX
if (supertx_enabled(&mip[0]->mbmi))
break;
#endif
if (mi_32_col_offset + 2 >= max_cols)
continue;
mip2 = mip + 2;
build_masks(lfi_n, mip2[0], shift_y + 2, shift_uv + 1, lfm);
break;
default:
#if CONFIG_SUPERTX
if (mip[0]->mbmi.tx_size == TX_32X32) {
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
break;
}
#endif
for (idx_16 = 0; idx_16 < 4; mip += offset_16[idx_16], ++idx_16) {
const int shift_y = shift_32_y[idx_32] + shift_16_y[idx_16];
const int shift_uv = shift_32_uv[idx_32] + shift_16_uv[idx_16];
......@@ -928,23 +950,45 @@ void vp10_setup_mask(VP10_COMMON *const cm, const int mi_row, const int mi_col,
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
break;
case BLOCK_16X8:
#if CONFIG_SUPERTX
if (supertx_enabled(&mip[0]->mbmi))
break;
#endif
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
if (mi_16_row_offset + 1 >= max_rows)
continue;
mip2 = mip + mode_info_stride;
build_y_mask(lfi_n, mip2[0], shift_y+8, lfm);
build_y_mask(lfi_n, mip2[0], shift_y+8,
#if CONFIG_SUPERTX
0,
#endif
lfm);
break;
case BLOCK_8X16:
#if CONFIG_SUPERTX
if (supertx_enabled(&mip[0]->mbmi))
break;
#endif
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
if (mi_16_col_offset +1 >= max_cols)
continue;
mip2 = mip + 1;
build_y_mask(lfi_n, mip2[0], shift_y+1, lfm);
build_y_mask(lfi_n, mip2[0], shift_y+1,
#if CONFIG_SUPERTX
0,
#endif
lfm);
break;
default: {
const int shift_y = shift_32_y[idx_32] +
shift_16_y[idx_16] +
shift_8_y[0];
#if CONFIG_SUPERTX
if (mip[0]->mbmi.tx_size == TX_16X16) {
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
break;
}
#endif
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
mip += offset[0];
for (idx_8 = 1; idx_8 < 4; mip += offset[idx_8], ++idx_8) {
......@@ -959,7 +1003,11 @@ void vp10_setup_mask(VP10_COMMON *const cm, const int mi_row, const int mi_col,
if (mi_8_col_offset >= max_cols ||
mi_8_row_offset >= max_rows)
continue;
build_y_mask(lfi_n, mip[0], shift_y, lfm);
build_y_mask(lfi_n, mip[0], shift_y,
#if CONFIG_SUPERTX
supertx_enabled(&mip[0]->mbmi),
#endif
lfm);
}
break;
}
......
......@@ -264,3 +264,227 @@ void vp10_setup_pre_planes(MACROBLOCKD *xd, int idx,
}
}
}
#if CONFIG_SUPERTX
static const uint8_t mask_8[8] = {
64, 64, 62, 52, 12, 2, 0, 0
};
static const uint8_t mask_16[16] = {
63, 62, 60, 58, 55, 50, 43, 36, 28, 21, 14, 9, 6, 4, 2, 1
};
static const uint8_t mask_32[32] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 61, 57, 52, 45, 36,
28, 19, 12, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static const uint8_t mask_8_uv[8] = {
64, 64, 62, 52, 12, 2, 0, 0
};
static const uint8_t mask_16_uv[16] = {
64, 64, 64, 64, 61, 53, 45, 36, 28, 19, 11, 3, 0, 0, 0, 0
};
static const uint8_t mask_32_uv[32] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 60, 54, 46, 36,
28, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static void generate_1dmask(int length, uint8_t *mask, int plane) {
switch (length) {
case 8:
memcpy(mask, plane ? mask_8_uv : mask_8, length);
break;
case 16:
memcpy(mask, plane ? mask_16_uv : mask_16, length);
break;
case 32:
memcpy(mask, plane ? mask_32_uv : mask_32, length);
break;
default:
assert(0);
}
}
void vp10_build_masked_inter_predictor_complex(
MACROBLOCKD *xd,
uint8_t *dst, int dst_stride, uint8_t *dst2, int dst2_stride,
const struct macroblockd_plane *pd, int mi_row, int mi_col,
int mi_row_ori, int mi_col_ori, BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
PARTITION_TYPE partition, int plane) {
int i, j;
uint8_t mask[MAXTXLEN];
int top_w = 4 << b_width_log2_lookup[top_bsize],
top_h = 4 << b_height_log2_lookup[top_bsize];
int w = 4 << b_width_log2_lookup[bsize], h = 4 << b_height_log2_lookup[bsize];
int w_offset = (mi_col - mi_col_ori) << 3,
h_offset = (mi_row - mi_row_ori) << 3;
#if CONFIG_VP9_HIGHBITDEPTH
uint16_t *dst16= CONVERT_TO_SHORTPTR(dst);
uint16_t *dst216 = CONVERT_TO_SHORTPTR(dst2);
int b_hdb = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? 1 : 0;
#endif // CONFIG_VP9_HIGHBITDEPTH
top_w >>= pd->subsampling_x;
top_h >>= pd->subsampling_y;
w >>= pd->subsampling_x;
h >>= pd->subsampling_y;
w_offset >>= pd->subsampling_x;
h_offset >>= pd->subsampling_y;
switch (partition) {
case PARTITION_HORZ:
{
#if CONFIG_VP9_HIGHBITDEPTH
if (b_hdb) {
uint16_t *dst_tmp = dst16 + h_offset * dst_stride;
uint16_t *dst2_tmp = dst216 + h_offset * dst2_stride;
generate_1dmask(h, mask + h_offset,
plane && xd->plane[plane].subsampling_y);
for (i = h_offset; i < h_offset + h; i++) {
for (j = 0; j < top_w; j++) {
const int m = mask[i]; assert(m >= 0 && m <= 64);
if (m == 64)
continue;
if (m == 0)
dst_tmp[j] = dst2_tmp[j];
else
dst_tmp[j] = (dst_tmp[j] * m + dst2_tmp[j] * (64 - m) + 32) >> 6;
}
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
for (; i < top_h; i ++) {
memcpy(dst_tmp, dst2_tmp, top_w * sizeof(uint16_t));
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
uint8_t *dst_tmp = dst + h_offset * dst_stride;
uint8_t *dst2_tmp = dst2 + h_offset * dst2_stride;
generate_1dmask(h, mask + h_offset,
plane && xd->plane[plane].subsampling_y);
for (i = h_offset; i < h_offset + h; i++) {
for (j = 0; j < top_w; j++) {
const int m = mask[i]; assert(m >= 0 && m <= 64);
if (m == 64)
continue;
if (m == 0)
dst_tmp[j] = dst2_tmp[j];
else
dst_tmp[j] = (dst_tmp[j] * m + dst2_tmp[j] * (64 - m) + 32) >> 6;
}
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
for (; i < top_h; i ++) {
memcpy(dst_tmp, dst2_tmp, top_w * sizeof(uint8_t));
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
#if CONFIG_VP9_HIGHBITDEPTH
}
#endif // CONFIG_VP9_HIGHBITDEPTH
}
break;
case PARTITION_VERT:
{
#if CONFIG_VP9_HIGHBITDEPTH
if (b_hdb) {
uint16_t *dst_tmp = dst16;
uint16_t *dst2_tmp = dst216;
generate_1dmask(w, mask + w_offset,
plane && xd->plane[plane].subsampling_x);
for (i = 0; i < top_h; i++) {
for (j = w_offset; j < w_offset + w; j++) {
const int m = mask[j]; assert(m >= 0 && m <= 64);
if (m == 64)
continue;
if (m == 0)
dst_tmp[j] = dst2_tmp[j];
else
dst_tmp[j] = (dst_tmp[j] * m + dst2_tmp[j] * (64 - m) + 32) >> 6;
}
memcpy(dst_tmp + j, dst2_tmp + j,
(top_w - w_offset - w) * sizeof(uint16_t));
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
uint8_t *dst_tmp = dst;
uint8_t *dst2_tmp = dst2;
generate_1dmask(w, mask + w_offset,
plane && xd->plane[plane].subsampling_x);
for (i = 0; i < top_h; i++) {
for (j = w_offset; j < w_offset + w; j++) {
const int m = mask[j]; assert(m >= 0 && m <= 64);
if (m == 64)
continue;
if (m == 0)
dst_tmp[j] = dst2_tmp[j];
else
dst_tmp[j] = (dst_tmp[j] * m + dst2_tmp[j] * (64 - m) + 32) >> 6;
}
memcpy(dst_tmp + j, dst2_tmp + j,
(top_w - w_offset - w) * sizeof(uint8_t));
dst_tmp += dst_stride;
dst2_tmp += dst2_stride;
}
#if CONFIG_VP9_HIGHBITDEPTH
}
#endif // CONFIG_VP9_HIGHBITDEPTH
}
break;
default:
assert(0);
}
(void) xd;
}
void vp10_build_inter_predictors_sb_sub8x8(MACROBLOCKD *xd,
int mi_row, int mi_col,
BLOCK_SIZE bsize, int block) {
// Prediction function used in supertx:
// Use the mv at current block (which is less than 8x8)
// to get prediction of a block located at (mi_row, mi_col) at size of bsize
// bsize can be larger than 8x8.
// block (0-3): the sub8x8 location of current block
int plane;
const int mi_x = mi_col * MI_SIZE;
const int mi_y = mi_row * MI_SIZE;
// For sub8x8 uv:
// Skip uv prediction in supertx except the first block (block = 0)
int max_plane = block ? 1 : MAX_MB_PLANE;
for (plane = 0; plane < max_plane; plane++) {
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize,
&xd->plane[plane]);
const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
const int bw = 4 * num_4x4_w;
const int bh = 4 * num_4x4_h;
build_inter_predictors(xd, plane, block, bw, bh,
0, 0, bw, bh,
mi_x, mi_y);
}
}
#endif // CONFIG_SUPERTX
......@@ -153,25 +153,39 @@ static INLINE MV average_split_mvs(const struct macroblockd_plane *pd,
}
void build_inter_predictors(MACROBLOCKD *xd, int plane, int block,
int bw, int bh,
int x, int y, int w, int h,
int mi_x, int mi_y);
int bw, int bh,
int x, int y, int w, int h,
int mi_x, int mi_y);
void vp10_build_inter_predictor_sub8x8(MACROBLOCKD *xd, int plane,
int i, int ir, int ic,
int mi_row, int mi_col);
void vp10_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize);
BLOCK_SIZE bsize);
void vp10_build_inter_predictors_sbp(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize, int plane);
BLOCK_SIZE bsize, int plane);
void vp10_build_inter_predictors_sbuv(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize);
BLOCK_SIZE bsize);
void vp10_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize);
BLOCK_SIZE bsize);
#if CONFIG_SUPERTX
void vp10_build_inter_predictors_sb_sub8x8(MACROBLOCKD *xd,
int mi_row, int mi_col,
BLOCK_SIZE bsize, int block);
struct macroblockd_plane;
void vp10_build_masked_inter_predictor_complex(
MACROBLOCKD *xd,
uint8_t *dst, int dst_stride, uint8_t *dst2, int dst2_stride,
const struct macroblockd_plane *pd, int mi_row, int mi_col,
int mi_row_ori, int mi_col_ori, BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
PARTITION_TYPE partition, int plane);
#endif // CONFIG_SUPERTX
void vp10_build_inter_predictor(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
......
......@@ -477,6 +477,15 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
}
#endif // CONFIG_EXT_TX
#if CONFIG_SUPERTX
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; i++)
for (j = 0; j < TX_SIZES; j++)
for (k = 0; k < 2; k++)
cm->counts.supertx[i][j][k] += counts->supertx[i][j][k];
for (i = 0; i < TX_SIZES; i++)
cm->counts.supertx_size[i] += counts->supertx_size[i];
#endif // CONFIG_SUPERTX
for (i = 0; i < PREDICTION_PROBS; i++)
for (j = 0; j < 2; j++)
cm->counts.seg.pred[i][j] += counts->seg.pred[i][j];
......
This diff is collapsed.
......@@ -929,98 +929,117 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
static void read_inter_frame_mode_info(VP10Decoder *const pbi,
MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif // CONFIG_SUPERTX
int mi_row, int mi_col, vpx_reader *r) {
VP10_COMMON *const cm = &pbi->common;
MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO *const mbmi = &mi->mbmi;
int inter_block;
int inter_block = 1;
#if CONFIG_VAR_TX
BLOCK_SIZE bsize = mbmi->sb_type;
#endif
#endif // CONFIG_VAR_TX
#if CONFIG_SUPERTX
(void) supertx_enabled;
#endif // CONFIG_SUPERTX
mbmi->mv[0].as_int = 0;
mbmi->mv[1].as_int = 0;
mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
#if CONFIG_SUPERTX
if (!supertx_enabled) {
#endif // CONFIG_SUPERTX
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
#if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col;
xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
!mbmi->skip && inter_block) {
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
const int bs = num_4x4_blocks_wide_lookup[txb_size];
const int width = num_4x4_blocks_wide_lookup[bsize];
const int height = num_4x4_blocks_high_lookup[bsize];
int idx, idy;
for (idy = 0; idy < height; idy += bs)
for (idx = 0; idx < width; idx += bs)
read_tx_size_inter(cm, xd, mbmi, xd->counts, max_tx_size,
idy, idx, r);
if (xd->counts) {
const int ctx = get_tx_size_context(xd);
++get_tx_counts(max_tx_size, ctx, &xd->counts->tx)[mbmi->tx_size];
}
} else {
mbmi->tx_size = read_tx_size(cm, xd, !mbmi->skip || !inter_block, r);
if (inter_block) {
xd->above_txfm_context = cm->above_txfm_context + mi_col;
xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
!mbmi->skip && inter_block) {
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
const int bs = num_4x4_blocks_wide_lookup[txb_size];
const int width = num_4x4_blocks_wide_lookup[bsize];
const int height = num_4x4_blocks_high_lookup[bsize];
int idx, idy;
for (idy = 0; idy < height; ++idy)
for (idx = 0; idx < width; ++idx)
mbmi->inter_tx_size[(idy >> 1) * 8 + (idx >> 1)] = mbmi->tx_size;
}
for (idy = 0; idy < height; idy += bs)
for (idx = 0; idx < width; idx += bs)
read_tx_size_inter(cm, xd, mbmi, xd->counts, max_tx_size,
idy, idx, r);