Commit 639c48f9 authored by Yushin Cho's avatar Yushin Cho
Browse files

Call tokenize_pvq() inside tokenize_b()

Since tokenize_b() is called by var-tx and several other experiments
during tokenization, in order for PVQ to run with those experiemnts
at the same time, it is required to call tokenize_pvq() from tokenize_b()
instead of av1_tokenize_sb().

Change-Id: I0450aa220b696efa3294952e47739acab707d483
parent 0d103578
......@@ -441,7 +441,6 @@ void av1_tokenize_palette_sb(const AV1_COMP *cpi,
}
#endif // CONFIG_PALETTE
#if !CONFIG_PVQ || CONFIG_VAR_TX
#if CONFIG_PALETTE && CONFIG_PALETTE_THROUGHPUT
void tokenize_palette_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
......@@ -507,8 +506,50 @@ void tokenize_palette_b(int plane, int block, int blk_row, int blk_col,
}
#endif // CONFIG_PALETTE && CONFIG_PALETTE_THROUGHPUT
#if CONFIG_PVQ
static void add_pvq_block(AV1_COMMON *const cm, MACROBLOCK *const x,
PVQ_INFO *pvq) {
PVQ_QUEUE *q = x->pvq_q;
if (q->curr_pos >= q->buf_len) {
int new_buf_len = 2 * q->buf_len + 1;
PVQ_INFO *new_buf;
CHECK_MEM_ERROR(cm, new_buf, aom_malloc(new_buf_len * sizeof(PVQ_INFO)));
memcpy(new_buf, q->buf, q->buf_len * sizeof(PVQ_INFO));
aom_free(q->buf);
q->buf = new_buf;
q->buf_len = new_buf_len;
}
OD_COPY(q->buf + q->curr_pos, pvq, 1);
++q->curr_pos;
}
// NOTE: This does not actually generate tokens, instead we store the encoding
// decisions made for PVQ in a queue that we will read from when
// actually writing the bitstream in write_modes_b
static void tokenize_pvq(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
const AV1_COMMON *const cm = &cpi->common;
ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb;
PVQ_INFO *pvq_info;
(void)block;
(void)blk_row;
(void)blk_col;
(void)plane_bsize;
(void)tx_size;
assert(block < MAX_PVQ_BLOCKS_IN_SB);
pvq_info = &x->pvq[block][plane];
add_pvq_block((AV1_COMMON * const)cm, x, pvq_info);
}
#endif // CONFIG_PVQ
static void tokenize_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
#if !CONFIG_PVQ
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
const AV1_COMMON *const cm = &cpi->common;
......@@ -663,6 +704,9 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
#endif
av1_set_contexts(xd, pd, plane, tx_size, c > 0, blk_col, blk_row);
#else // !CONFIG_PVQ
tokenize_pvq(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg);
#endif // !CONFIG_PVQ
}
#if CONFIG_PALETTE && CONFIG_PALETTE_THROUGHPUT
......@@ -674,7 +718,6 @@ void tokenize_joint_b(int plane, int block, int blk_row, int blk_col,
tokenize_b(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg);
}
#endif // CONFIG_PALETTE && CONFIG_PALETTE_THROUGHPUT
#endif // !CONFIG_PVQ
struct is_skippable_args {
uint16_t *eobs;
......@@ -701,46 +744,6 @@ int av1_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
return result;
}
#if CONFIG_PVQ
void add_pvq_block(AV1_COMMON *const cm, MACROBLOCK *const x, PVQ_INFO *pvq) {
PVQ_QUEUE *q = x->pvq_q;
if (q->curr_pos >= q->buf_len) {
int new_buf_len = 2 * q->buf_len + 1;
PVQ_INFO *new_buf;
CHECK_MEM_ERROR(cm, new_buf, aom_malloc(new_buf_len * sizeof(PVQ_INFO)));
memcpy(new_buf, q->buf, q->buf_len * sizeof(PVQ_INFO));
aom_free(q->buf);
q->buf = new_buf;
q->buf_len = new_buf_len;
}
// memcpy(q->buf + q->curr_pos, pvq, sizeof(PVQ_INFO));
OD_COPY(q->buf + q->curr_pos, pvq, 1);
++q->curr_pos;
}
// NOTE: This does not actually generate tokens, instead we store the encoding
// decisions made for PVQ in a queue that we will read from when
// actually writing the bitstream in write_modes_b
static void tokenize_pvq(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
const AV1_COMMON *const cm = &cpi->common;
ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb;
PVQ_INFO *pvq_info;
(void)block;
(void)blk_row;
(void)blk_col;
(void)plane_bsize;
(void)tx_size;
assert(block < MAX_PVQ_BLOCKS_IN_SB);
pvq_info = &x->pvq[block][plane];
add_pvq_block((AV1_COMMON * const)cm, x, pvq_info);
}
#endif // CONFIG_PVQ
#if CONFIG_VAR_TX
void tokenize_vartx(ThreadData *td, TOKENEXTRA **t, RUN_TYPE dry_run,
TX_SIZE tx_size, BLOCK_SIZE plane_bsize, int blk_row,
......@@ -876,7 +879,6 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
return;
}
#if !CONFIG_PVQ
if (!dry_run) {
#if CONFIG_COEF_INTERLEAVE
td->counts->skip[ctx][0] += skip_inc;
......@@ -893,8 +895,10 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) {
#if !CONFIG_PVQ
(*t)->token = EOSB_TOKEN;
(*t)++;
#endif
continue;
}
#else
......@@ -908,11 +912,15 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
av1_foreach_transformed_block_in_plane(xd, bsize, plane, tokenize_b,
&arg);
#endif // CONFIG_PALETTE && CONFIG_PALETTE_THROUGHPUT
#if !CONFIG_PVQ
(*t)->token = EOSB_TOKEN;
(*t)++;
#endif // !CONFIG_PVQ
}
#endif
} else if (dry_run == DRY_RUN_NORMAL) {
}
#if !CONFIG_PVQ
else if (dry_run == DRY_RUN_NORMAL) {
int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4
......@@ -939,25 +947,8 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
&arg);
}
}
#else
if (!dry_run) {
int plane;
td->counts->skip[ctx][0] += skip_inc;
#endif // !CONFIG_PVQ
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col))
continue;
#else
(void)mi_row;
(void)mi_col;
#endif
av1_foreach_transformed_block_in_plane(xd, bsize, plane, tokenize_pvq,
&arg);
}
}
#endif
if (rate) *rate += arg.this_rate;
}
......
Supports Markdown
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