obudec: Fix TU reader function call sig inconsistency.
Change the OBU TU reader to use the same call signature as the
IVF and WebM readers.
Change-Id: I690d311f21d5abf0972e5cb7785363d37d15b11b
diff --git a/aomdec.c b/aomdec.c
index e365dbf..e01cf6a 100644
--- a/aomdec.c
+++ b/aomdec.c
@@ -249,7 +249,7 @@
buffer_size);
case FILE_TYPE_OBU:
return obudec_read_temporal_unit(input->obu_ctx, buf, bytes_in_buffer,
- buffer_size, 0);
+ buffer_size);
default: return 1;
}
}
@@ -533,7 +533,7 @@
memset(&webm_ctx, 0, sizeof(webm_ctx));
input.webm_ctx = &webm_ctx;
#endif
- struct ObuDecInputContext obu_ctx = { NULL, NULL, 0, 0, 0 };
+ struct ObuDecInputContext obu_ctx = { NULL, NULL, 0, 0, 0, 0 };
obu_ctx.avx_ctx = &aom_input_ctx;
input.obu_ctx = &obu_ctx;
input.aom_input_ctx = &aom_input_ctx;
diff --git a/examples/scalable_decoder.c b/examples/scalable_decoder.c
index 6b41c85..23c3510 100644
--- a/examples/scalable_decoder.c
+++ b/examples/scalable_decoder.c
@@ -100,9 +100,8 @@
uint8_t *buf = NULL;
size_t bytes_in_buffer = 0;
size_t buffer_size = 0;
- int next_layer_id = 0;
struct AvxInputContext aom_input_ctx;
- struct ObuDecInputContext obu_ctx = { &aom_input_ctx, NULL, 0, 0, 0 };
+ struct ObuDecInputContext obu_ctx = { &aom_input_ctx, NULL, 0, 0, 0, 0 };
aom_codec_stream_info_t si;
uint8_t tmpbuf[32];
unsigned int i;
@@ -141,7 +140,7 @@
}
while (!obudec_read_temporal_unit(&obu_ctx, &buf, &bytes_in_buffer,
- &buffer_size, next_layer_id)) {
+ &buffer_size)) {
aom_codec_iter_t iter = NULL;
aom_image_t *img = NULL;
if (aom_codec_decode(&codec, buf, (unsigned int)bytes_in_buffer, NULL))
@@ -151,15 +150,15 @@
if (img->enhancement_id == 0) {
printf("Writing base layer 0 %d\n", frame_cnt);
aom_img_write(img, outfile[0]);
- next_layer_id++;
+ obu_ctx.last_layer_id++;
} else if (img->enhancement_id <= (int)si.enhancement_layers_cnt) {
printf("Writing enhancemnt layer %d %d\n", img->enhancement_id,
frame_cnt);
aom_img_write(img, outfile[img->enhancement_id]);
if (img->enhancement_id == (int)si.enhancement_layers_cnt)
- next_layer_id = 0;
+ obu_ctx.last_layer_id = 0;
else
- next_layer_id++;
+ obu_ctx.last_layer_id++;
} else {
die_codec(&codec, "Invalid bitstream. Layer id exceeds layer count");
}
diff --git a/obudec.c b/obudec.c
index 1ce7d24..4b5bda3 100644
--- a/obudec.c
+++ b/obudec.c
@@ -258,7 +258,7 @@
int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
uint8_t **buffer, size_t *bytes_read,
- size_t *buffer_size, int last_layer_id) {
+ size_t *buffer_size) {
FILE *f = obu_ctx->avx_ctx->file;
if (!f) return -1;
@@ -286,7 +286,7 @@
if (obu_header.type == OBU_TEMPORAL_DELIMITER || obu_size == 0 ||
(obu_header.has_extension &&
- obu_header.enhancement_layer_id > last_layer_id)) {
+ obu_header.enhancement_layer_id > obu_ctx->last_layer_id)) {
const size_t tu_size = obu_ctx->bytes_buffered;
#if defined AOM_MAX_ALLOCABLE_MEMORY
diff --git a/obudec.h b/obudec.h
index c413f20..6cfad15 100644
--- a/obudec.h
+++ b/obudec.h
@@ -23,6 +23,7 @@
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
@@ -37,7 +38,7 @@
// via 'bytes_read'.
int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
uint8_t **buffer, size_t *bytes_read,
- size_t *buffer_size, int last_layer_id);
+ size_t *buffer_size);
void obudec_free(struct ObuDecInputContext *obu_ctx);
diff --git a/tools/dump_obu.cc b/tools/dump_obu.cc
index 749b5a7..100f9f5 100644
--- a/tools/dump_obu.cc
+++ b/tools/dump_obu.cc
@@ -35,6 +35,7 @@
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 = kIgnoreLayers;
#if CONFIG_WEBM_IO
memset(webm_ctx, 0, sizeof(*webm_ctx));
#endif
@@ -74,7 +75,7 @@
}
case FILE_TYPE_OBU: {
if (obudec_read_temporal_unit(ctx->obu_ctx, &ctx->unit_buffer, unit_size,
- &ctx->unit_buffer_size, kIgnoreLayers)) {
+ &ctx->unit_buffer_size)) {
return false;
}
break;