Commit f8e87b46 authored by Yi Luo's avatar Yi Luo

Deliver the eob threshold to inverse transform

Change-Id: Iaa8ab77eb4a982759939fb5fc475f699cb21a4e1
parent a4d87992
......@@ -494,6 +494,7 @@ typedef struct RefBuffer {
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 @@ typedef struct macroblockd {
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,
......
......@@ -2781,6 +2781,20 @@ void av1_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
}
}
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 @@ void av1_inverse_transform_block(MACROBLOCKD *xd, const tran_low_t *dqcoeff,
#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
......
......@@ -27,6 +27,9 @@ extern "C" {
#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;
......
......@@ -6776,31 +6776,6 @@ static void update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
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 @@ static void update_eob_threshold(AV1_COMMON *cm, TX_SIZE tx_size,
}
}
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_adapt_scan_order(AV1_COMMON *cm) {
}
}
}
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
......@@ -55,12 +55,8 @@ void av1_update_neighbors(int tx_size, const int16_t *scan,
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) {
......
......@@ -4831,6 +4831,9 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
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
......
......@@ -5093,6 +5093,10 @@ static void encode_frame_internal(AV1_COMP *cpi) {
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
......
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