Commit 8ae64a93 authored by Yunqing Wang's avatar Yunqing Wang

ext_tile: Not to write large_scale_tile bit to bitstream

This patch made several changes.
1. Removed writing large_scale_tile bit to bitstream.
2. Created SET_TILE_MODE API in decoder to pass in tile coding mode
information.
3. Modified related unit tests.

BUG=aomedia:1204

Change-Id: I2d729afba8b1b9278543a5da154be7ae6c99d184
parent 7a19734d
......@@ -140,6 +140,11 @@ enum aom_dec_control_id {
*/
AV1_SET_DECODE_TILE_ROW,
AV1_SET_DECODE_TILE_COL,
/** control function to set the tile coding mode. A value that is equal to
* zero indicates the tiles are coded in normal tile mode. A value that is
* 1 indicates the tiles are coded in large-scale tile mode.
*/
AV1_SET_TILE_MODE,
/** control function to set an aom_inspect_cb callback that is invoked each
* time a frame is decoded. When compiled without --enable-inspection, this
......@@ -180,6 +185,8 @@ AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int)
#define AOM_CTRL_AV1_SET_DECODE_TILE_ROW
AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int)
#define AOM_CTRL_AV1_SET_DECODE_TILE_COL
AOM_CTRL_USE_TYPE(AV1_SET_TILE_MODE, unsigned int)
#define AOM_CTRL_AV1_SET_TILE_MODE
AOM_CTRL_USE_TYPE(AV1_SET_INSPECTION_CALLBACK, aom_inspect_init *)
#define AOM_CTRL_AV1_SET_INSPECTION_CALLBACK
/*!\endcond */
......
......@@ -107,6 +107,9 @@ static const arg_def_t framestatsarg =
static const arg_def_t outbitdeptharg =
ARG_DEF(NULL, "output-bit-depth", 1, "Output bit-depth for decoded frames");
#if CONFIG_EXT_TILE
static const arg_def_t tilem = ARG_DEF(NULL, "tile-mode", 1,
"Tile coding mode "
"(0 for normal tile coding mode)");
static const arg_def_t tiler = ARG_DEF(NULL, "tile-row", 1,
"Row index of tile to decode "
"(-1 for all rows)");
......@@ -122,7 +125,7 @@ static const arg_def_t *all_args[] = {
&verbosearg, &scalearg, &fb_arg, &md5arg, &framestatsarg,
&continuearg, &outbitdeptharg,
#if CONFIG_EXT_TILE
&tiler, &tilec,
&tilem, &tiler, &tilec,
#endif // CONFIG_EXT_TILE
NULL
};
......@@ -509,6 +512,7 @@ static int main_loop(int argc, const char **argv_) {
aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH };
unsigned int output_bit_depth = 0;
#if CONFIG_EXT_TILE
unsigned int tile_mode = 0;
int tile_row = -1;
int tile_col = -1;
#endif // CONFIG_EXT_TILE
......@@ -616,6 +620,8 @@ static int main_loop(int argc, const char **argv_) {
output_bit_depth = arg_parse_uint(&arg);
}
#if CONFIG_EXT_TILE
else if (arg_match(&arg, &tilem, argi))
tile_mode = arg_parse_int(&arg);
else if (arg_match(&arg, &tiler, argi))
tile_row = arg_parse_int(&arg);
else if (arg_match(&arg, &tilec, argi))
......@@ -726,6 +732,12 @@ static int main_loop(int argc, const char **argv_) {
if (!quiet) fprintf(stderr, "%s\n", decoder.name);
#if CONFIG_AV1_DECODER && CONFIG_EXT_TILE
if (aom_codec_control(&decoder, AV1_SET_TILE_MODE, tile_mode)) {
fprintf(stderr, "Failed to set decode_tile_mode: %s\n",
aom_codec_error(&decoder));
goto fail;
}
if (aom_codec_control(&decoder, AV1_SET_DECODE_TILE_ROW, tile_row)) {
fprintf(stderr, "Failed to set decode_tile_row: %s\n",
aom_codec_error(&decoder));
......
......@@ -1598,6 +1598,10 @@ static void initialize_encoder(struct stream_state *stream,
#if CONFIG_EXT_TILE
if (strcmp(global->codec->name, "av1") == 0) {
aom_codec_control(&stream->decoder, AV1_SET_TILE_MODE,
stream->config.cfg.large_scale_tile);
ctx_exit_on_error(&stream->decoder, "Failed to set decode_tile_mode");
aom_codec_control(&stream->decoder, AV1_SET_DECODE_TILE_ROW, -1);
ctx_exit_on_error(&stream->decoder, "Failed to set decode_tile_row");
......
......@@ -55,6 +55,7 @@ struct aom_codec_alg_priv {
int skip_loop_filter;
int decode_tile_row;
int decode_tile_col;
unsigned int tile_mode;
// Frame parallel related.
int frame_parallel_decode; // frame-based threading.
......@@ -301,9 +302,6 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
struct aom_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL };
const int frame_marker = aom_rb_read_literal(&rb, 2);
const BITSTREAM_PROFILE profile = av1_read_profile(&rb);
#if CONFIG_EXT_TILE
unsigned int large_scale_tile;
#endif // CONFIG_EXT_TILE
if (frame_marker != AOM_FRAME_MARKER) return AOM_CODEC_UNSUP_BITSTREAM;
......@@ -312,10 +310,6 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
if ((profile >= 2 && data_sz <= 1) || data_sz < 1)
return AOM_CODEC_UNSUP_BITSTREAM;
#if CONFIG_EXT_TILE
large_scale_tile = aom_rb_read_literal(&rb, 1);
#endif // CONFIG_EXT_TILE
if (aom_rb_read_bit(&rb)) { // show an existing frame
aom_rb_read_literal(&rb, 3); // Frame buffer to show.
return AOM_CODEC_OK;
......@@ -335,9 +329,6 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
if (si->is_kf) {
/* TODO: Move outside frame loop or inside key-frame branch */
read_sequence_header(&seq_params, &rb);
#if CONFIG_EXT_TILE
if (large_scale_tile) seq_params.frame_id_numbers_present_flag = 0;
#endif // CONFIG_EXT_TILE
}
#endif // CONFIG_REFERENCE_BUFFER
......@@ -568,10 +559,14 @@ static aom_codec_err_t init_decoder(aom_codec_alg_priv_t *ctx) {
// thread or loopfilter thread.
frame_worker_data->pbi->max_threads =
(ctx->frame_parallel_decode == 0) ? ctx->cfg.threads : 0;
frame_worker_data->pbi->inv_tile_order = ctx->invert_tile_order;
frame_worker_data->pbi->common.frame_parallel_decode =
ctx->frame_parallel_decode;
#if CONFIG_EXT_TILE
frame_worker_data->pbi->common.large_scale_tile = ctx->tile_mode;
frame_worker_data->pbi->dec_tile_row = ctx->decode_tile_row;
frame_worker_data->pbi->dec_tile_col = ctx->decode_tile_col;
#endif // CONFIG_EXT_TILE
worker->hook = (AVxWorkerHook)frame_worker_hook;
if (!winterface->reset(worker)) {
set_error_detail(ctx, "Frame Worker thread creation failed");
......@@ -628,11 +623,6 @@ static aom_codec_err_t decode_one(aom_codec_alg_priv_t *ctx,
frame_worker_data->pbi->inspect_ctx = ctx->inspect_ctx;
#endif
#if CONFIG_EXT_TILE
frame_worker_data->pbi->dec_tile_row = ctx->decode_tile_row;
frame_worker_data->pbi->dec_tile_col = ctx->decode_tile_col;
#endif // CONFIG_EXT_TILE
worker->had_error = 0;
winterface->execute(worker);
......@@ -1271,6 +1261,12 @@ static aom_codec_err_t ctrl_set_decode_tile_col(aom_codec_alg_priv_t *ctx,
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_tile_mode(aom_codec_alg_priv_t *ctx,
va_list args) {
ctx->tile_mode = va_arg(args, unsigned int);
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_inspection_callback(aom_codec_alg_priv_t *ctx,
va_list args) {
#if !CONFIG_INSPECTION
......@@ -1300,6 +1296,7 @@ static aom_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
{ AV1_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
{ AV1_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row },
{ AV1_SET_DECODE_TILE_COL, ctrl_set_decode_tile_col },
{ AV1_SET_TILE_MODE, ctrl_set_tile_mode },
{ AV1_SET_INSPECTION_CALLBACK, ctrl_set_inspection_callback },
// Getters
......
......@@ -2517,13 +2517,6 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
"Unsupported bitstream profile");
#endif
#if CONFIG_EXT_TILE
cm->large_scale_tile = aom_rb_read_literal(rb, 1);
#if CONFIG_REFERENCE_BUFFER
if (cm->large_scale_tile) cm->seq_params.frame_id_numbers_present_flag = 0;
#endif // CONFIG_REFERENCE_BUFFER
#endif // CONFIG_EXT_TILE
cm->show_existing_frame = aom_rb_read_bit(rb);
#if CONFIG_FWD_KF
cm->reset_decoder_state = 0;
......
......@@ -3501,10 +3501,6 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
write_profile(cm->profile, wb);
#if CONFIG_EXT_TILE
aom_wb_write_literal(wb, cm->large_scale_tile, 1);
#endif // CONFIG_EXT_TILE
// NOTE: By default all coded frames to be used as a reference
cm->is_reference_frame = 1;
......@@ -3832,10 +3828,6 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
#if CONFIG_EXT_TILE
aom_wb_write_literal(wb, cm->large_scale_tile, 1);
#endif // CONFIG_EXT_TILE
// NOTE: By default all coded frames to be used as a reference
cm->is_reference_frame = 1;
......
......@@ -122,7 +122,8 @@ int main(int argc, char **argv) {
if (aom_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
die_codec(&codec, "Failed to initialize decoder.");
// Decode reference frames.
aom_codec_control_(&codec, AV1_SET_TILE_MODE, 0);
// How many reference images we need to encode.
u_blocks = (lf_width + lf_blocksize - 1) / lf_blocksize;
v_blocks = (lf_height + lf_blocksize - 1) / lf_blocksize;
......@@ -171,6 +172,7 @@ int main(int argc, char **argv) {
if (aom_codec_control(&codec, AV1_SET_REFERENCE, &ref)) {
die_codec(&codec, "Failed to set reference image.");
}
aom_codec_control_(&codec, AV1_SET_TILE_MODE, 1);
aom_codec_control_(&codec, AV1_SET_DECODE_TILE_ROW, tile_t);
aom_codec_control_(&codec, AV1_SET_DECODE_TILE_COL, tile_s);
aom_codec_err_t aom_status =
......
......@@ -46,6 +46,7 @@ class AV1ExtTileTest
cfg.allow_lowbitdepth = 1;
decoder_ = codec_->CreateDecoder(cfg, 0);
decoder_->Control(AV1_SET_TILE_MODE, 1);
decoder_->Control(AV1_SET_DECODE_TILE_ROW, -1);
decoder_->Control(AV1_SET_DECODE_TILE_COL, -1);
......
......@@ -238,6 +238,7 @@ void EncoderTest::RunLoop(VideoSource *video) {
if (decoder->IsAV1()) {
// Set dec_cfg.tile_row = -1 and dec_cfg.tile_col = -1 so that the whole
// frame is decoded.
decoder->Control(AV1_SET_TILE_MODE, cfg_.large_scale_tile);
decoder->Control(AV1_SET_DECODE_TILE_ROW, -1);
decoder->Control(AV1_SET_DECODE_TILE_COL, -1);
}
......
......@@ -172,6 +172,7 @@ class AVxEncoderThreadTest
TEST_P(AVxEncoderThreadTest, EncoderResultTest) {
#if CONFIG_AV1 && CONFIG_EXT_TILE
cfg_.large_scale_tile = 0;
decoder_->Control(AV1_SET_TILE_MODE, 0);
#endif // CONFIG_AV1 && CONFIG_EXT_TILE
DoTest();
}
......@@ -181,6 +182,7 @@ class AVxEncoderThreadTestLarge : public AVxEncoderThreadTest {};
TEST_P(AVxEncoderThreadTestLarge, EncoderResultTest) {
#if CONFIG_AV1 && CONFIG_EXT_TILE
cfg_.large_scale_tile = 0;
decoder_->Control(AV1_SET_TILE_MODE, 0);
#endif // CONFIG_AV1 && CONFIG_EXT_TILE
DoTest();
}
......@@ -208,6 +210,7 @@ class AVxEncoderThreadLSTest : public AVxEncoderThreadTest {
TEST_P(AVxEncoderThreadLSTest, EncoderResultTest) {
cfg_.large_scale_tile = 1;
decoder_->Control(AV1_SET_TILE_MODE, 1);
DoTest();
}
......@@ -215,6 +218,7 @@ class AVxEncoderThreadLSTestLarge : public AVxEncoderThreadLSTest {};
TEST_P(AVxEncoderThreadLSTestLarge, EncoderResultTest) {
cfg_.large_scale_tile = 1;
decoder_->Control(AV1_SET_TILE_MODE, 1);
DoTest();
}
......
......@@ -127,6 +127,8 @@ class TileIndependenceTest
TEST_P(TileIndependenceTest, MD5Match) {
#if CONFIG_EXT_TILE
cfg_.large_scale_tile = 0;
fw_dec_->Control(AV1_SET_TILE_MODE, 0);
inv_dec_->Control(AV1_SET_TILE_MODE, 0);
#endif // CONFIG_EXT_TILE
DoTest();
}
......@@ -141,6 +143,8 @@ class TileIndependenceTestLarge : public TileIndependenceTest {
TEST_P(TileIndependenceTestLarge, MD5Match) {
#if CONFIG_EXT_TILE
cfg_.large_scale_tile = 0;
fw_dec_->Control(AV1_SET_TILE_MODE, 0);
inv_dec_->Control(AV1_SET_TILE_MODE, 0);
#endif // CONFIG_EXT_TILE
DoTest();
}
......@@ -155,6 +159,8 @@ class TileIndependenceLSTest : public TileIndependenceTest {};
TEST_P(TileIndependenceLSTest, MD5Match) {
cfg_.large_scale_tile = 1;
fw_dec_->Control(AV1_SET_TILE_MODE, 1);
inv_dec_->Control(AV1_SET_TILE_MODE, 1);
DoTest();
}
......@@ -162,6 +168,8 @@ class TileIndependenceLSTestLarge : public TileIndependenceTestLarge {};
TEST_P(TileIndependenceLSTestLarge, MD5Match) {
cfg_.large_scale_tile = 1;
fw_dec_->Control(AV1_SET_TILE_MODE, 1);
inv_dec_->Control(AV1_SET_TILE_MODE, 1);
DoTest();
}
......
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