Commit b25ba508 authored by Thomas Davies's avatar Thomas Davies
Browse files

Remove the CONFIG_TILE_GROUPS experimental flag.

Tile groups are now an integral part of the codec.

Change-Id: I620a88ec7a44b057d5cce0bf6cf602822a3339a9
parent f99e9ed4
......@@ -418,14 +418,12 @@ static const arg_def_t qm_min = ARG_DEF(
static const arg_def_t qm_max = ARG_DEF(
NULL, "qm-max", 1, "Max quant matrix flatness (0..15), default is 16");
#endif
#if CONFIG_TILE_GROUPS
static const arg_def_t num_tg = ARG_DEF(
NULL, "num-tile-groups", 1, "Maximum number of tile groups, default is 1");
static const arg_def_t mtu_size =
ARG_DEF(NULL, "mtu-size", 1,
"MTU size for a tile group, default is 0 (no MTU targeting), "
"overrides maximum number of tile groups");
#endif
#if CONFIG_TEMPMV_SIGNALING
static const arg_def_t disable_tempmv = ARG_DEF(
NULL, "disable-tempmv", 1, "Disable temporal mv prediction (default is 0)");
......@@ -581,10 +579,8 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
#if CONFIG_EXT_PARTITION
&superblock_size,
#endif // CONFIG_EXT_PARTITION
#if CONFIG_TILE_GROUPS
&num_tg,
&mtu_size,
#endif
#if CONFIG_TEMPMV_SIGNALING
&disable_tempmv,
#endif
......@@ -639,10 +635,8 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
#if CONFIG_EXT_PARTITION
AV1E_SET_SUPERBLOCK_SIZE,
#endif // CONFIG_EXT_PARTITION
#if CONFIG_TILE_GROUPS
AV1E_SET_NUM_TG,
AV1E_SET_MTU,
#endif
#if CONFIG_TEMPMV_SIGNALING
AV1E_SET_DISABLE_TEMPMV,
#endif
......
......@@ -55,10 +55,8 @@ struct av1_extracfg {
unsigned int qm_min;
unsigned int qm_max;
#endif
#if CONFIG_TILE_GROUPS
unsigned int num_tg;
unsigned int mtu_size;
#endif
#if CONFIG_TEMPMV_SIGNALING
unsigned int disable_tempmv;
#endif
......@@ -121,10 +119,8 @@ static struct av1_extracfg default_extra_cfg = {
DEFAULT_QM_FIRST, // qm_min
DEFAULT_QM_LAST, // qm_max
#endif
#if CONFIG_TILE_GROUPS
1, // max number of tile groups
0, // mtu_size
#endif
#if CONFIG_TEMPMV_SIGNALING
0, // disable temporal mv prediction
#endif
......@@ -482,14 +478,12 @@ static aom_codec_err_t set_encoder_config(
oxcf->qm_maxlevel = extra_cfg->qm_max;
#endif
#if CONFIG_TILE_GROUPS
oxcf->num_tile_groups = extra_cfg->num_tg;
#if CONFIG_EXT_TILE
// In large-scale tile encoding mode, num_tile_groups is always 1.
if (cfg->large_scale_tile) oxcf->num_tile_groups = 1;
#endif // CONFIG_EXT_TILE
oxcf->mtu = extra_cfg->mtu_size;
#endif
#if CONFIG_TEMPMV_SIGNALING
oxcf->disable_tempmv = extra_cfg->disable_tempmv;
......@@ -869,7 +863,6 @@ static aom_codec_err_t ctrl_set_qm_max(aom_codec_alg_priv_t *ctx,
}
#endif
#if CONFIG_TILE_GROUPS
static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
......@@ -882,7 +875,6 @@ static aom_codec_err_t ctrl_set_mtu(aom_codec_alg_priv_t *ctx, va_list args) {
extra_cfg.mtu_size = CAST(AV1E_SET_MTU, args);
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
#if CONFIG_TEMPMV_SIGNALING
static aom_codec_err_t ctrl_set_disable_tempmv(aom_codec_alg_priv_t *ctx,
va_list args) {
......@@ -1545,10 +1537,8 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_QM_MIN, ctrl_set_qm_min },
{ AV1E_SET_QM_MAX, ctrl_set_qm_max },
#endif
#if CONFIG_TILE_GROUPS
{ AV1E_SET_NUM_TG, ctrl_set_num_tg },
{ AV1E_SET_MTU, ctrl_set_mtu },
#endif
#if CONFIG_TEMPMV_SIGNALING
{ AV1E_SET_DISABLE_TEMPMV, ctrl_set_disable_tempmv },
#endif
......
......@@ -196,11 +196,7 @@ static INLINE int is_inside(const TileInfo *const tile, int mi_col, int mi_row,
const int dependent_horz_tile_flag = 0;
(void)cm;
#endif
#if CONFIG_TILE_GROUPS
if (dependent_horz_tile_flag && !tile->tg_horz_boundary) {
#else
if (dependent_horz_tile_flag) {
#endif
return !(mi_row + mi_pos->row < 0 ||
mi_col + mi_pos->col < tile->mi_col_start ||
mi_row + mi_pos->row >= mi_rows ||
......
......@@ -365,11 +365,9 @@ typedef struct AV1Common {
#if CONFIG_DEPENDENT_HORZTILES
int dependent_horz_tiles;
#if CONFIG_TILE_GROUPS
int tile_group_start_row[MAX_TILE_ROWS][MAX_TILE_COLS];
int tile_group_start_col[MAX_TILE_ROWS][MAX_TILE_COLS];
#endif
#endif
#if CONFIG_LOOPFILTERING_ACROSS_TILES
int loop_filter_across_tiles_enabled;
#endif // CONFIG_LOOPFILTERING_ACROSS_TILES
......@@ -427,9 +425,7 @@ typedef struct AV1Common {
int delta_lf_res;
#endif
#endif
#if CONFIG_TILE_GROUPS
int num_tg;
#endif
#if CONFIG_REFERENCE_BUFFER
int current_frame_id;
int ref_frame_id[REF_FRAMES];
......@@ -654,11 +650,7 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
#if CONFIG_DEPENDENT_HORZTILES
if (dependent_horz_tile_flag) {
#if CONFIG_TILE_GROUPS
xd->up_available = (mi_row > tile->mi_row_start) || !tile->tg_horz_boundary;
#else
xd->up_available = (mi_row > 0);
#endif // CONFIG_TILE_GROUPS
} else {
#endif // CONFIG_DEPENDENT_HORZTILES
// Are edges available for intra prediction?
......
......@@ -23,7 +23,7 @@ void av1_tile_set_col(TileInfo *tile, const AV1_COMMON *cm, int col) {
tile->mi_col_end = AOMMIN(tile->mi_col_start + cm->tile_width, cm->mi_cols);
}
#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
#if CONFIG_DEPENDENT_HORZTILES
void av1_tile_set_tg_boundary(TileInfo *tile, const AV1_COMMON *const cm,
int row, int col) {
if (row < cm->tile_rows - 1) {
......@@ -41,7 +41,7 @@ void av1_tile_set_tg_boundary(TileInfo *tile, const AV1_COMMON *const cm,
void av1_tile_init(TileInfo *tile, const AV1_COMMON *cm, int row, int col) {
av1_tile_set_row(tile, cm, row);
av1_tile_set_col(tile, cm, col);
#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
#if CONFIG_DEPENDENT_HORZTILES
av1_tile_set_tg_boundary(tile, cm, row, col);
#endif
}
......@@ -119,11 +119,7 @@ void av1_setup_across_tile_boundary_info(const AV1_COMMON *const cm,
int row, col;
#if CONFIG_DEPENDENT_HORZTILES
#if CONFIG_TILE_GROUPS
if (!cm->dependent_horz_tiles || tile_info->tg_horz_boundary)
#else
if (!cm->dependent_horz_tiles)
#endif // CONFIG_TILE_GROUPS
#endif // CONFIG_DEPENDENT_HORZTILES
{
mi = mi_start;
......
......@@ -20,9 +20,7 @@ extern "C" {
struct AV1Common;
#if CONFIG_TILE_GROUPS
#define DEFAULT_MAX_NUM_TG 1
#endif
typedef struct TileInfo {
int mi_row_start, mi_row_end;
......@@ -37,7 +35,7 @@ void av1_tile_init(TileInfo *tile, const struct AV1Common *cm, int row,
void av1_tile_set_row(TileInfo *tile, const struct AV1Common *cm, int row);
void av1_tile_set_col(TileInfo *tile, const struct AV1Common *cm, int col);
#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
#if CONFIG_DEPENDENT_HORZTILES
void av1_tile_set_tg_boundary(TileInfo *tile, const struct AV1Common *const cm,
int row, int col);
#endif
......
......@@ -3361,16 +3361,12 @@ static void read_tile_info(AV1Decoder *const pbi,
cm->tile_width = ALIGN_POWER_OF_TWO(cm->tile_width, MAX_MIB_SIZE_LOG2);
cm->tile_height = ALIGN_POWER_OF_TWO(cm->tile_height, MAX_MIB_SIZE_LOG2);
// tile size magnitude
#if !CONFIG_TILE_GROUPS
if (cm->tile_rows > 1 || cm->tile_cols > 1)
#endif
pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
// tile size magnitude
pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
#if CONFIG_TILE_GROUPS
// Store an index to the location of the tile group information
pbi->tg_size_bit_offset = rb->bit_offset;
pbi->tg_size = 1 << (cm->log2_tile_rows + cm->log2_tile_cols);
......@@ -3380,7 +3376,6 @@ static void read_tile_info(AV1Decoder *const pbi,
pbi->tg_size =
1 + aom_rb_read_literal(rb, cm->log2_tile_rows + cm->log2_tile_cols);
}
#endif
}
static int mem_get_varsize(const uint8_t *src, int sz) {
......@@ -3581,7 +3576,6 @@ static void get_tile_buffers(
AV1Decoder *pbi, const uint8_t *data, const uint8_t *data_end,
TileBufferDec (*const tile_buffers)[MAX_TILE_COLS]) {
AV1_COMMON *const cm = &pbi->common;
#if CONFIG_TILE_GROUPS
int r, c;
const int tile_cols = cm->tile_cols;
const int tile_rows = cm->tile_rows;
......@@ -3628,21 +3622,6 @@ static void get_tile_buffers(
#endif
}
}
#else
int r, c;
const int tile_cols = cm->tile_cols;
const int tile_rows = cm->tile_rows;
for (r = 0; r < tile_rows; ++r) {
for (c = 0; c < tile_cols; ++c) {
const int is_last = (r == tile_rows - 1) && (c == tile_cols - 1);
TileBufferDec *const buf = &tile_buffers[r][c];
buf->col = c;
get_tile_buffer(data_end, pbi->tile_size_bytes, is_last, &cm->error,
&data, pbi->decrypt_cb, pbi->decrypt_state, buf);
}
}
#endif
}
#if CONFIG_PVQ
......@@ -3853,13 +3832,9 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
av1_tile_set_col(&tile_info, cm, col);
#if CONFIG_DEPENDENT_HORZTILES
#if CONFIG_TILE_GROUPS
av1_tile_set_tg_boundary(&tile_info, cm, tile_row, tile_col);
if (!cm->dependent_horz_tiles || tile_row == 0 ||
tile_info.tg_horz_boundary) {
#else
if (!cm->dependent_horz_tiles || tile_row == 0) {
#endif
av1_zero_above_context(cm, tile_info.mi_col_start,
tile_info.mi_col_end);
}
......@@ -4004,11 +3979,7 @@ static int tile_worker_hook(TileWorkerData *const tile_data,
tile_data->error_info.setjmp = 1;
tile_data->xd.error_info = &tile_data->error_info;
#if CONFIG_DEPENDENT_HORZTILES
#if CONFIG_TILE_GROUPS
if (!cm->dependent_horz_tiles || tile->tg_horz_boundary) {
#else
if (!cm->dependent_horz_tiles) {
#endif
av1_zero_above_context(&pbi->common, tile->mi_col_start, tile->mi_col_end);
}
#else
......@@ -5253,10 +5224,8 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
}
#endif // CONFIG_EXT_TILE
#if CONFIG_TILE_GROUPS
pbi->first_partition_size = first_partition_size;
pbi->uncomp_hdr_size = aom_rb_bytes_read(&rb);
#endif
new_fb = get_frame_new_buffer(cm);
xd->cur_buf = new_fb;
#if CONFIG_INTRABC
......
......@@ -135,11 +135,9 @@ typedef struct AV1Decoder {
#endif
size_t uncomp_hdr_size; // Size of the uncompressed header
size_t first_partition_size; // Size of the compressed header
#if CONFIG_TILE_GROUPS
int tg_size; // Number of tiles in the current tilegroup
int tg_start; // First tile in the current tilegroup
int tg_size; // Number of tiles in the current tilegroup
int tg_start; // First tile in the current tilegroup
int tg_size_bit_offset;
#endif
#if CONFIG_REFERENCE_BUFFER
SequenceHeader seq_params;
#endif
......
......@@ -452,11 +452,7 @@ static void write_selected_tx_size(const AV1_COMMON *cm, const MACROBLOCKD *xd,
static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
int i;
#if CONFIG_TILE_GROUPS
const int probwt = cm->num_tg;
#else
const int probwt = 1;
#endif
for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
av1_cond_prob_diff_update(w, &cm->fc->newmv_prob[i], counts->newmv_mode[i],
probwt);
......@@ -628,11 +624,7 @@ static void write_delta_lflevel(const AV1_COMMON *cm, const MACROBLOCKD *xd,
static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
int k;
#if CONFIG_TILE_GROUPS
const int probwt = cm->num_tg;
#else
const int probwt = 1;
#endif
for (k = 0; k < SKIP_CONTEXTS; ++k) {
av1_cond_prob_diff_update(w, &cm->fc->skip_probs[k], counts->skip[k],
probwt);
......@@ -3127,12 +3119,8 @@ static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
int mi_row, mi_col;
#if CONFIG_DEPENDENT_HORZTILES
#if CONFIG_TILE_GROUPS
if (!cm->dependent_horz_tiles || mi_row_start == 0 ||
tile->tg_horz_boundary) {
#else
if (!cm->dependent_horz_tiles || mi_row_start == 0) {
#endif
av1_zero_above_context(cm, mi_col_start, mi_col_end);
}
#else
......@@ -3736,7 +3724,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
const int tile_rows = cm->tile_rows;
unsigned int tile_size = 0;
const int have_tiles = tile_cols * tile_rows > 1;
#if CONFIG_TILE_GROUPS
struct aom_write_bit_buffer wb = { dst, 0 };
const int n_log2_tiles = cm->log2_tile_rows + cm->log2_tile_cols;
uint32_t comp_hdr_size;
......@@ -3761,7 +3748,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
int mtu_size = cpi->oxcf.mtu;
int curr_tg_data_size = 0;
int hdr_size;
#endif
*max_tile_size = 0;
*max_tile_col_size = 0;
......@@ -3862,7 +3848,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
}
} else {
#endif // CONFIG_EXT_TILE
#if CONFIG_TILE_GROUPS
write_uncompressed_header(cpi, &wb);
#if CONFIG_EXT_REFS
......@@ -3893,7 +3878,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
aom_wb_overwrite_literal(&comp_hdr_len_wb, (int)(comp_hdr_size), 16);
hdr_size = uncompressed_hdr_size + comp_hdr_size;
total_size += hdr_size;
#endif
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
TileInfo tile_info;
......@@ -3908,64 +3892,63 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col];
const int is_last_col = (tile_col == tile_cols - 1);
const int is_last_tile = is_last_col && is_last_row;
#if !CONFIG_TILE_GROUPS
(void)tile_idx;
#else
if ((!mtu_size && tile_count > tg_size) ||
(mtu_size && tile_count && curr_tg_data_size >= mtu_size)) {
// New tile group
tg_count++;
// We've exceeded the packet size
if (tile_count > 1) {
/* The last tile exceeded the packet size. The tile group size
should therefore be tile_count-1.
Move the last tile and insert headers before it
*/
uint32_t old_total_size = total_size - tile_size - 4;
memmove(dst + old_total_size + hdr_size, dst + old_total_size,
(tile_size + 4) * sizeof(uint8_t));
// Copy uncompressed header
memmove(dst + old_total_size, dst,
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header before the one we've just inserted
aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
n_log2_tiles);
aom_wb_overwrite_literal(&tg_params_wb, tile_count - 2, n_log2_tiles);
// Update the pointer to the last TG params
tg_params_wb.bit_offset = saved_offset + 8 * old_total_size;
// Copy compressed header
memmove(dst + old_total_size + uncompressed_hdr_size,
dst + uncompressed_hdr_size, comp_hdr_size * sizeof(uint8_t));
total_size += hdr_size;
tile_count = 1;
curr_tg_data_size = hdr_size + tile_size + 4;
} else {
// We exceeded the packet size in just one tile
// Copy uncompressed header
memmove(dst + total_size, dst,
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header
aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
n_log2_tiles);
aom_wb_overwrite_literal(&tg_params_wb, tile_count - 1, n_log2_tiles);
tg_params_wb.bit_offset = saved_offset + 8 * total_size;
// Copy compressed header
memmove(dst + total_size + uncompressed_hdr_size,
dst + uncompressed_hdr_size, comp_hdr_size * sizeof(uint8_t));
total_size += hdr_size;
tile_count = 0;
curr_tg_data_size = hdr_size;
if ((!mtu_size && tile_count > tg_size) ||
(mtu_size && tile_count && curr_tg_data_size >= mtu_size)) {
// New tile group
tg_count++;
// We've exceeded the packet size
if (tile_count > 1) {
/* The last tile exceeded the packet size. The tile group size
should therefore be tile_count-1.
Move the last tile and insert headers before it
*/
uint32_t old_total_size = total_size - tile_size - 4;
memmove(dst + old_total_size + hdr_size, dst + old_total_size,
(tile_size + 4) * sizeof(uint8_t));
// Copy uncompressed header
memmove(dst + old_total_size, dst,
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header before the one we've just inserted
aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
n_log2_tiles);
aom_wb_overwrite_literal(&tg_params_wb, tile_count - 2,
n_log2_tiles);
// Update the pointer to the last TG params
tg_params_wb.bit_offset = saved_offset + 8 * old_total_size;
// Copy compressed header
memmove(dst + old_total_size + uncompressed_hdr_size,
dst + uncompressed_hdr_size,
comp_hdr_size * sizeof(uint8_t));
total_size += hdr_size;
tile_count = 1;
curr_tg_data_size = hdr_size + tile_size + 4;
} else {
// We exceeded the packet size in just one tile
// Copy uncompressed header
memmove(dst + total_size, dst,
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header
aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
n_log2_tiles);
aom_wb_overwrite_literal(&tg_params_wb, tile_count - 1,
n_log2_tiles);
tg_params_wb.bit_offset = saved_offset + 8 * total_size;
// Copy compressed header
memmove(dst + total_size + uncompressed_hdr_size,
dst + uncompressed_hdr_size,
comp_hdr_size * sizeof(uint8_t));
total_size += hdr_size;
tile_count = 0;
curr_tg_data_size = hdr_size;
}
}
}
tile_count++;
#endif
tile_count++;
av1_tile_set_col(&tile_info, cm, tile_col);
#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
#if CONFIG_DEPENDENT_HORZTILES
av1_tile_set_tg_boundary(&tile_info, cm, tile_row, tile_col);
#endif
buf->data = dst + total_size;
......@@ -4003,9 +3986,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
assert(tile_size > 0);
#if CONFIG_TILE_GROUPS
curr_tg_data_size += tile_size + 4;
#endif
buf->size = tile_size;
if (!is_last_tile) {
......@@ -4017,7 +3998,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
total_size += tile_size;
}
}
#if CONFIG_TILE_GROUPS
// Write the final tile group size
if (n_log2_tiles) {
aom_wb_overwrite_literal(&tg_params_wb, (1 << n_log2_tiles) - tile_count,
......@@ -4035,7 +4015,6 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
aom_wb_overwrite_literal(&tile_size_bytes_wb, tile_size_bytes - 1, 2);
}
#endif
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
......@@ -4585,11 +4564,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
int j;
#endif
#if CONFIG_TILE_GROUPS
const int probwt = cm->num_tg;
#else
const int probwt = 1;
#endif
(void)probwt;
(void)i;
(void)fc;
......@@ -4898,7 +4873,7 @@ static int remux_tiles(const AV1_COMMON *const cm, uint8_t *dst,
void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
uint8_t *data = dst;
uint32_t data_size;
#if (!CONFIG_TILE_GROUPS) || (CONFIG_TILE_GROUPS && CONFIG_EXT_TILE)
#if CONFIG_EXT_TILE
AV1_COMMON *const cm = &cpi->common;
uint32_t compressed_header_size = 0;
uint32_t uncompressed_header_size;
......@@ -4907,7 +4882,7 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
const int have_tiles = cm->tile_cols * cm->tile_rows > 1;
int tile_size_bytes;
int tile_col_size_bytes;
#endif // (!CONFIG_TILE_GROUPS) || (CONFIG_TILE_GROUPS && CONFIG_EXT_TILE)
#endif // CONFIG_EXT_TILE
unsigned int max_tile_size;
unsigned int max_tile_col_size;
......@@ -4915,47 +4890,6 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
bitstream_queue_reset_write();
#endif
#if !CONFIG_TILE_GROUPS
// Write the uncompressed header
write_uncompressed_header(cpi, &wb);
#if CONFIG_EXT_REFS
if (cm->show_existing_frame) {
*size = aom_wb_bytes_written(&wb);
return;
}
#endif // CONFIG_EXT_REFS
// We do not know these in advance. Output placeholder bit.
saved_wb = wb;
// Write tile size magnitudes
if (have_tiles) {
// Note that the last item in the uncompressed header is the data
// describing tile configuration.
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
// Number of bytes in tile column size - 1
aom_wb_write_literal(&wb, 0, 2);
}
#endif // CONFIG_EXT_TILE
// Number of bytes in tile size - 1
aom_wb_write_literal(&wb, 0, 2);
}
// Size of compressed header
aom_wb_write_literal(&wb, 0, 16);
uncompressed_header_size = (uint32_t)aom_wb_bytes_written(&wb);
data += uncompressed_header_size;
aom_clear_system_state();
// Write the compressed header
compressed_header_size = write_compressed_header(cpi, data);
data += compressed_header_size;
// Write the encoded tile data
data_size = write_tiles(cpi, data, &max_tile_size, &max_tile_col_size);
#else
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
// Write the uncompressed header
......@@ -5000,31 +4934,6 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
#endif
#if !CONFIG_TILE_GROUPS
if (have_tiles) {
data_size =
remux_tiles(cm, data, data_size, max_tile_size, max_tile_col_size,
&tile_size_bytes, &tile_col_size_bytes);
}
data += data_size;
// Now fill in the gaps in the uncompressed header.
if (have_tiles) {
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
assert(tile_col_size_bytes >= 1 && tile_col_size_bytes <= 4);
aom_wb_write_literal(&saved_wb, tile_col_size_bytes - 1, 2);
}
#endif // CONFIG_EXT_TILE
assert(tile_size_bytes >= 1 && tile_size_bytes <= 4);
aom_wb_write_literal(&saved_wb, tile_size_bytes - 1, 2);
}
// TODO(jbb): Figure out what to do if compressed_header_size > 16 bits.
assert(compressed_header_size <= 0xffff);
aom_wb_write_literal(&saved_wb, compressed_header_size, 16);
#else
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
if (have_tiles) {
......@@ -5052,7 +4961,6 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
#endif
#if CONFIG_ANS && ANS_REVERSE