Commit ff0da2b4 authored by hui su's avatar hui su Committed by Hui Su

Code refactoring in adapt-scan

Change-Id: Ie20bd0b05bbf3128933f10787aade7b63c98b52a
parent b3be926a
......@@ -5584,10 +5584,6 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
TX_SIZE tx_size;
unsigned int count_sat, update_factor;
#if CONFIG_ADAPT_SCAN
TX_TYPE tx_type;
#endif
if (!frame_is_intra_only(cm) && cm->last_frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY;
......@@ -5601,25 +5597,6 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
for (tx_size = 0; tx_size < TX_SIZES; tx_size++)
adapt_coef_probs(cm, tx_size, count_sat, update_factor);
#if CONFIG_SUBFRAME_PROB_UPDATE
if (cm->partial_prob_update == 0)
#endif // CONFIG_SUBFRAME_PROB_UPDATE
{
#if CONFIG_ADAPT_SCAN
for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
#if !(CONFIG_VAR_TX || CONFIG_RECT_TX)
if (tx_size >= TX_SIZES) continue;
#else
if (tx_size > TX_32X16) continue;
#endif // !(CONFIG_VAR_TX || CONFIG_RECT_TX)
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
av1_update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE_16);
av1_update_scan_order_facade(cm, tx_size, tx_type);
}
}
#endif // CONFIG_ADAPT_SCAN
}
}
#if CONFIG_SUBFRAME_PROB_UPDATE
......
......@@ -6600,8 +6600,8 @@ static uint32_t *get_non_zero_counts(FRAME_COUNTS *counts, TX_SIZE tx_size,
}
}
void av1_update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
int rate_16) {
static void update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
int rate_16) {
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
uint32_t *prev_non_zero_prob = get_non_zero_prob(pre_fc, tx_size, tx_type);
uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
......@@ -6757,8 +6757,8 @@ void av1_update_scan_order(TX_SIZE tx_size, int16_t *sort_order, int16_t *scan,
}
}
void av1_update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type) {
static void update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type) {
int16_t sort_order[COEFF_IDX_SIZE];
uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
int16_t *scan = get_adapt_scan(cm->fc, tx_size, tx_type);
......@@ -6787,11 +6787,27 @@ void av1_init_scan_order(AV1_COMMON *cm) {
for (i = 0; i < tx2d_size; ++i) {
non_zero_prob[i] = (1 << 16) / 2; // init non_zero_prob to 0.5
}
av1_update_scan_order_facade(cm, tx_size, tx_type);
update_scan_order_facade(cm, tx_size, tx_type);
sc->scan = get_adapt_scan(cm->fc, tx_size, tx_type);
sc->iscan = get_adapt_iscan(cm->fc, tx_size, tx_type);
sc->neighbors = get_adapt_nb(cm->fc, 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) {
#if !(CONFIG_VAR_TX || CONFIG_RECT_TX)
if (tx_size >= TX_SIZES) continue;
#else
if (tx_size > TX_32X16) continue;
#endif // !(CONFIG_VAR_TX || CONFIG_RECT_TX)
TX_TYPE tx_type;
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);
}
}
}
#endif // CONFIG_ADAPT_SCAN
......@@ -30,8 +30,6 @@ extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES_ALL][TX_TYPES];
extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
#if CONFIG_ADAPT_SCAN
void av1_update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
int rate_16);
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);
......@@ -55,9 +53,8 @@ void av1_update_scan_order(TX_SIZE tx_size, int16_t *sort_order, int16_t *scan,
// neighbors[] accordingly.
void av1_update_neighbors(int tx_size, const int16_t *scan,
const int16_t *iscan, int16_t *neighbors);
void av1_update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type);
void av1_init_scan_order(AV1_COMMON *cm);
void av1_adapt_scan_order(AV1_COMMON *cm);
#endif
static INLINE int get_coef_context(const int16_t *neighbors,
......
......@@ -63,12 +63,12 @@
#define ACCT_STR __func__
#if CONFIG_PVQ
#include "av1/decoder/pvq_decoder.h"
#include "av1/common/pvq.h"
#include "av1/encoder/encodemb.h"
#include "av1/common/partition.h"
#include "av1/common/pvq.h"
#include "av1/common/scan.h"
#include "av1/decoder/decint.h"
#include "av1/decoder/pvq_decoder.h"
#include "av1/encoder/encodemb.h"
#include "av1/encoder/hybrid_fwd_txfm.h"
#endif
......@@ -5043,6 +5043,9 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
#endif // CONFIG_SUBFRAME_PROB_UPDATE
av1_adapt_coef_probs(cm);
av1_adapt_intra_frame_probs(cm);
#if CONFIG_ADAPT_SCAN
av1_adapt_scan_order(cm);
#endif // CONFIG_ADAPT_SCAN
if (!frame_is_intra_only(cm)) {
av1_adapt_inter_frame_probs(cm);
......
......@@ -4949,6 +4949,9 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
#endif // CONFIG_SUBFRAME_PROB_UPDATE
av1_adapt_coef_probs(cm);
av1_adapt_intra_frame_probs(cm);
#if CONFIG_ADAPT_SCAN
av1_adapt_scan_order(cm);
#endif // CONFIG_ADAPT_SCAN
}
if (!frame_is_intra_only(cm)) {
......
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