Commit 82a41183 authored by Tom Finegan's avatar Tom Finegan

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
parent f61c0d14
......@@ -249,7 +249,7 @@ static int read_frame(struct AvxDecInputContext *input, uint8_t **buf,
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 @@ 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 };
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;
......
......@@ -100,9 +100,8 @@ int main(int argc, char **argv) {
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 @@ int main(int argc, char **argv) {
}
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 @@ int main(int argc, char **argv) {
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");
}
......
......@@ -258,7 +258,7 @@ int file_is_obu(struct ObuDecInputContext *obu_ctx) {
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 @@ int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
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
......
......@@ -23,6 +23,7 @@ struct ObuDecInputContext {
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 @@ int file_is_obu(struct ObuDecInputContext *obu_ctx);
// 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);
......
......@@ -35,6 +35,7 @@ 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 = kIgnoreLayers;
#if CONFIG_WEBM_IO
memset(webm_ctx, 0, sizeof(*webm_ctx));
#endif
......@@ -74,7 +75,7 @@ bool ReadTemporalUnit(InputContext *ctx, size_t *unit_size) {
}
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;
......
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