Commit a8de8819 authored by David Barker's avatar David Barker Committed by Debargha Mukherjee

Remove 'last_layer_id' from ObuDecInputContext

Previously, if we wanted to use all-layers mode, the code
in obudec.c was responsible for carving up temporal units
into spatial layers to feed into the decoder. Whether we were
in this mode corresponded to whether last_layer_id is set to
IGNORE_ENHANCEMENT_LAYERS or not.

Now, the all-layers behaviour is implemented in the decoder proper,
so we can always pass a full temporal unit at a time into the decoder.

This means that the special code in obudec.c is no longer needed,
and that all-layers mode now works correctly for "contained" streams
(ie, annexb format, .ivf, .webm, etc.)

BUG=aomedia:1941

Change-Id: I38a21e560c14f822b652f8c2880f6be9f7c2e2ec
parent f1c07ce7
......@@ -535,8 +535,7 @@ static int main_loop(int argc, const char **argv_) {
memset(&webm_ctx, 0, sizeof(webm_ctx));
input.webm_ctx = &webm_ctx;
#endif
struct ObuDecInputContext obu_ctx = { NULL, NULL, 0,
0, 0, IGNORE_ENHANCEMENT_LAYERS };
struct ObuDecInputContext obu_ctx = { NULL, NULL, 0, 0, 0 };
obu_ctx.avx_ctx = &aom_input_ctx;
input.obu_ctx = &obu_ctx;
......@@ -624,7 +623,6 @@ static int main_loop(int argc, const char **argv_) {
} else if (arg_match(&arg, &oppointarg, argi)) {
operating_point = arg_parse_int(&arg);
} else if (arg_match(&arg, &outallarg, argi)) {
input.obu_ctx->last_layer_id = 0;
output_all_layers = 1;
} else {
argj++;
......
......@@ -388,19 +388,7 @@ int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
return -1;
}
if (obu_header.type == OBU_TEMPORAL_DELIMITER) {
// Reset last_layer_id at temporal delimiter
if (obu_ctx->last_layer_id != IGNORE_ENHANCEMENT_LAYERS)
obu_ctx->last_layer_id = 0;
tu_size = obu_ctx->bytes_buffered;
break;
} else if (obu_size == 0) {
tu_size = obu_ctx->bytes_buffered;
break;
} else if (obu_header.has_extension &&
obu_header.spatial_layer_id > obu_ctx->last_layer_id) {
// Update last_layer_id to current spatial layer
obu_ctx->last_layer_id = obu_header.spatial_layer_id;
if (obu_header.type == OBU_TEMPORAL_DELIMITER || obu_size == 0) {
tu_size = obu_ctx->bytes_buffered;
break;
} else {
......
......@@ -17,17 +17,12 @@
extern "C" {
#endif
// Assign this value to last_layer_id when the application wants full
// temporal units regardless of the presence of enhancement layers.
#define IGNORE_ENHANCEMENT_LAYERS 8
struct ObuDecInputContext {
struct AvxInputContext *avx_ctx;
uint8_t *buffer;
size_t buffer_capacity;
size_t bytes_buffered;
int is_annexb;
int last_layer_id;
};
// Returns 1 when file data starts (if Annex B stream, after reading the
......
......@@ -100,7 +100,7 @@ int main(int argc, char **argv) {
size_t bytes_in_buffer = 0;
size_t buffer_size = 0;
struct AvxInputContext aom_input_ctx;
struct ObuDecInputContext obu_ctx = { &aom_input_ctx, NULL, 0, 0, 0, 0 };
struct ObuDecInputContext obu_ctx = { &aom_input_ctx, NULL, 0, 0, 0 };
aom_codec_stream_info_t si;
uint8_t tmpbuf[32];
unsigned int i;
......@@ -164,14 +164,9 @@ int main(int argc, char **argv) {
if (img->spatial_id == 0) {
printf("Writing base layer 0 %d\n", frame_cnt);
aom_img_write(img_shifted, outfile[0]);
obu_ctx.last_layer_id++;
} else if (img->spatial_id <= (int)(si.number_spatial_layers - 1)) {
printf("Writing enhancement layer %d %d\n", img->spatial_id, frame_cnt);
aom_img_write(img_shifted, outfile[img->spatial_id]);
if (img->spatial_id == (int)(si.number_spatial_layers - 1))
obu_ctx.last_layer_id = 0;
else
obu_ctx.last_layer_id++;
} else {
die_codec(&codec, "Invalid bitstream. Layer id exceeds layer count");
}
......
......@@ -35,7 +35,6 @@ struct InputContext {
memset(avx_ctx, 0, sizeof(*avx_ctx));
memset(obu_ctx, 0, sizeof(*obu_ctx));
obu_ctx->avx_ctx = avx_ctx;
obu_ctx->last_layer_id = IGNORE_ENHANCEMENT_LAYERS;
#if CONFIG_WEBM_IO
memset(webm_ctx, 0, sizeof(*webm_ctx));
#endif
......
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