Commit 025c6c41 authored by Jingning Han's avatar Jingning Han

Use sub-frame statistics for adaptive scan order update

Skip the last SB row counting for per frame adaptive scan order.
This allows enough time window for HW decoder to process the
scan order update for next frame decoding.

Change-Id: I8a3b48fe452c68c921d55dc76cc787f0a8e00e29
parent ba2d817a
......@@ -5505,9 +5505,16 @@ static void update_scan_count(int16_t *scan, int max_scan,
}
}
void av1_update_scan_count_facade(AV1_COMMON *cm, FRAME_COUNTS *counts,
TX_SIZE tx_size, TX_TYPE tx_type,
const tran_low_t *dqcoeffs, int max_scan) {
void av1_update_scan_count_facade(AV1_COMMON *cm, int mi_row,
FRAME_COUNTS *counts, TX_SIZE tx_size,
TX_TYPE tx_type, const tran_low_t *dqcoeffs,
int max_scan) {
#if SUB_FRAME_COUNT
if (((mi_row >> 5) << 5) + 32 >= cm->mi_rows) return;
#else
(void)mi_row;
#endif
if (cm->use_adapt_scan && do_adapt_scan(tx_size, tx_type) && max_scan) {
#if SUB_REGION_COUNT
if (counts->txb_count[tx_size][tx_type] >= UINT8_MAX) return;
......
......@@ -34,11 +34,13 @@ extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
#define CACHE_SCAN_PROB 0
#define REDUCED_SET 1
#define SUB_REGION_COUNT 1
#define SUB_FRAME_COUNT 1
#define USE_TOPOLOGICAL_SORT 0
#define USE_LIMIT_SCAN_DISTANCE 0
void av1_update_scan_count_facade(AV1_COMMON *cm, FRAME_COUNTS *counts,
TX_SIZE tx_size, TX_TYPE tx_type,
const tran_low_t *dqcoeffs, int max_scan);
void av1_update_scan_count_facade(AV1_COMMON *cm, int mi_row,
FRAME_COUNTS *counts, TX_SIZE tx_size,
TX_TYPE tx_type, const tran_low_t *dqcoeffs,
int max_scan);
// embed r + c and coeff_idx info with nonzero probabilities. When sorting the
// nonzero probabilities, if there is a tie, the coefficient with smaller r + c
......
......@@ -406,9 +406,11 @@ uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_ADAPT_SCAN
PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, row, col, block, tx_size);
const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
if (xd->counts && *eob > 0)
av1_update_scan_count_facade(cm, xd->counts, tx_size, tx_type, pd->dqcoeff,
*eob);
av1_update_scan_count_facade(cm, mi_row, xd->counts, tx_size, tx_type,
pd->dqcoeff, *eob);
#endif
av1_set_contexts(xd, pd, plane, tx_size, cul_level, col, row);
return cul_level;
......
......@@ -372,9 +372,11 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
ctx, sc->scan, sc->neighbors, max_scan_line, r);
av1_set_contexts(xd, pd, plane, tx_size, eob > 0, x, y);
#if CONFIG_ADAPT_SCAN
const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
if (xd->counts)
av1_update_scan_count_facade(cm, xd->counts, tx_size, tx_type, pd->dqcoeff,
eob);
av1_update_scan_count_facade(cm, mi_row, xd->counts, tx_size, tx_type,
pd->dqcoeff, eob);
#else
(void)cm;
#endif
......
......@@ -2402,8 +2402,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
// av1_update_scan_count_facade(). The update behavior should be the same
// because av1_update_scan_count_facade() only cares if coefficients are zero
// or not.
av1_update_scan_count_facade((AV1_COMMON *)cm, td->counts, tx_size, tx_type,
qcoeff, eob);
const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
av1_update_scan_count_facade((AV1_COMMON *)cm, mi_row, td->counts, tx_size,
tx_type, qcoeff, eob);
#endif
}
......
......@@ -513,8 +513,9 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
// av1_update_scan_count_facade(). The update behavior should be the same
// because av1_update_scan_count_facade() only cares if coefficients are zero
// or not.
av1_update_scan_count_facade((AV1_COMMON *)cm, td->counts, tx_size, tx_type,
qcoeff, c);
const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
av1_update_scan_count_facade((AV1_COMMON *)cm, mi_row, td->counts, tx_size,
tx_type, qcoeff, c);
#endif
av1_set_contexts(xd, pd, plane, tx_size, c > 0, blk_col, blk_row);
......
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