Commit bd161f9f authored by Jingning Han's avatar Jingning Han Committed by Gerrit Code Review
Browse files

Merge "Refactor decoder side qcoeff reset" into nextgenv2

parents a1a753c7 1be18785
...@@ -251,34 +251,26 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) { ...@@ -251,34 +251,26 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
static void inverse_transform_block(MACROBLOCKD *xd, int plane, static void inverse_transform_block(MACROBLOCKD *xd, int plane,
const TX_TYPE tx_type, const TX_TYPE tx_type,
const TX_SIZE tx_size, uint8_t *dst, const TX_SIZE tx_size, uint8_t *dst,
int stride, int eob) { int stride, int16_t scan_line, int eob) {
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
if (eob > 0) { tran_low_t *const dqcoeff = pd->dqcoeff;
tran_low_t *const dqcoeff = pd->dqcoeff; INV_TXFM_PARAM inv_txfm_param;
INV_TXFM_PARAM inv_txfm_param; inv_txfm_param.tx_type = tx_type;
inv_txfm_param.tx_type = tx_type; inv_txfm_param.tx_size = tx_size;
inv_txfm_param.tx_size = tx_size; inv_txfm_param.eob = eob;
inv_txfm_param.eob = eob; inv_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
inv_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
#if CONFIG_AOM_HIGHBITDEPTH #if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
inv_txfm_param.bd = xd->bd; inv_txfm_param.bd = xd->bd;
highbd_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param); highbd_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param);
} else { } else {
#endif // CONFIG_AOM_HIGHBITDEPTH #endif // CONFIG_AOM_HIGHBITDEPTH
inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param); inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param);
#if CONFIG_AOM_HIGHBITDEPTH #if CONFIG_AOM_HIGHBITDEPTH
}
#endif // CONFIG_AOM_HIGHBITDEPTH
// TODO(jingning): This cleans up different reset requests from various
// experiments, but incurs unnecessary memset size.
if (eob == 1)
dqcoeff[0] = 0;
else
memset(dqcoeff, 0, tx_size_2d[tx_size] * sizeof(dqcoeff[0]));
} }
#endif // CONFIG_AOM_HIGHBITDEPTH
memset(dqcoeff, 0, (scan_line + 1) * sizeof(dqcoeff[0]));
} }
static void predict_and_reconstruct_intra_block(AV1_COMMON *cm, static void predict_and_reconstruct_intra_block(AV1_COMMON *cm,
...@@ -307,10 +299,13 @@ static void predict_and_reconstruct_intra_block(AV1_COMMON *cm, ...@@ -307,10 +299,13 @@ static void predict_and_reconstruct_intra_block(AV1_COMMON *cm,
if (!mbmi->skip) { if (!mbmi->skip) {
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size); TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const int eob = av1_decode_block_tokens( int16_t max_scan_line = 0;
xd, plane, scan_order, col, row, tx_size, tx_type, r, mbmi->segment_id); const int eob =
inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride, av1_decode_block_tokens(xd, plane, scan_order, col, row, tx_size,
eob); tx_type, &max_scan_line, r, mbmi->segment_id);
if (eob)
inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
max_scan_line, eob);
} }
} }
...@@ -341,13 +336,14 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -341,13 +336,14 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV; PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size); TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1); const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
int16_t max_scan_line = 0;
const int eob = const int eob =
av1_decode_block_tokens(xd, plane, sc, blk_col, blk_row, plane_tx_size, av1_decode_block_tokens(xd, plane, sc, blk_col, blk_row, plane_tx_size,
tx_type, r, mbmi->segment_id); tx_type, &max_scan_line, r, mbmi->segment_id);
inverse_transform_block( inverse_transform_block(
xd, plane, tx_type, plane_tx_size, xd, plane, tx_type, plane_tx_size,
&pd->dst.buf[4 * blk_row * pd->dst.stride + 4 * blk_col], &pd->dst.buf[4 * blk_row * pd->dst.stride + 4 * blk_col],
pd->dst.stride, eob); pd->dst.stride, max_scan_line, eob);
*eob_total += eob; *eob_total += eob;
} else { } else {
int bsl = b_width_log2_lookup[bsize]; int bsl = b_width_log2_lookup[bsize];
...@@ -385,12 +381,14 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -385,12 +381,14 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
int block_idx = (row << 1) + col; int block_idx = (row << 1) + col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size); TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
const int eob = av1_decode_block_tokens(xd, plane, scan_order, col, row, int16_t max_scan_line = 0;
tx_size, tx_type, r, segment_id); const int eob =
av1_decode_block_tokens(xd, plane, scan_order, col, row, tx_size, tx_type,
inverse_transform_block(xd, plane, tx_type, tx_size, &max_scan_line, r, segment_id);
&pd->dst.buf[4 * row * pd->dst.stride + 4 * col], if (eob)
pd->dst.stride, eob); inverse_transform_block(xd, plane, tx_type, tx_size,
&pd->dst.buf[4 * row * pd->dst.stride + 4 * col],
pd->dst.stride, max_scan_line, eob);
return eob; return eob;
} }
#endif // !CONFIG_VAR_TX || CONFIG_SUPER_TX #endif // !CONFIG_VAR_TX || CONFIG_SUPER_TX
......
...@@ -61,7 +61,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -61,7 +61,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
dequant_val_type_nuq *dq_val, dequant_val_type_nuq *dq_val,
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
int ctx, const int16_t *scan, const int16_t *nb, int ctx, const int16_t *scan, const int16_t *nb,
aom_reader *r) int16_t *max_scan_line, aom_reader *r)
#endif #endif
{ {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
...@@ -166,6 +166,9 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -166,6 +166,9 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
dqv_val = &dq_val[band][0]; dqv_val = &dq_val[band][0];
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
} }
*max_scan_line = AOMMAX(*max_scan_line, scan[c]);
#if CONFIG_RANS #if CONFIG_RANS
cdf = &coef_cdfs[band][ctx]; cdf = &coef_cdfs[band][ctx];
token = ONE_TOKEN + token = ONE_TOKEN +
...@@ -327,7 +330,8 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, ...@@ -327,7 +330,8 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane, int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size, const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size,
TX_TYPE tx_type, aom_reader *r, int seg_id) { TX_TYPE tx_type, int16_t *max_scan_line,
aom_reader *r, int seg_id) {
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
const int16_t *const dequant = pd->seg_dequant[seg_id]; const int16_t *const dequant = pd->seg_dequant[seg_id];
const int ctx = const int ctx =
...@@ -339,16 +343,16 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane, ...@@ -339,16 +343,16 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
const int eob = const int eob = decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size,
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant, tx_type, dequant, ctx, sc->scan, sc->neighbors,
ctx, sc->scan, sc->neighbors, r, pd->seg_iqmatrix[seg_id]); &sc->max_scan_line, r, pd->seg_iqmatrix[seg_id]);
#else #else
const int eob = const int eob =
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant, decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
pd->seg_dequant_nuq[seg_id][dq], pd->seg_dequant_nuq[seg_id][dq],
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
ctx, sc->scan, sc->neighbors, r); ctx, sc->scan, sc->neighbors, max_scan_line, r);
#endif // CONFIG_AOM_QM #endif // CONFIG_AOM_QM
av1_set_contexts(xd, pd, tx_size, eob > 0, x, y); av1_set_contexts(xd, pd, tx_size, eob > 0, x, y);
return eob; return eob;
......
...@@ -28,7 +28,7 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r); ...@@ -28,7 +28,7 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane, int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size, const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size,
TX_TYPE tx_type, TX_TYPE tx_type, int16_t *max_scan_line,
#if CONFIG_ANS #if CONFIG_ANS
struct AnsDecoder *const r, struct AnsDecoder *const r,
#else #else
......
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