Commit a6b0c4c9 authored by Jingning Han's avatar Jingning Han

Support adaptive scan order in cb4x4 mode

This commit adds 2x2 transform block scan order to make the
adaptive scan order support cb4x4 mode.

BUG=aomedia:135

Change-Id: Ic8c3ae9ed65d577df629524b617b386b5e799d4c
parent 25f2f7d9
......@@ -3588,7 +3588,7 @@ void av1_adapt_coef_probs(AV1_COMMON *cm) {
adapt_coef_probs(cm, tx_size, count_sat, update_factor);
#if CONFIG_ADAPT_SCAN
for (tx_size = TX_4X4; tx_size < TX_SIZES; ++tx_size)
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size)
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);
......
......@@ -67,24 +67,35 @@ typedef struct frame_contexts {
#endif // CONFIG_EC_MULTISYMBOL
aom_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS - 1];
#if CONFIG_ADAPT_SCAN
// TODO(angiebird): try aom_prob
// TODO(angiebird): try aom_prob
#if CONFIG_CB4X4
uint32_t non_zero_prob_2x2[TX_TYPES][4];
#endif
uint32_t non_zero_prob_4X4[TX_TYPES][16];
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];
#if CONFIG_CB4X4
DECLARE_ALIGNED(16, int16_t, scan_2x2[TX_TYPES][4]);
#endif
DECLARE_ALIGNED(16, int16_t, scan_4X4[TX_TYPES][16]);
DECLARE_ALIGNED(16, int16_t, scan_8X8[TX_TYPES][64]);
DECLARE_ALIGNED(16, int16_t, scan_16X16[TX_TYPES][256]);
DECLARE_ALIGNED(16, int16_t, scan_32X32[TX_TYPES][1024]);
#if CONFIG_CB4X4
DECLARE_ALIGNED(16, int16_t, iscan_2x2[TX_TYPES][4]);
#endif
DECLARE_ALIGNED(16, int16_t, iscan_4X4[TX_TYPES][16]);
DECLARE_ALIGNED(16, int16_t, iscan_8X8[TX_TYPES][64]);
DECLARE_ALIGNED(16, int16_t, iscan_16X16[TX_TYPES][256]);
DECLARE_ALIGNED(16, int16_t, iscan_32X32[TX_TYPES][1024]);
#if CONFIG_CB4X4
int16_t nb_2x2[TX_TYPES][(4 + 1) * 2];
#endif
int16_t nb_4X4[TX_TYPES][(16 + 1) * 2];
int16_t nb_8X8[TX_TYPES][(64 + 1) * 2];
int16_t nb_16X16[TX_TYPES][(256 + 1) * 2];
......@@ -199,12 +210,15 @@ typedef struct FRAME_COUNTS {
unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
#if CONFIG_ADAPT_SCAN
#if CONFIG_CB4X4
unsigned int non_zero_count_2x2[TX_TYPES][4];
#endif // CONFIG_CB4X4
unsigned int non_zero_count_4X4[TX_TYPES][16];
unsigned int non_zero_count_8X8[TX_TYPES][64];
unsigned int non_zero_count_16X16[TX_TYPES][256];
unsigned int non_zero_count_32X32[TX_TYPES][1024];
unsigned int txb_count[TX_SIZES][TX_TYPES];
#endif
#endif // CONFIG_ADAPT_SCAN
#if CONFIG_REF_MV
unsigned int newmv_mode[NEWMV_MODE_CONTEXTS][2];
......
......@@ -6493,6 +6493,9 @@ const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES] = {
static uint32_t *get_non_zero_prob(FRAME_CONTEXT *fc, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
#if CONFIG_CB4X4
case TX_2X2: return fc->non_zero_prob_2x2[tx_type];
#endif
case TX_4X4: return fc->non_zero_prob_4X4[tx_type];
case TX_8X8: return fc->non_zero_prob_8X8[tx_type];
case TX_16X16: return fc->non_zero_prob_16X16[tx_type];
......@@ -6504,6 +6507,9 @@ static uint32_t *get_non_zero_prob(FRAME_CONTEXT *fc, TX_SIZE tx_size,
static int16_t *get_adapt_scan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
#if CONFIG_CB4X4
case TX_2X2: return fc->scan_2x2[tx_type];
#endif
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];
......@@ -6515,6 +6521,9 @@ static int16_t *get_adapt_scan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
static int16_t *get_adapt_iscan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
#if CONFIG_CB4X4
case TX_2X2: return fc->iscan_2x2[tx_type];
#endif
case TX_4X4: return fc->iscan_4X4[tx_type];
case TX_8X8: return fc->iscan_8X8[tx_type];
case TX_16X16: return fc->iscan_16X16[tx_type];
......@@ -6526,6 +6535,9 @@ static int16_t *get_adapt_iscan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
static int16_t *get_adapt_nb(FRAME_CONTEXT *fc, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
#if CONFIG_CB4X4
case TX_2X2: return fc->nb_2x2[tx_type];
#endif
case TX_4X4: return fc->nb_4X4[tx_type];
case TX_8X8: return fc->nb_8X8[tx_type];
case TX_16X16: return fc->nb_16X16[tx_type];
......@@ -6537,6 +6549,9 @@ static int16_t *get_adapt_nb(FRAME_CONTEXT *fc, TX_SIZE tx_size,
static uint32_t *get_non_zero_counts(FRAME_COUNTS *counts, TX_SIZE tx_size,
TX_TYPE tx_type) {
switch (tx_size) {
#if CONFIG_CB4X4
case TX_2X2: return counts->non_zero_count_2x2[tx_type];
#endif
case TX_4X4: return counts->non_zero_count_4X4[tx_type];
case TX_8X8: return counts->non_zero_count_8X8[tx_type];
case TX_16X16: return counts->non_zero_count_16X16[tx_type];
......@@ -6716,7 +6731,7 @@ void av1_update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
void av1_init_scan_order(AV1_COMMON *cm) {
TX_SIZE tx_size;
TX_TYPE tx_type;
for (tx_size = TX_4X4; tx_size < TX_SIZES; ++tx_size) {
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
const int tx2d_size = tx_size_2d[tx_size];
......
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