Commit 7eab9ff1 authored by Jingning Han's avatar Jingning Han

Refactor get_tx_type indexing

Use row and column indexes to fetch the txk_type value.

Change-Id: I881d500c030e322d8aca9dccb6ff2870c9e1e392
parent 1c318d52
...@@ -42,8 +42,8 @@ static int read_golomb(MACROBLOCKD *xd, aom_reader *r) { ...@@ -42,8 +42,8 @@ static int read_golomb(MACROBLOCKD *xd, aom_reader *r) {
} }
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_reader *r, int block, int plane, aom_reader *r, int blk_row, int blk_col, int block,
tran_low_t *tcoeffs, TXB_CTX *txb_ctx, int plane, tran_low_t *tcoeffs, TXB_CTX *txb_ctx,
TX_SIZE tx_size, int16_t *max_scan_line, int *eob) { TX_SIZE tx_size, int16_t *max_scan_line, int *eob) {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
TX_SIZE txs_ctx = get_txsize_context(tx_size); TX_SIZE txs_ctx = get_txsize_context(tx_size);
...@@ -77,6 +77,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -77,6 +77,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
return 0; return 0;
} }
(void)blk_row;
(void)blk_col;
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_read_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), r); av1_read_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), r);
#endif #endif
...@@ -231,8 +233,9 @@ uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -231,8 +233,9 @@ uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
TXB_CTX txb_ctx; TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + col, get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + col,
pd->left_context + row, &txb_ctx); pd->left_context + row, &txb_ctx);
uint8_t cul_level = av1_read_coeffs_txb( uint8_t cul_level =
cm, xd, r, block, plane, tcoeffs, &txb_ctx, tx_size, max_scan_line, eob); av1_read_coeffs_txb(cm, xd, r, row, col, block, plane, tcoeffs, &txb_ctx,
tx_size, max_scan_line, eob);
#if CONFIG_ADAPT_SCAN #if CONFIG_ADAPT_SCAN
PLANE_TYPE plane_type = get_plane_type(plane); PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include "aom_dsp/bitreader.h" #include "aom_dsp/bitreader.h"
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_reader *r, int block, int plane, aom_reader *r, int blk_row, int blk_col, int block,
tran_low_t *tcoeffs, TXB_CTX *txb_ctx, int plane, tran_low_t *tcoeffs, TXB_CTX *txb_ctx,
TX_SIZE tx_size, int16_t *max_scan_line, int *eob); TX_SIZE tx_size, int16_t *max_scan_line, int *eob);
uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd, uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
......
...@@ -914,8 +914,8 @@ static void pack_txb_tokens(aom_writer *w, ...@@ -914,8 +914,8 @@ static void pack_txb_tokens(aom_writer *w,
uint16_t eob = x->mbmi_ext->eobs[plane][block]; uint16_t eob = x->mbmi_ext->eobs[plane][block];
TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block], TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block],
x->mbmi_ext->dc_sign_ctx[plane][block] }; x->mbmi_ext->dc_sign_ctx[plane][block] };
av1_write_coeffs_txb(cm, xd, w, block, plane, tx_size, tcoeff, eob, av1_write_coeffs_txb(cm, xd, w, blk_row, blk_col, block, plane, tx_size,
&txb_ctx); tcoeff, eob, &txb_ctx);
#else #else
pack_pvq_tokens(w, x, xd, plane, bsize, tx_size); pack_pvq_tokens(w, x, xd, plane, bsize, tx_size);
#endif #endif
......
...@@ -5871,7 +5871,7 @@ static void tx_partition_set_contexts(const AV1_COMMON *const cm, ...@@ -5871,7 +5871,7 @@ static void tx_partition_set_contexts(const AV1_COMMON *const cm,
void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd, void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, int blk_row, int blk_col, int block, int plane,
#endif #endif
BLOCK_SIZE bsize, TX_SIZE tx_size, BLOCK_SIZE bsize, TX_SIZE tx_size,
FRAME_COUNTS *counts) { FRAME_COUNTS *counts) {
...@@ -5881,6 +5881,8 @@ void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -5881,6 +5881,8 @@ void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd,
#if !CONFIG_TXK_SEL #if !CONFIG_TXK_SEL
TX_TYPE tx_type = mbmi->tx_type; TX_TYPE tx_type = mbmi->tx_type;
#else #else
(void)blk_row;
(void)blk_col;
// Only y plane's tx_type is updated // Only y plane's tx_type is updated
if (plane > 0) return; if (plane > 0) return;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size); TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
......
...@@ -37,7 +37,7 @@ void av1_encode_tile(struct AV1_COMP *cpi, struct ThreadData *td, int tile_row, ...@@ -37,7 +37,7 @@ void av1_encode_tile(struct AV1_COMP *cpi, struct ThreadData *td, int tile_row,
void av1_update_tx_type_count(const struct AV1Common *cm, MACROBLOCKD *xd, void av1_update_tx_type_count(const struct AV1Common *cm, MACROBLOCKD *xd,
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, int blk_row, int blk_col, int block, int plane,
#endif #endif
BLOCK_SIZE bsize, TX_SIZE tx_size, BLOCK_SIZE bsize, TX_SIZE tx_size,
FRAME_COUNTS *counts); FRAME_COUNTS *counts);
......
...@@ -430,9 +430,10 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, ...@@ -430,9 +430,10 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
} }
#endif // !CONFIG_LV_MAP #endif // !CONFIG_LV_MAP
int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block, int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int blk_col, int block, BLOCK_SIZE plane_bsize,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l) { TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l) {
MACROBLOCKD *const xd = &mb->e_mbd; MACROBLOCKD *const xd = &mb->e_mbd;
struct macroblock_plane *const p = &mb->plane[plane]; struct macroblock_plane *const p = &mb->plane[plane];
const int eob = p->eobs[block]; const int eob = p->eobs[block];
...@@ -450,6 +451,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block, ...@@ -450,6 +451,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
#if !CONFIG_LV_MAP #if !CONFIG_LV_MAP
(void)plane_bsize; (void)plane_bsize;
(void)blk_row;
(void)blk_col;
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
int ctx = get_entropy_context(tx_size, a, l); int ctx = get_entropy_context(tx_size, a, l);
#else #else
...@@ -459,7 +462,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block, ...@@ -459,7 +462,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
#else // !CONFIG_LV_MAP #else // !CONFIG_LV_MAP
TXB_CTX txb_ctx; TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx); get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
return av1_optimize_txb(cm, mb, plane, block, tx_size, &txb_ctx); return av1_optimize_txb(cm, mb, plane, blk_row, blk_col, block, tx_size,
&txb_ctx);
#endif // !CONFIG_LV_MAP #endif // !CONFIG_LV_MAP
} }
...@@ -735,7 +739,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, ...@@ -735,7 +739,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
#endif #endif
#if !CONFIG_PVQ #if !CONFIG_PVQ
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, a,
l);
av1_set_txb_context(x, plane, block, tx_size, a, l); av1_set_txb_context(x, plane, block, tx_size, a, l);
...@@ -1392,7 +1397,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, ...@@ -1392,7 +1397,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
if (args->enable_optimize_b) { if (args->enable_optimize_b) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_FP); ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l);
} else { } else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_B); ctx, AV1_XFORM_QUANT_B);
......
...@@ -53,9 +53,10 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, ...@@ -53,9 +53,10 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
int blk_row, int blk_col, BLOCK_SIZE plane_bsize, int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx, AV1_XFORM_QUANT xform_quant_idx); TX_SIZE tx_size, int ctx, AV1_XFORM_QUANT xform_quant_idx);
int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block, int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int blk_col, int block, BLOCK_SIZE plane_bsize,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l); TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l);
void av1_subtract_txb(MACROBLOCK *x, int plane, BLOCK_SIZE plane_bsize, void av1_subtract_txb(MACROBLOCK *x, int plane, BLOCK_SIZE plane_bsize,
int blk_col, int blk_row, TX_SIZE tx_size); int blk_col, int blk_row, TX_SIZE tx_size);
......
...@@ -70,9 +70,9 @@ static void write_golomb(aom_writer *w, int level) { ...@@ -70,9 +70,9 @@ static void write_golomb(aom_writer *w, int level) {
} }
void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_writer *w, int block, int plane, TX_SIZE tx_size, aom_writer *w, int blk_row, int blk_col, int block,
const tran_low_t *tcoeff, uint16_t eob, int plane, TX_SIZE tx_size, const tran_low_t *tcoeff,
TXB_CTX *txb_ctx) { uint16_t eob, TXB_CTX *txb_ctx) {
aom_prob *nz_map; aom_prob *nz_map;
aom_prob *eob_flag; aom_prob *eob_flag;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
...@@ -89,6 +89,9 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -89,6 +89,9 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
uint8_t txb_mask[32 * 32] = { 0 }; uint8_t txb_mask[32 * 32] = { 0 };
uint16_t update_eob = 0; uint16_t update_eob = 0;
(void)blk_row;
(void)blk_col;
aom_write(w, eob == 0, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx]); aom_write(w, eob == 0, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx]);
if (eob == 0) return; if (eob == 0) return;
...@@ -206,8 +209,8 @@ void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x, ...@@ -206,8 +209,8 @@ void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
uint16_t eob = x->mbmi_ext->eobs[plane][block]; uint16_t eob = x->mbmi_ext->eobs[plane][block];
TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block], TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block],
x->mbmi_ext->dc_sign_ctx[plane][block] }; x->mbmi_ext->dc_sign_ctx[plane][block] };
av1_write_coeffs_txb(cm, xd, w, block, plane, tx_size, tcoeff, eob, av1_write_coeffs_txb(cm, xd, w, row, col, block, plane, tx_size, tcoeff,
&txb_ctx); eob, &txb_ctx);
block += step; block += step;
} }
} }
...@@ -284,11 +287,14 @@ static INLINE int get_base_cost(tran_low_t abs_qc, int ctx, ...@@ -284,11 +287,14 @@ static INLINE int get_base_cost(tran_low_t abs_qc, int ctx,
} }
int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, TXB_CTX *txb_ctx) { int blk_row, int blk_col, int block, TX_SIZE tx_size,
TXB_CTX *txb_ctx) {
const AV1_COMMON *const cm = &cpi->common; const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
TX_SIZE txs_ctx = get_txsize_context(tx_size); TX_SIZE txs_ctx = get_txsize_context(tx_size);
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
(void)blk_row;
(void)blk_col;
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const struct macroblock_plane *p = &x->plane[plane]; const struct macroblock_plane *p = &x->plane[plane];
...@@ -1459,11 +1465,14 @@ static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = { ...@@ -1459,11 +1465,14 @@ static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = {
{ 17, 13 }, { 16, 10 }, { 17, 13 }, { 16, 10 },
}; };
int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
TX_SIZE tx_size, TXB_CTX *txb_ctx) { int blk_row, int blk_col, int block, TX_SIZE tx_size,
TXB_CTX *txb_ctx) {
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE txs_ctx = get_txsize_context(tx_size); const TX_SIZE txs_ctx = get_txsize_context(tx_size);
(void)blk_row;
(void)blk_col;
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const struct macroblock_plane *p = &x->plane[plane]; const struct macroblock_plane *p = &x->plane[plane];
...@@ -1595,8 +1604,8 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row, ...@@ -1595,8 +1604,8 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
} }
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_update_tx_type_count(cm, xd, block, plane, mbmi->sb_type, av1_update_tx_type_count(cm, xd, blk_row, blk_col, block, plane,
get_min_tx_size(tx_size), td->counts); mbmi->sb_type, get_min_tx_size(tx_size), td->counts);
#endif #endif
for (c = 0; c < eob; ++c) { for (c = 0; c < eob; ++c) {
...@@ -1895,13 +1904,15 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1895,13 +1904,15 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_invalid_rd_stats(&this_rd_stats); av1_invalid_rd_stats(&this_rd_stats);
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l);
av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size, av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size,
&this_rd_stats.dist, &this_rd_stats.sse, &this_rd_stats.dist, &this_rd_stats.sse,
OUTPUT_HAS_PREDICTED_PIXELS); OUTPUT_HAS_PREDICTED_PIXELS);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
this_rd_stats.rate = av1_cost_coeffs( this_rd_stats.rate =
cpi, x, plane, block, tx_size, scan_order, a, l, use_fast_coef_costing); av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size,
scan_order, a, l, use_fast_coef_costing);
int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist); int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
if (rd < best_rd) { if (rd < best_rd) {
best_rd = rd; best_rd = rd;
...@@ -1921,7 +1932,8 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1921,7 +1932,8 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
// can use it for prediction. // can use it for prediction.
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l);
av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col, av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col,
x->plane[plane].eobs[block]); x->plane[plane].eobs[block]);
......
...@@ -67,11 +67,12 @@ typedef struct TxbProbs { ...@@ -67,11 +67,12 @@ typedef struct TxbProbs {
void av1_alloc_txb_buf(AV1_COMP *cpi); void av1_alloc_txb_buf(AV1_COMP *cpi);
void av1_free_txb_buf(AV1_COMP *cpi); void av1_free_txb_buf(AV1_COMP *cpi);
int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, TXB_CTX *txb_ctx); int blk_row, int blk_col, int block, TX_SIZE tx_size,
TXB_CTX *txb_ctx);
void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_writer *w, int block, int plane, TX_SIZE tx_size, aom_writer *w, int blk_row, int blk_col, int block,
const tran_low_t *tcoeff, uint16_t eob, int plane, TX_SIZE tx_size, const tran_low_t *tcoeff,
TXB_CTX *txb_ctx); uint16_t eob, TXB_CTX *txb_ctx);
void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x, void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
aom_writer *w, int plane); aom_writer *w, int plane);
int av1_get_txb_entropy_context(const tran_low_t *qcoeff, int av1_get_txb_entropy_context(const tran_low_t *qcoeff,
...@@ -96,8 +97,9 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -96,8 +97,9 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l, const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
int use_fast_coef_costing, RD_STATS *rd_stats); int use_fast_coef_costing, RD_STATS *rd_stats);
#endif #endif
int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
TX_SIZE tx_size, TXB_CTX *txb_ctx); int blk_row, int blk_col, int block, TX_SIZE tx_size,
TXB_CTX *txb_ctx);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -1441,10 +1441,12 @@ static int cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, ...@@ -1441,10 +1441,12 @@ static int cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
#endif // !CONFIG_LV_MAP #endif // !CONFIG_LV_MAP
int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order, int blk_row, int blk_col, int block, TX_SIZE tx_size,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l, const SCAN_ORDER *scan_order, const ENTROPY_CONTEXT *a,
int use_fast_coef_costing) { const ENTROPY_CONTEXT *l, int use_fast_coef_costing) {
#if !CONFIG_LV_MAP #if !CONFIG_LV_MAP
(void)blk_row;
(void)blk_col;
const AV1_COMMON *const cm = &cpi->common; const AV1_COMMON *const cm = &cpi->common;
return cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l, return cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l,
use_fast_coef_costing); use_fast_coef_costing);
...@@ -1467,7 +1469,8 @@ int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, ...@@ -1467,7 +1469,8 @@ int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
TXB_CTX txb_ctx; TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx); get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
return av1_cost_coeffs_txb(cpi, x, plane, block, tx_size, &txb_ctx); return av1_cost_coeffs_txb(cpi, x, plane, blk_row, blk_col, block, tx_size,
&txb_ctx);
#endif // !CONFIG_LV_MAP #endif // !CONFIG_LV_MAP
} }
#endif // !CONFIG_PVQ || CONFIG_VAR_TX #endif // !CONFIG_PVQ || CONFIG_VAR_TX
...@@ -1862,7 +1865,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, ...@@ -1862,7 +1865,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
#else #else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, a,
l);
#endif // DISABLE_TRELLISQ_SEARCH #endif // DISABLE_TRELLISQ_SEARCH
if (!is_inter_block(mbmi)) { if (!is_inter_block(mbmi)) {
...@@ -1901,8 +1905,8 @@ CALCULATE_RD : {} ...@@ -1901,8 +1905,8 @@ CALCULATE_RD : {}
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
this_rd_stats.rate = this_rd_stats.rate =
av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l, av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size,
args->use_fast_coef_costing); scan_order, a, l, args->use_fast_coef_costing);
#else // !CONFIG_PVQ #else // !CONFIG_PVQ
this_rd_stats.rate = x->rate; this_rd_stats.rate = x->rate;
#endif // !CONFIG_PVQ #endif // !CONFIG_PVQ
...@@ -3124,8 +3128,8 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode( ...@@ -3124,8 +3128,8 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
#if !CONFIG_PVQ #if !CONFIG_PVQ
av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8, av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
tx_size, coeff_ctx, AV1_XFORM_QUANT_FP); tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order, ratey += av1_cost_coeffs(cpi, x, 0, 0, 0, block, tx_size,
tempa + idx, templ + idy, scan_order, tempa + idx, templ + idy,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
skip = (p->eobs[block] == 0); skip = (p->eobs[block] == 0);
can_skip &= skip; can_skip &= skip;
...@@ -3176,11 +3180,11 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode( ...@@ -3176,11 +3180,11 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
#else #else
av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8, av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
tx_size, coeff_ctx, AV1_XFORM_QUANT_FP); tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, 0, block, BLOCK_8X8, tx_size, tempa + idx, av1_optimize_b(cm, x, 0, 0, 0, block, BLOCK_8X8, tx_size,
templ + idy); tempa + idx, templ + idy);
#endif // DISABLE_TRELLISQ_SEARCH #endif // DISABLE_TRELLISQ_SEARCH
ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order, ratey += av1_cost_coeffs(cpi, x, 0, 0, 0, block, tx_size,
tempa + idx, templ + idy, scan_order, tempa + idx, templ + idy,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
skip = (p->eobs[block] == 0); skip = (p->eobs[block] == 0);
can_skip &= skip; can_skip &= skip;
...@@ -3350,12 +3354,12 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode( ...@@ -3350,12 +3354,12 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
#endif // CONFIG_CB4X4 #endif // CONFIG_CB4X4
BLOCK_8X8, tx_size, coeff_ctx, xform_quant); BLOCK_8X8, tx_size, coeff_ctx, xform_quant);
av1_optimize_b(cm, x, 0, block, BLOCK_8X8, tx_size, tempa + idx, av1_optimize_b(cm, x, 0, 0, 0, block, BLOCK_8X8, tx_size, tempa + idx,
templ + idy); templ + idy);
#endif // DISABLE_TRELLISQ_SEARCH #endif // DISABLE_TRELLISQ_SEARCH
ratey += ratey += av1_cost_coeffs(cpi, x, 0, 0, 0, block, tx_size, scan_order,
av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order, tempa + idx, tempa + idx, templ + idy,
templ + idy, cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
skip = (p->eobs[block] == 0); skip = (p->eobs[block] == 0);
can_skip &= skip; can_skip &= skip;
tempa[idx] = !skip; tempa[idx] = !skip;
...@@ -4291,7 +4295,8 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, ...@@ -4291,7 +4295,8 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l); av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, a,
l);
#endif // DISABLE_TRELLISQ_SEARCH #endif // DISABLE_TRELLISQ_SEARCH
// TODO(any): Use av1_dist_block to compute distortion // TODO(any): Use av1_dist_block to compute distortion
...@@ -4360,8 +4365,8 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, ...@@ -4360,8 +4365,8 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
blk_row, blk_col, plane_bsize, txm_bsize); blk_row, blk_col, plane_bsize, txm_bsize);
} }
rd_stats->dist += tmp * 16; rd_stats->dist += tmp * 16;
txb_coeff_cost = txb_coeff_cost = av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block,
av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l, 0); tx_size, scan_order, a, l, 0);
rd_stats->rate += txb_coeff_cost; rd_stats->rate += txb_coeff_cost;
rd_stats->skip &= (eob == 0); rd_stats->skip &= (eob == 0);
......
...@@ -81,9 +81,9 @@ int64_t av1_daala_dist(const MACROBLOCKD *xd, const uint8_t *src, ...@@ -81,9 +81,9 @@ int64_t av1_daala_dist(const MACROBLOCKD *xd, const uint8_t *src,
#if !CONFIG_PVQ || CONFIG_VAR_TX #if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order, int blk_row, int blk_col, int block, TX_SIZE tx_size,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l, const SCAN_ORDER *scan_order, const ENTROPY_CONTEXT *a,
int use_fast_coef_costing); const ENTROPY_CONTEXT *l, int use_fast_coef_costing);
#endif #endif
void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x, void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
struct RD_STATS *rd_cost, BLOCK_SIZE bsize, struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
......
...@@ -279,9 +279,9 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col, ...@@ -279,9 +279,9 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
const PLANE_TYPE type = pd->plane_type; const PLANE_TYPE type = pd->plane_type;
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size); const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int rate = av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, const int rate = av1_cost_coeffs(
pd->above_context + blk_col, cpi, x, plane, blk_row, blk_col, block, tx_size, scan_order,
pd->left_context + blk_row, 0); pd->above_context + blk_col, pd->left_context + blk_row, 0);
args->this_rate += rate; args->this_rate += rate;
(void)plane_bsize; (void)plane_bsize;
av1_set_contexts(xd, pd, plane, tx_size, p->eobs[block] > 0, blk_col, av1_set_contexts(xd, pd, plane, tx_size, p->eobs[block] > 0, blk_col,
......
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