Commit 6dbffbf1 authored by Angie Chiang's avatar Angie Chiang

Add frame-level flag to turn on/off adapt_scan

Change-Id: I7a73dbe72b618e795191cc31bc32e31ad99d8587
parent 952eae29
......@@ -541,6 +541,9 @@ typedef struct AV1Common {
#if CONFIG_LPF_SB
int final_lpf_encode;
#endif
#if CONFIG_ADAPT_SCAN
int use_adapt_scan;
#endif
} AV1_COMMON;
// TODO(hkuang): Don't need to lock the whole pool after implementing atomic
......
......@@ -8239,7 +8239,7 @@ 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) {
if (do_adapt_scan(tx_size, tx_type)) {
if (cm->use_adapt_scan && do_adapt_scan(tx_size, tx_type)) {
int16_t *scan = get_adapt_scan(cm->fc, tx_size, tx_type);
uint32_t *non_zero_count = get_non_zero_counts(counts, tx_size, tx_type);
update_scan_count(scan, max_scan, dqcoeffs, non_zero_count);
......@@ -8550,25 +8550,27 @@ void av1_init_scan_order(AV1_COMMON *cm) {
}
void av1_adapt_scan_order(AV1_COMMON *cm) {
TX_SIZE tx_size;
if (cm->use_adapt_scan) {
TX_SIZE tx_size;
#if CACHE_SCAN_PROB
int use_curr_frame = 0;
int use_curr_frame = 0;
#else // CACHE_SCAN_PROB
int use_curr_frame = 1;
int use_curr_frame = 1;
#endif // CACHE_SCAN_PROB
for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
#if CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
if (tx_size > TX_32X16) continue;
if (tx_size > TX_32X16) continue;
#else
if (tx_size >= TX_SIZES) continue;
if (tx_size >= TX_SIZES) continue;
#endif // CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
TX_TYPE tx_type;
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
if (do_adapt_scan(tx_size, tx_type)) {
update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE);
update_scan_order_facade(cm, tx_size, tx_type, use_curr_frame);
update_eob_threshold(cm, tx_size, tx_type);
TX_TYPE tx_type;
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
if (do_adapt_scan(tx_size, tx_type)) {
update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE);
update_scan_order_facade(cm, tx_size, tx_type, use_curr_frame);
update_eob_threshold(cm, tx_size, tx_type);
}
}
}
}
......
......@@ -5167,6 +5167,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
cm->reduced_tx_set_used = aom_rb_read_bit(rb);
#endif // CONFIG_EXT_TX
#if CONFIG_ADAPT_SCAN
cm->use_adapt_scan = aom_rb_read_bit(rb);
// TODO(angiebird): call av1_init_scan_order only when use_adapt_scan
// switches from 1 to 0
if (cm->use_adapt_scan == 0) av1_init_scan_order(cm);
#endif // CONFIG_ADAPT_SCAN
#if CONFIG_EXT_REFS || CONFIG_TEMPMV_SIGNALING
// NOTE(zoeliu): As cm->prev_frame can take neither a frame of
// show_exisiting_frame=1, nor can it take a frame not used as
......
......@@ -4813,6 +4813,10 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
aom_wb_write_bit(wb, cm->reduced_tx_set_used);
#endif // CONFIG_EXT_TX
#if CONFIG_ADAPT_SCAN
aom_wb_write_bit(wb, cm->use_adapt_scan);
#endif
#if CONFIG_GLOBAL_MOTION
if (!frame_is_intra_only(cm)) write_global_motion(cpi, wb);
#endif // CONFIG_GLOBAL_MOTION
......
......@@ -5579,6 +5579,12 @@ void av1_encode_frame(AV1_COMP *cpi) {
// rather than the potential full set of 16 transforms
cm->reduced_tx_set_used = 0;
#endif // CONFIG_EXT_TX
#if CONFIG_ADAPT_SCAN
cm->use_adapt_scan = 1;
// TODO(angiebird): call av1_init_scan_order only when use_adapt_scan
// switches from 1 to 0
if (cm->use_adapt_scan == 0) av1_init_scan_order(cm);
#endif
#if CONFIG_FRAME_MARKER
if (cm->show_frame == 0) {
......
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