Commit caaa43d9 authored by Angie Chiang's avatar Angie Chiang
Browse files

Add update_scan_count_facade()

This function is used to update nonzero count when encode/decode
transform blocks

Change-Id: I6717170e39efe0e103237116fa8c22ccec87c829
parent 5cb9f2e5
......@@ -74,6 +74,11 @@ typedef struct frame_contexts {
uint32_t non_zero_prob_8X8[TX_TYPES][64];
uint32_t non_zero_prob_16X16[TX_TYPES][256];
uint32_t non_zero_prob_32X32[TX_TYPES][1024];
int16_t scan_4X4[TX_TYPES][16];
int16_t scan_8X8[TX_TYPES][64];
int16_t scan_16X16[TX_TYPES][256];
int16_t scan_32X32[TX_TYPES][1024];
#endif
#if CONFIG_REF_MV
......
......@@ -759,6 +759,16 @@ uint32_t *get_non_zero_prob(FRAME_CONTEXT *fc, TX_SIZE tx_size,
}
}
int16_t *get_adapt_scan(FRAME_CONTEXT *fc, TX_SIZE tx_size, TX_TYPE tx_type) {
switch (tx_size) {
case TX_4X4: return fc->scan_4X4[tx_type];
case TX_8X8: return fc->scan_8X8[tx_type];
case TX_16X16: return fc->scan_16X16[tx_type];
case TX_32X32: return fc->scan_32X32[tx_type];
default: assert(0); return NULL;
}
}
uint32_t *get_non_zero_counts(FRAME_COUNTS *counts, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
......@@ -794,4 +804,20 @@ void update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
non_zero_prob[i] = clamp(pred_prob, 0, UINT16_MAX);
}
}
void update_scan_count(int16_t *scan, int max_scan, tran_low_t *dqcoeffs,
uint32_t *non_zero_count) {
int i;
for (i = 0; i < max_scan; ++i) {
int coeff_idx = scan[i];
non_zero_count[coeff_idx] += (dqcoeffs[coeff_idx] != 0);
}
}
void update_scan_count_facade(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
tran_low_t *dqcoeffs, int max_scan) {
int16_t *scan = get_adapt_scan(cm->fc, tx_size, tx_type);
uint32_t *non_zero_count = get_non_zero_counts(&cm->counts, tx_size, tx_type);
update_scan_count(scan, max_scan, dqcoeffs, non_zero_count);
}
#endif
......@@ -37,6 +37,8 @@ extern const SCAN_ORDER av1_scan_orders[TX_SIZES][TX_TYPES];
#if CONFIG_ADAPT_SCAN
void update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
int rate_16);
void update_scan_count_facade(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
tran_low_t *dqcoeffs, int max_scan);
#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