Commit cfe0fede authored by Yi Luo's avatar Yi Luo

Add EOB threshold calculation for ADAPT_SCAN

Change-Id: I0c58fb5ee2a77ae15f6243b1c645dbe601171e67
parent 9f07be16
......@@ -1394,6 +1394,10 @@ static const int partition_supertx_context_lookup[PARTITION_TYPES] = { -1, 0, 0,
#endif // CONFIG_EXT_PARTITION_TYPES
#endif // CONFIG_SUPERTX
#if CONFIG_ADAPT_SCAN
#define EOB_THRESHOLD_NUM 2
#endif
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -164,6 +164,8 @@ typedef struct frame_contexts {
int16_t nb_32X16[TX_TYPES][(512 + 1) * 2];
SCAN_ORDER sc[TX_SIZES_ALL][TX_TYPES];
int16_t eob_threshold[TX_SIZES][TX_TYPES][EOB_THRESHOLD_NUM];
#endif // CONFIG_ADAPT_SCAN
#if CONFIG_LV_MAP
......
......@@ -6801,6 +6801,40 @@ void av1_init_scan_order(AV1_COMMON *cm) {
}
}
static void update_eob_threshold(AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type) {
int i, row, col, row_limit, col_limit, cal_idx = 0;
const int tx_width = tx_size_wide[tx_size];
const int tx_height = tx_size_high[tx_size];
row_limit = tx_width >> 1;
col_limit = tx_height >> 1;
if (tx_width >= 8 && tx_height >= 8) {
SCAN_ORDER *sc = &cm->fc->sc[tx_size][tx_type];
int16_t *threshold = &cm->fc->eob_threshold[tx_size][tx_type][0];
const int tx2d_size = tx_size_2d[tx_size];
while (cal_idx < EOB_THRESHOLD_NUM) {
for (i = 0; i < tx2d_size; ++i) {
row = sc->scan[i] / tx_height;
col = sc->scan[i] % tx_width;
if (row >= row_limit || col >= col_limit) break;
}
row_limit >>= 1;
col_limit >>= 1;
threshold[cal_idx] = i;
cal_idx++;
}
}
}
const EobThreshold *av1_get_eob_threshold(const AV1_COMMON *cm,
const TX_SIZE tx_size,
const TX_TYPE tx_type) {
return (const EobThreshold *)&cm->fc->eob_threshold[tx_size][tx_type];
}
void av1_adapt_scan_order(AV1_COMMON *cm) {
TX_SIZE tx_size;
for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
......@@ -6813,6 +6847,7 @@ void av1_adapt_scan_order(AV1_COMMON *cm) {
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE_16);
update_scan_order_facade(cm, tx_size, tx_type);
update_eob_threshold(cm, tx_size, tx_type);
}
}
}
......
......@@ -55,6 +55,11 @@ void av1_update_neighbors(int tx_size, const int16_t *scan,
const int16_t *iscan, int16_t *neighbors);
void av1_init_scan_order(AV1_COMMON *cm);
void av1_adapt_scan_order(AV1_COMMON *cm);
typedef int16_t EobThreshold[EOB_THRESHOLD_NUM];
const EobThreshold *av1_get_eob_threshold(const AV1_COMMON *cm,
const TX_SIZE tx_size,
const TX_TYPE tx_type);
#endif
static INLINE int get_coef_context(const int16_t *neighbors,
......
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