Commit 331662e9 authored by Jingning Han's avatar Jingning Han
Browse files

Rework txfm_above and txfm_left context offset

Make the txfm_above and txfm_left be processed in the unit of
miniumum transform block size. Scale the transform block step
size with respect to the mode_info step size.

Change-Id: Iee4421e005db742cd4ff7899215560063e5f68e5
parent 70bd76e1
...@@ -168,7 +168,7 @@ int av1_alloc_context_buffers(AV1_COMMON *cm, int width, int height) { ...@@ -168,7 +168,7 @@ int av1_alloc_context_buffers(AV1_COMMON *cm, int width, int height) {
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
aom_free(cm->above_txfm_context); aom_free(cm->above_txfm_context);
cm->above_txfm_context = (TXFM_CONTEXT *)aom_calloc( cm->above_txfm_context = (TXFM_CONTEXT *)aom_calloc(
aligned_mi_cols, sizeof(*cm->above_txfm_context)); aligned_mi_cols << TX_UNIT_WIDE_LOG2, sizeof(*cm->above_txfm_context));
if (!cm->above_txfm_context) goto fail; if (!cm->above_txfm_context) goto fail;
#endif #endif
......
...@@ -1434,12 +1434,15 @@ static void get_filter_level_and_masks_non420( ...@@ -1434,12 +1434,15 @@ static void get_filter_level_and_masks_non420(
#endif #endif
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
TX_SIZE tx_size_r = AOMMIN(tx_size, cm->above_txfm_context[mi_col + c]); TX_SIZE tx_size_r = AOMMIN(
tx_size, cm->above_txfm_context[(mi_col + c) << TX_UNIT_WIDE_LOG2]);
TX_SIZE tx_size_c = TX_SIZE tx_size_c =
AOMMIN(tx_size, cm->left_txfm_context[(mi_row + r) & MAX_MIB_MASK]); AOMMIN(tx_size, cm->left_txfm_context[((mi_row + r) & MAX_MIB_MASK)
<< TX_UNIT_HIGH_LOG2]);
cm->above_txfm_context[mi_col + c] = tx_size; cm->above_txfm_context[(mi_col + c) << TX_UNIT_WIDE_LOG2] = tx_size;
cm->left_txfm_context[(mi_row + r) & MAX_MIB_MASK] = tx_size; cm->left_txfm_context[((mi_row + r) & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2] =
tx_size;
#else #else
TX_SIZE tx_size_c = txsize_horz_map[tx_size]; TX_SIZE tx_size_c = txsize_horz_map[tx_size];
TX_SIZE tx_size_r = txsize_vert_map[tx_size]; TX_SIZE tx_size_r = txsize_vert_map[tx_size];
...@@ -2189,12 +2192,12 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm, ...@@ -2189,12 +2192,12 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
int mi_row, mi_col; int mi_row, mi_col;
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
memset(cm->above_txfm_context, TX_SIZES, cm->mi_cols); memset(cm->above_txfm_context, TX_SIZES, cm->mi_cols << TX_UNIT_WIDE_LOG2);
#endif // CONFIG_VAR_TX #endif // CONFIG_VAR_TX
for (mi_row = start; mi_row < stop; mi_row += cm->mib_size) { for (mi_row = start; mi_row < stop; mi_row += cm->mib_size) {
MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride; MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
memset(cm->left_txfm_context, TX_SIZES, MAX_MIB_SIZE); memset(cm->left_txfm_context, TX_SIZES, MAX_MIB_SIZE << TX_UNIT_WIDE_LOG2);
#endif // CONFIG_VAR_TX #endif // CONFIG_VAR_TX
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += cm->mib_size) { for (mi_col = 0; mi_col < cm->mi_cols; mi_col += cm->mib_size) {
int plane; int plane;
......
...@@ -623,7 +623,7 @@ typedef struct macroblockd { ...@@ -623,7 +623,7 @@ typedef struct macroblockd {
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
TXFM_CONTEXT *above_txfm_context; TXFM_CONTEXT *above_txfm_context;
TXFM_CONTEXT *left_txfm_context; TXFM_CONTEXT *left_txfm_context;
TXFM_CONTEXT left_txfm_context_buffer[MAX_MIB_SIZE]; TXFM_CONTEXT left_txfm_context_buffer[2 * MAX_MIB_SIZE];
TX_SIZE max_tx_size; TX_SIZE max_tx_size;
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
......
...@@ -785,6 +785,9 @@ static const int tx_size_high_log2[TX_SIZES_ALL] = { ...@@ -785,6 +785,9 @@ static const int tx_size_high_log2[TX_SIZES_ALL] = {
3, 2, 4, 3, 5, 4, 4, 2, 5, 3 3, 2, 4, 3, 5, 4, 4, 2, 5, 3
}; };
#define TX_UNIT_WIDE_LOG2 (MI_SIZE_LOG2 - tx_size_wide_log2[0])
#define TX_UNIT_HIGH_LOG2 (MI_SIZE_LOG2 - tx_size_high_log2[0])
static const int tx_size_2d[TX_SIZES_ALL] = { static const int tx_size_2d[TX_SIZES_ALL] = {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
4, 4,
......
...@@ -386,7 +386,7 @@ typedef struct AV1Common { ...@@ -386,7 +386,7 @@ typedef struct AV1Common {
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
TXFM_CONTEXT *above_txfm_context; TXFM_CONTEXT *above_txfm_context;
TXFM_CONTEXT left_txfm_context[MAX_MIB_SIZE]; TXFM_CONTEXT left_txfm_context[2 * MAX_MIB_SIZE];
#endif #endif
int above_context_alloc_cols; int above_context_alloc_cols;
...@@ -877,7 +877,8 @@ static INLINE void av1_zero_above_context(AV1_COMMON *const cm, ...@@ -877,7 +877,8 @@ static INLINE void av1_zero_above_context(AV1_COMMON *const cm,
av1_zero_array(cm->above_seg_context + mi_col_start, aligned_width); av1_zero_array(cm->above_seg_context + mi_col_start, aligned_width);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
av1_zero_array(cm->above_txfm_context + mi_col_start, aligned_width); av1_zero_array(cm->above_txfm_context + (mi_col_start << TX_UNIT_WIDE_LOG2),
aligned_width << TX_UNIT_WIDE_LOG2);
#endif // CONFIG_VAR_TX #endif // CONFIG_VAR_TX
} }
...@@ -910,16 +911,16 @@ static INLINE void set_txfm_ctxs(TX_SIZE tx_size, int n8_w, int n8_h, int skip, ...@@ -910,16 +911,16 @@ static INLINE void set_txfm_ctxs(TX_SIZE tx_size, int n8_w, int n8_h, int skip,
bh = n8_h * MI_SIZE; bh = n8_h * MI_SIZE;
} }
set_txfm_ctx(xd->above_txfm_context, bw, n8_w); set_txfm_ctx(xd->above_txfm_context, bw, n8_w << TX_UNIT_WIDE_LOG2);
set_txfm_ctx(xd->left_txfm_context, bh, n8_h); set_txfm_ctx(xd->left_txfm_context, bh, n8_h << TX_UNIT_HIGH_LOG2);
} }
static INLINE void txfm_partition_update(TXFM_CONTEXT *above_ctx, static INLINE void txfm_partition_update(TXFM_CONTEXT *above_ctx,
TXFM_CONTEXT *left_ctx, TXFM_CONTEXT *left_ctx,
TX_SIZE tx_size, TX_SIZE txb_size) { TX_SIZE tx_size, TX_SIZE txb_size) {
BLOCK_SIZE bsize = txsize_to_bsize[txb_size]; BLOCK_SIZE bsize = txsize_to_bsize[txb_size];
int bh = mi_size_high[bsize]; int bh = mi_size_high[bsize] << TX_UNIT_HIGH_LOG2;
int bw = mi_size_wide[bsize]; int bw = mi_size_wide[bsize] << TX_UNIT_WIDE_LOG2;
uint8_t txw = tx_size_wide[tx_size]; uint8_t txw = tx_size_wide[tx_size];
uint8_t txh = tx_size_high[tx_size]; uint8_t txh = tx_size_high[tx_size];
int i; int i;
......
...@@ -345,8 +345,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -345,8 +345,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
const int tx_col = blk_col >> 1; const int tx_col = blk_col >> 1;
const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
TX_SIZE(*const inter_tx_size) TX_SIZE(*const inter_tx_size)
[MAX_MIB_SIZE] = [MAX_MIB_SIZE] =
...@@ -362,8 +362,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -362,8 +362,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
mbmi->min_tx_size = AOMMIN(mbmi->min_tx_size, get_min_tx_size(tx_size)); mbmi->min_tx_size = AOMMIN(mbmi->min_tx_size, get_min_tx_size(tx_size));
if (counts) ++counts->txfm_partition[ctx][0]; if (counts) ++counts->txfm_partition[ctx][0];
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
return; return;
} }
...@@ -384,8 +384,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -384,8 +384,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
inter_tx_size[idy][idx] = inter_tx_size[0][0]; inter_tx_size[idy][idx] = inter_tx_size[0][0];
mbmi->tx_size = sub_txs; mbmi->tx_size = sub_txs;
mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size); mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size);
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, sub_txs, tx_size); xd->left_txfm_context + blk_row, sub_txs, tx_size);
return; return;
} }
...@@ -405,8 +405,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -405,8 +405,8 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
mbmi->min_tx_size = AOMMIN(mbmi->min_tx_size, get_min_tx_size(tx_size)); mbmi->min_tx_size = AOMMIN(mbmi->min_tx_size, get_min_tx_size(tx_size));
if (counts) ++counts->txfm_partition[ctx][0]; if (counts) ++counts->txfm_partition[ctx][0];
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
} }
} }
#endif #endif
...@@ -2196,9 +2196,10 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi, ...@@ -2196,9 +2196,10 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r); inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
if (cm->tx_mode == TX_MODE_SELECT && if (cm->tx_mode == TX_MODE_SELECT &&
#if CONFIG_CB4X4 #if CONFIG_CB4X4
......
...@@ -362,22 +362,22 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -362,22 +362,22 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
if (depth == MAX_VARTX_DEPTH) { if (depth == MAX_VARTX_DEPTH) {
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
return; return;
} }
if (tx_size == mbmi->inter_tx_size[tx_row][tx_col]) { if (tx_size == mbmi->inter_tx_size[tx_row][tx_col]) {
aom_write(w, 0, cm->fc->txfm_partition_prob[ctx]); aom_write(w, 0, cm->fc->txfm_partition_prob[ctx]);
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
} else { } else {
const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
const int bsl = tx_size_wide_unit[sub_txs]; const int bsl = tx_size_wide_unit[sub_txs];
...@@ -386,8 +386,8 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -386,8 +386,8 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
aom_write(w, 1, cm->fc->txfm_partition_prob[ctx]); aom_write(w, 1, cm->fc->txfm_partition_prob[ctx]);
if (tx_size == TX_8X8) { if (tx_size == TX_8X8) {
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, sub_txs, tx_size); xd->left_txfm_context + blk_row, sub_txs, tx_size);
return; return;
} }
...@@ -2282,9 +2282,10 @@ static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile, ...@@ -2282,9 +2282,10 @@ static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
mi_row, mi_col, w); mi_row, mi_col, w);
} else { } else {
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
#endif #endif
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
// has_subpel_mv_component needs the ref frame buffers set up to look // has_subpel_mv_component needs the ref frame buffers set up to look
......
...@@ -275,9 +275,10 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi, ...@@ -275,9 +275,10 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi,
set_mode_info_offsets(cpi, x, xd, mi_row, mi_col); set_mode_info_offsets(cpi, x, xd, mi_row, mi_col);
set_skip_context(xd, mi_row, mi_col); set_skip_context(xd, mi_row, mi_col);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
xd->max_tx_size = max_txsize_lookup[bsize]; xd->max_tx_size = max_txsize_lookup[bsize];
#endif #endif
...@@ -1761,8 +1762,8 @@ typedef struct { ...@@ -1761,8 +1762,8 @@ typedef struct {
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
TXFM_CONTEXT *p_ta; TXFM_CONTEXT *p_ta;
TXFM_CONTEXT *p_tl; TXFM_CONTEXT *p_tl;
TXFM_CONTEXT ta[MAX_MIB_SIZE]; TXFM_CONTEXT ta[2 * MAX_MIB_SIZE];
TXFM_CONTEXT tl[MAX_MIB_SIZE]; TXFM_CONTEXT tl[2 * MAX_MIB_SIZE];
#endif #endif
} RD_SEARCH_MACROBLOCK_CONTEXT; } RD_SEARCH_MACROBLOCK_CONTEXT;
...@@ -1803,9 +1804,9 @@ static void restore_context(MACROBLOCK *x, ...@@ -1803,9 +1804,9 @@ static void restore_context(MACROBLOCK *x,
xd->above_txfm_context = ctx->p_ta; xd->above_txfm_context = ctx->p_ta;
xd->left_txfm_context = ctx->p_tl; xd->left_txfm_context = ctx->p_tl;
memcpy(xd->above_txfm_context, ctx->ta, memcpy(xd->above_txfm_context, ctx->ta,
sizeof(*xd->above_txfm_context) * mi_width); sizeof(*xd->above_txfm_context) * (mi_width << TX_UNIT_WIDE_LOG2));
memcpy(xd->left_txfm_context, ctx->tl, memcpy(xd->left_txfm_context, ctx->tl,
sizeof(*xd->left_txfm_context) * mi_height); sizeof(*xd->left_txfm_context) * (mi_height << TX_UNIT_HIGH_LOG2));
#endif #endif
#if CONFIG_PVQ #if CONFIG_PVQ
od_encode_rollback(&x->daala_enc, rdo_buf); od_encode_rollback(&x->daala_enc, rdo_buf);
...@@ -1848,9 +1849,9 @@ static void save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx, ...@@ -1848,9 +1849,9 @@ static void save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx,
sizeof(xd->left_seg_context[0]) * mi_height); sizeof(xd->left_seg_context[0]) * mi_height);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
memcpy(ctx->ta, xd->above_txfm_context, memcpy(ctx->ta, xd->above_txfm_context,
sizeof(*xd->above_txfm_context) * mi_width); sizeof(*xd->above_txfm_context) * (mi_width << TX_UNIT_WIDE_LOG2));
memcpy(ctx->tl, xd->left_txfm_context, memcpy(ctx->tl, xd->left_txfm_context,
sizeof(*xd->left_txfm_context) * mi_height); sizeof(*xd->left_txfm_context) * (mi_height << TX_UNIT_HIGH_LOG2));
ctx->p_ta = xd->above_txfm_context; ctx->p_ta = xd->above_txfm_context;
ctx->p_tl = xd->left_txfm_context; ctx->p_tl = xd->left_txfm_context;
#endif #endif
...@@ -2265,9 +2266,10 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td, ...@@ -2265,9 +2266,10 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
pc_tree->partitioning = partition; pc_tree->partitioning = partition;
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
#endif #endif
#if !CONFIG_PVQ #if !CONFIG_PVQ
save_context(x, &x_ctx, mi_row, mi_col, bsize); save_context(x, &x_ctx, mi_row, mi_col, bsize);
...@@ -3281,9 +3283,10 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td, ...@@ -3281,9 +3283,10 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
} }
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
#endif #endif
#if !CONFIG_PVQ #if !CONFIG_PVQ
save_context(x, &x_ctx, mi_row, mi_col, bsize); save_context(x, &x_ctx, mi_row, mi_col, bsize);
...@@ -5245,8 +5248,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -5245,8 +5248,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
const int tx_col = blk_col >> 1; const int tx_col = blk_col >> 1;
const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col]; const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col];
...@@ -5255,8 +5258,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -5255,8 +5258,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
if (tx_size == plane_tx_size) { if (tx_size == plane_tx_size) {
++counts->txfm_partition[ctx][0]; ++counts->txfm_partition[ctx][0];
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
} else { } else {
const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
const int bs = tx_size_wide_unit[sub_txs]; const int bs = tx_size_wide_unit[sub_txs];
...@@ -5268,8 +5271,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -5268,8 +5271,8 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
if (tx_size == TX_8X8) { if (tx_size == TX_8X8) {
mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4; mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4;
mbmi->tx_size = TX_4X4; mbmi->tx_size = TX_4X4;
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, TX_4X4, tx_size); xd->left_txfm_context + blk_row, TX_4X4, tx_size);
return; return;
} }
...@@ -5293,9 +5296,10 @@ static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x, ...@@ -5293,9 +5296,10 @@ static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x,
const int bw = tx_size_wide_unit[max_tx_size]; const int bw = tx_size_wide_unit[max_tx_size];
int idx, idy; int idx, idy;
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
for (idy = 0; idy < mi_height; idy += bh) for (idy = 0; idy < mi_height; idy += bh)
for (idx = 0; idx < mi_width; idx += bw) for (idx = 0; idx < mi_width; idx += bw)
...@@ -5316,8 +5320,8 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, ...@@ -5316,8 +5320,8 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row,
if (tx_size == plane_tx_size) { if (tx_size == plane_tx_size) {
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, tx_size, tx_size); xd->left_txfm_context + blk_row, tx_size, tx_size);
} else { } else {
const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
...@@ -5327,8 +5331,8 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, ...@@ -5327,8 +5331,8 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row,
if (tx_size == TX_8X8) { if (tx_size == TX_8X8) {
mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4; mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4;
mbmi->tx_size = TX_4X4; mbmi->tx_size = TX_4X4;
txfm_partition_update(xd->above_txfm_context + tx_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + tx_row, TX_4X4, tx_size); xd->left_txfm_context + blk_row, TX_4X4, tx_size);
return; return;
} }
...@@ -5351,9 +5355,10 @@ static void tx_partition_set_contexts(const AV1_COMMON *const cm, ...@@ -5351,9 +5355,10 @@ static void tx_partition_set_contexts(const AV1_COMMON *const cm,
const int bw = tx_size_wide_unit[max_tx_size]; const int bw = tx_size_wide_unit[max_tx_size];
int idx, idy; int idx, idy;
xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->above_txfm_context =
xd->left_txfm_context = cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
for (idy = 0; idy < mi_height; idy += bh) for (idy = 0; idy < mi_height; idy += bh)
for (idx = 0; idx < mi_width; idx += bw) for (idx = 0; idx < mi_width; idx += bw)
......
...@@ -4046,9 +4046,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4046,9 +4046,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
ENTROPY_CONTEXT *pta = ta + blk_col; ENTROPY_CONTEXT *pta = ta + blk_col;
ENTROPY_CONTEXT *ptl = tl + blk_row; ENTROPY_CONTEXT *ptl = tl + blk_row;
int coeff_ctx, i; int coeff_ctx, i;
int ctx = int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row,
txfm_partition_context(tx_above + (blk_col >> 1), mbmi->sb_type, tx_size);
tx_left + (blk_row >> 1), mbmi->sb_type, tx_size);
int64_t sum_rd = INT64_MAX; int64_t sum_rd = INT64_MAX;
int tmp_eob = 0; int tmp_eob = 0;
int zero_blk_rate; int zero_blk_rate;
...@@ -4152,8 +4151,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4152,8 +4151,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
int idx, idy; int idx, idy;
for (i = 0; i < tx_size_wide_unit[tx_size]; ++i) pta[i] = !(tmp_eob == 0); for (i = 0; i < tx_size_wide_unit[tx_size]; ++i) pta[i] = !(tmp_eob == 0);
for (i = 0; i < tx_size_high_unit[tx_size]; ++i) ptl[i] = !(tmp_eob == 0); for (i = 0; i < tx_size_high_unit[tx_size]; ++i) ptl[i] = !(tmp_eob == 0);
txfm_partition_update(tx_above + (blk_col >> 1), tx_left + (blk_row >> 1), txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size,
tx_size, tx_size); tx_size);
inter_tx_size[0][0] = tx_size; inter_tx_size[0][0] = tx_size;
for (idy = 0; idy < tx_size_high_unit[tx_size] / 2; ++idy) for (idy = 0; idy < tx_size_high_unit[tx_size] / 2; ++idy)
for (idx = 0; idx < tx_size_wide_unit[tx_size] / 2; ++idx) for (idx = 0; idx < tx_size_wide_unit[tx_size] / 2; ++idx)
...@@ -4192,17 +4191,15 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4192,17 +4191,15 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
int step = tx_size_wide_unit[max_tx_size] * tx_size_high_unit[max_tx_size]; int step = tx_size_wide_unit[max_tx_size] * tx_size_high_unit[max_tx_size];
ENTROPY_CONTEXT ctxa[2 * MAX_MIB_SIZE]; ENTROPY_CONTEXT ctxa[2 * MAX_MIB_SIZE];
ENTROPY_CONTEXT ctxl[2 * MAX_MIB_SIZE]; ENTROPY_CONTEXT ctxl[2 * MAX_MIB_SIZE];
TXFM_CONTEXT tx_above[MAX_MIB_SIZE]; TXFM_CONTEXT tx_above[MAX_MIB_SIZE * 2];
TXFM_CONTEXT tx_left[MAX_MIB_SIZE]; TXFM_CONTEXT tx_left[MAX_MIB_SIZE * 2];
RD_STATS pn_rd_stats; RD_STATS pn_rd_stats;
av1_init_rd_stats(&pn_rd_stats); av1_init_rd_stats(&pn_rd_stats);
av1_get_entropy_contexts(bsize, 0, pd, ctxa, ctxl); av1_get_entropy_contexts(bsize, 0, pd, ctxa, ctxl);
memcpy(tx_above, xd->above_txfm_context, memcpy(tx_above, xd->above_txfm_context, sizeof(TXFM_CONTEXT) * mi_width);
sizeof(TXFM_CONTEXT) * (mi_width >> 1)); memcpy(tx_left, xd->left_txfm_context, sizeof(TXFM_CONTEXT) * mi_height);
memcpy(tx_left, xd->left_txfm_context,
sizeof(TXFM_CONTEXT) * (mi_height >> 1));
for (idy = 0; idy < mi_height; idy += bh) { for (idy = 0; idy < mi_height; idy += bh) {
for (idx = 0; idx < mi_width; idx += bw) { for (idx = 0; idx < mi_width; idx += bw) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment