Commit 4822e14c authored by Thomas Davies's avatar Thomas Davies

Add CONFIG_SIMPLE_BWD_ADAPT experiment.

Use just one tile for CDF backwards update.

Enable by default.

Change-Id: I0c89f87c16e5b24894f8cd3151efc5ad5aaecb49
parent bc732efc
......@@ -2215,6 +2215,9 @@ void av1_average_tile_coef_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
int i, cdf_size;
aom_cdf_prob *fc_cdf_ptr;
#if CONFIG_SIMPLE_BWD_ADAPT
assert(num_tiles == 1);
#endif
#if CONFIG_LV_MAP
AVERAGE_TILE_CDFS(txb_skip_cdf)
......@@ -2243,6 +2246,10 @@ void av1_average_tile_mv_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
aom_cdf_prob *fc_cdf_ptr;
#if CONFIG_SIMPLE_BWD_ADAPT
assert(num_tiles == 1);
#endif
int j;
for (j = 0; j < NMV_CONTEXTS; ++j) {
AVERAGE_TILE_CDFS(nmvc[j].joint_cdf)
......@@ -2265,6 +2272,9 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
aom_cdf_prob *cdf_ptr[], int num_tiles) {
int i, cdf_size;
#if CONFIG_SIMPLE_BWD_ADAPT
assert(num_tiles == 1);
#endif
aom_cdf_prob *fc_cdf_ptr;
AVERAGE_TILE_CDFS(tx_size_cdf)
......@@ -2325,6 +2335,9 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
aom_cdf_prob *cdf_ptr[], int num_tiles) {
int i, cdf_size;
#if CONFIG_SIMPLE_BWD_ADAPT
assert(num_tiles == 1);
#endif
aom_cdf_prob *fc_cdf_ptr;
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -231,6 +231,9 @@ typedef struct AV1Common {
// support additional planes.
int subsampling_x;
int subsampling_y;
#if CONFIG_SIMPLE_BWD_ADAPT
int largest_tile_id;
#endif
#if CONFIG_HIGHBITDEPTH
// Marks if we need to use 16bit frame buffers (1: yes, 0: no).
......
......@@ -3665,6 +3665,10 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
int tile_group_start_row = 0;
#endif
#if CONFIG_SIMPLE_BWD_ADAPT
size_t max_tile_size = 0;
cm->largest_tile_id = 0;
#endif
for (r = 0; r < tile_rows; ++r) {
for (c = 0; c < tile_cols; ++c, ++tc) {
TileBufferDec *const buf = &tile_buffers[r][c];
......@@ -3699,6 +3703,12 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
#if CONFIG_DEPENDENT_HORZTILES
cm->tile_group_start_row[r][c] = tile_group_start_row;
cm->tile_group_start_col[r][c] = tile_group_start_col;
#endif
#if CONFIG_SIMPLE_BWD_ADAPT
if (buf->size > max_tile_size) {
max_tile_size = buf->size;
cm->largest_tile_id = r * tile_cols + c;
}
#endif
}
}
......@@ -5461,11 +5471,11 @@ BITSTREAM_PROFILE av1_read_profile(struct aom_read_bit_buffer *rb) {
return (BITSTREAM_PROFILE)profile;
}
static void make_update_tile_list_dec(AV1Decoder *pbi, int tile_rows,
int tile_cols, FRAME_CONTEXT *ec_ctxs[]) {
static void make_update_tile_list_dec(AV1Decoder *pbi, int start_tile,
int num_tile, FRAME_CONTEXT *ec_ctxs[]) {
int i;
for (i = 0; i < tile_rows * tile_cols; ++i)
ec_ctxs[i] = &pbi->tile_data[i].tctx;
for (i = start_tile; i < start_tile + num_tile; ++i)
ec_ctxs[i - start_tile] = &pbi->tile_data[i].tctx;
}
#if CONFIG_FRAME_SUPERRES
......@@ -5766,12 +5776,21 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
if (!xd->corrupted) {
if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
FRAME_CONTEXT **tile_ctxs = aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&pbi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs =
aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&pbi->tile_data[0].tctx.partition_cdf[0][0]));
make_update_tile_list_dec(pbi, cm->tile_rows, cm->tile_cols, tile_ctxs);
#if CONFIG_SIMPLE_BWD_ADAPT
const int num_bwd_ctxs = 1;
#else
const int num_bwd_ctxs = cm->tile_rows * cm->tile_cols;
#endif
FRAME_CONTEXT **tile_ctxs =
aom_malloc(num_bwd_ctxs * sizeof(&pbi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs = aom_malloc(
num_bwd_ctxs * sizeof(&pbi->tile_data[0].tctx.partition_cdf[0][0]));
#if CONFIG_SIMPLE_BWD_ADAPT
make_update_tile_list_dec(pbi, cm->largest_tile_id, num_bwd_ctxs,
tile_ctxs);
#else
make_update_tile_list_dec(pbi, 0, num_bwd_ctxs, tile_ctxs);
#endif
#if CONFIG_LV_MAP
av1_adapt_coef_probs(cm);
#endif // CONFIG_LV_MAP
......@@ -5780,12 +5799,11 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
#endif
av1_adapt_intra_frame_probs(cm);
av1_average_tile_coef_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
av1_average_tile_intra_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
#if CONFIG_PVQ
av1_average_tile_pvq_cdfs(pbi->common.fc, tile_ctxs,
cm->tile_rows * cm->tile_cols);
av1_average_tile_pvq_cdfs(pbi->common.fc, tile_ctxs, num_bwd_ctxs);
#endif // CONFIG_PVQ
#if CONFIG_ADAPT_SCAN
av1_adapt_scan_order(cm);
......@@ -5797,9 +5815,9 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
av1_adapt_mv_probs(cm, cm->allow_high_precision_mv);
#endif
av1_average_tile_inter_cdfs(&pbi->common, pbi->common.fc, tile_ctxs,
cdf_ptrs, cm->tile_rows * cm->tile_cols);
cdf_ptrs, num_bwd_ctxs);
av1_average_tile_mv_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
}
aom_free(tile_ctxs);
aom_free(cdf_ptrs);
......
......@@ -3958,7 +3958,7 @@ static INLINE int find_identical_tile(
static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
unsigned int *max_tile_size,
unsigned int *max_tile_col_size) {
const AV1_COMMON *const cm = &cpi->common;
AV1_COMMON *const cm = &cpi->common;
aom_writer mode_bc;
int tile_row, tile_col;
TOKENEXTRA *(*const tok_buffers)[MAX_TILE_COLS] = cpi->tile_tok;
......@@ -3998,6 +3998,10 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
// All tile size fields are output on 4 bytes. A call to remux_tiles will
// later compact the data if smaller headers are adequate.
#if CONFIG_SIMPLE_BWD_ADAPT
cm->largest_tile_id = 0;
#endif
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
......@@ -4044,6 +4048,11 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
#endif
buf->size = tile_size;
#if CONFIG_SIMPLE_BWD_ADAPT
if (tile_size > *max_tile_size) {
cm->largest_tile_id = tile_cols * tile_row + tile_col;
}
#endif
// Record the maximum tile size we see, so we can compact headers later.
*max_tile_size = AOMMAX(*max_tile_size, tile_size);
......@@ -4237,6 +4246,11 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
curr_tg_data_size += tile_size + 4;
buf->size = tile_size;
#if CONFIG_SIMPLE_BWD_ADAPT
if (tile_size > *max_tile_size) {
cm->largest_tile_id = tile_cols * tile_row + tile_col;
}
#endif
if (!is_last_tile) {
*max_tile_size = AOMMAX(*max_tile_size, tile_size);
// size of this tile
......@@ -5592,7 +5606,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
uint8_t *const frame_header_obu_location,
uint32_t frame_header_obu_size,
int insert_frame_header_obu_flag) {
const AV1_COMMON *const cm = &cpi->common;
AV1_COMMON *const cm = &cpi->common;
aom_writer mode_bc;
int tile_row, tile_col;
TOKENEXTRA *(*const tok_buffers)[MAX_TILE_COLS] = cpi->tile_tok;
......@@ -5619,6 +5633,9 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
const int have_tiles = tile_cols * tile_rows > 1;
#endif
#if CONFIG_SIMPLE_BWD_ADAPT
cm->largest_tile_id = 0;
#endif
*max_tile_size = 0;
*max_tile_col_size = 0;
......@@ -5669,7 +5686,12 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
buf->size = tile_size;
// Record the maximum tile size we see, so we can compact headers later.
*max_tile_size = AOMMAX(*max_tile_size, tile_size);
if (tile_size > *max_tile_size) {
*max_tile_size = tile_size;
#if CONFIG_SIMPLE_BWD_ADAPT
cm->largest_tile_id = tile_cols * tile_row + tile_col;
#endif
}
if (have_tiles) {
// tile header: size of this tile, or copy offset
......@@ -5791,10 +5813,15 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
curr_tg_data_size += (tile_size + (is_last_tile_in_tg ? 0 : 4));
buf->size = tile_size;
#if CONFIG_SIMPLE_BWD_ADAPT
if (tile_size > *max_tile_size) {
cm->largest_tile_id = tile_cols * tile_row + tile_col;
}
#endif
if (!is_last_tile) {
*max_tile_size = AOMMAX(*max_tile_size, tile_size);
}
if (!is_last_tile_in_tg) {
// size of this tile
mem_put_le32(buf->data, tile_size);
......
......@@ -5352,12 +5352,12 @@ static void dump_filtered_recon_frames(AV1_COMP *cpi) {
}
#endif // DUMP_RECON_FRAMES
static void make_update_tile_list_enc(AV1_COMP *cpi, const int tile_rows,
const int tile_cols,
static void make_update_tile_list_enc(AV1_COMP *cpi, const int start_tile,
const int num_tiles,
FRAME_CONTEXT *ec_ctxs[]) {
int i;
for (i = 0; i < tile_rows * tile_cols; ++i)
ec_ctxs[i] = &cpi->tile_data[i].tctx;
for (i = start_tile; i < start_tile + num_tiles; ++i)
ec_ctxs[i - start_tile] = &cpi->tile_data[i].tctx;
}
static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
......@@ -5366,11 +5366,16 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
AV1_COMMON *const cm = &cpi->common;
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
struct segmentation *const seg = &cm->seg;
FRAME_CONTEXT **tile_ctxs = aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&cpi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs =
aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&cpi->tile_data[0].tctx.partition_cdf[0][0]));
#if CONFIG_SIMPLE_BWD_ADAPT
const int num_bwd_ctxs = 1;
#else
const int num_bwd_ctxs = cm->tile_rows * cm->tile_cols;
#endif
FRAME_CONTEXT **tile_ctxs =
aom_malloc(num_bwd_ctxs * sizeof(&cpi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs = aom_malloc(
num_bwd_ctxs * sizeof(&cpi->tile_data[0].tctx.partition_cdf[0][0]));
#if CONFIG_XIPHRC
int frame_type;
int drop_this_frame = 0;
......@@ -5691,14 +5696,17 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
av1_adapt_coef_probs(cm);
#endif // CONFIG_LV_MAP
av1_adapt_intra_frame_probs(cm);
make_update_tile_list_enc(cpi, cm->tile_rows, cm->tile_cols, tile_ctxs);
#if CONFIG_SIMPLE_BWD_ADAPT
make_update_tile_list_enc(cpi, cm->largest_tile_id, 1, tile_ctxs);
#else
make_update_tile_list_enc(cpi, 0, num_bwd_ctxs, tile_ctxs);
#endif
av1_average_tile_coef_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
av1_average_tile_intra_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
#if CONFIG_PVQ
av1_average_tile_pvq_cdfs(cpi->common.fc, tile_ctxs,
cm->tile_rows * cm->tile_cols);
av1_average_tile_pvq_cdfs(cpi->common.fc, tile_ctxs, num_bwd_ctxs);
#endif // CONFIG_PVQ
#if CONFIG_ADAPT_SCAN
av1_adapt_scan_order(cm);
......@@ -5710,9 +5718,9 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
av1_adapt_inter_frame_probs(cm);
av1_adapt_mv_probs(cm, cm->allow_high_precision_mv);
av1_average_tile_inter_cdfs(&cpi->common, cpi->common.fc, tile_ctxs,
cdf_ptrs, cm->tile_rows * cm->tile_cols);
cdf_ptrs, num_bwd_ctxs);
av1_average_tile_mv_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
num_bwd_ctxs);
}
}
......
......@@ -198,6 +198,7 @@ set(CONFIG_REF_ADAPT 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_RESTRICT_COMPRESSED_HDR 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SBL_SYMBOL 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SEGMENT_ZEROMV 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SIMPLE_BWD_ADAPT 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SMOOTH_HV 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_STRIPED_LOOP_RESTORATION 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SUPERTX 0 CACHE NUMBER "AV1 experiment flag.")
......
......@@ -355,6 +355,7 @@ EXPERIMENT_LIST="
ext_warped_motion
restrict_compressed_hdr
horzonly_frame_superres
simple_bwd_adapt
"
CONFIG_LIST="
dependency_tracking
......@@ -545,6 +546,7 @@ post_process_cmdline() {
soft_enable ext_comp_refs
soft_enable ext_delta_q
soft_enable parallel_deblocking
soft_enable simple_bwd_adapt
fi
# Enable low-bitdepth pixel pipeline by default
......
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