Deliver the eob threshold to inverse transform
Change-Id: Iaa8ab77eb4a982759939fb5fc475f699cb21a4e1
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 3d9e4e1..5b0bae8 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -494,6 +494,7 @@
struct scale_factors sf;
} RefBuffer;
+typedef int16_t EobThresholdMD[TX_SIZES_ALL][TX_TYPES];
typedef struct macroblockd {
struct macroblockd_plane plane[MAX_MB_PLANE];
uint8_t bmode_blocks_wl;
@@ -579,6 +580,9 @@
int delta_qindex;
int current_qindex;
#endif
+#if CONFIG_ADAPT_SCAN
+ const EobThresholdMD *eob_threshold_md;
+#endif
} MACROBLOCKD;
static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize,
diff --git a/av1/common/idct.c b/av1/common/idct.c
index fc58d00..8d2e92b 100644
--- a/av1/common/idct.c
+++ b/av1/common/idct.c
@@ -2781,6 +2781,20 @@
}
}
+static void init_inv_txfm_param(const MACROBLOCKD *xd, TX_SIZE tx_size,
+ TX_TYPE tx_type, int eob, INV_TXFM_PARAM *inv) {
+ inv->tx_type = tx_type;
+ inv->tx_size = tx_size;
+ inv->eob = eob;
+ inv->lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
+#if CONFIG_HIGHBITDEPTH
+ inv->bd = xd->bd;
+#endif
+#if CONFIG_ADAPT_SCAN
+ inv->eob_threshold = &xd->eob_threshold_md[tx_size][tx_type][0];
+#endif
+}
+
void av1_inverse_transform_block(MACROBLOCKD *xd, const tran_low_t *dqcoeff,
const TX_TYPE tx_type, const TX_SIZE tx_size,
uint8_t *dst, int stride, int eob) {
@@ -2805,14 +2819,10 @@
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_PVQ
INV_TXFM_PARAM inv_txfm_param;
- inv_txfm_param.tx_type = tx_type;
- inv_txfm_param.tx_size = tx_size;
- inv_txfm_param.eob = eob;
- inv_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
+ init_inv_txfm_param(xd, tx_size, tx_type, eob, &inv_txfm_param);
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- inv_txfm_param.bd = xd->bd;
av1_highbd_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param);
} else {
#endif // CONFIG_HIGHBITDEPTH
diff --git a/av1/common/idct.h b/av1/common/idct.h
index 1c093ab..a0c421f 100644
--- a/av1/common/idct.h
+++ b/av1/common/idct.h
@@ -27,6 +27,9 @@
#endif
typedef struct INV_TXFM_PARAM {
+#if CONFIG_ADAPT_SCAN
+ const int16_t *eob_threshold;
+#endif
TX_TYPE tx_type;
TX_SIZE tx_size;
int eob;
diff --git a/av1/common/scan.c b/av1/common/scan.c
index 41ed284..9ad6c0b 100644
--- a/av1/common/scan.c
+++ b/av1/common/scan.c
@@ -6776,31 +6776,6 @@
av1_update_neighbors(tx_size, scan, iscan, nb);
}
-void av1_init_scan_order(AV1_COMMON *cm) {
- TX_SIZE tx_size;
- TX_TYPE tx_type;
- 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;
-#else
- if (tx_size >= TX_SIZES) continue;
-#endif // CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
- 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];
- int i;
- SCAN_ORDER *sc = &cm->fc->sc[tx_size][tx_type];
- for (i = 0; i < tx2d_size; ++i) {
- non_zero_prob[i] = (1 << 16) / 2; // init non_zero_prob to 0.5
- }
- 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);
- }
- }
-}
-
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;
@@ -6829,10 +6804,30 @@
}
}
-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_init_scan_order(AV1_COMMON *cm) {
+ TX_SIZE tx_size;
+ TX_TYPE tx_type;
+ 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;
+#else
+ if (tx_size >= TX_SIZES) continue;
+#endif // CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
+ 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];
+ int i;
+ SCAN_ORDER *sc = &cm->fc->sc[tx_size][tx_type];
+ for (i = 0; i < tx2d_size; ++i) {
+ non_zero_prob[i] = (1 << 16) / 2; // init non_zero_prob to 0.5
+ }
+ 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);
+ update_eob_threshold(cm, tx_size, tx_type);
+ }
+ }
}
void av1_adapt_scan_order(AV1_COMMON *cm) {
@@ -6851,4 +6846,8 @@
}
}
}
+
+void av1_deliver_eob_threshold(const AV1_COMMON *cm, MACROBLOCKD *xd) {
+ xd->eob_threshold_md = (const EobThresholdMD *)cm->fc->eob_threshold;
+}
#endif // CONFIG_ADAPT_SCAN
diff --git a/av1/common/scan.h b/av1/common/scan.h
index 0f5ffdc..ecef113 100644
--- a/av1/common/scan.h
+++ b/av1/common/scan.h
@@ -55,12 +55,8 @@
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
+void av1_deliver_eob_threshold(const AV1_COMMON *cm, MACROBLOCKD *xd);
static INLINE int get_coef_context(const int16_t *neighbors,
const uint8_t *token_cache, int c) {
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 2285b1f..d555108 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -4831,6 +4831,9 @@
size_t first_partition_size;
YV12_BUFFER_CONFIG *new_fb;
+#if CONFIG_ADAPT_SCAN
+ av1_deliver_eob_threshold(cm, xd);
+#endif
#if CONFIG_BITSTREAM_DEBUG
bitstream_queue_set_frame_read(cm->current_video_frame * 2 + cm->show_frame);
#endif
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 0b53c02..8b77a83 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -5093,6 +5093,10 @@
RD_COUNTS *const rdc = &cpi->td.rd_counts;
int i;
+#if CONFIG_ADAPT_SCAN
+ av1_deliver_eob_threshold(cm, xd);
+#endif
+
x->min_partition_size = AOMMIN(x->min_partition_size, cm->sb_size);
x->max_partition_size = AOMMIN(x->max_partition_size, cm->sb_size);
#if CONFIG_REF_MV