Commit 66ae9163 authored by Tom Finegan's avatar Tom Finegan

aomdec: Implement support for AV1 Section 5 streams.

BUG=aomedia:1618

Change-Id: I1e0cfa208f94008df8b0d4cc4d14defde173114a
parent eb895ef5
......@@ -58,6 +58,7 @@ static const char *exec_name;
struct AvxDecInputContext {
struct AvxInputContext *aom_input_ctx;
struct ObuDecInputContext *obu_ctx;
struct WebmInputContext *webm_ctx;
};
......@@ -246,12 +247,13 @@ static int read_frame(struct AvxDecInputContext *input, uint8_t **buf,
buffer_size);
#if CONFIG_OBU_NO_IVF
case FILE_TYPE_OBU:
return obu_read_temporal_unit(input->aom_input_ctx->file, buf,
return obudec_read_temporal_unit(input->obu_ctx, buf,
#if CONFIG_SCALABILITY
bytes_in_buffer, buffer_size, 0);
bytes_in_buffer, buffer_size, 0
#else
bytes_in_buffer, buffer_size);
bytes_in_buffer, buffer_size
#endif
);
#endif
default: return 1;
}
......@@ -528,12 +530,17 @@ static int main_loop(int argc, const char **argv_) {
MD5Context md5_ctx;
unsigned char md5_digest[16];
struct AvxDecInputContext input = { NULL, NULL };
struct AvxDecInputContext input = { NULL, NULL, NULL };
struct AvxInputContext aom_input_ctx;
#if CONFIG_WEBM_IO
struct WebmInputContext webm_ctx;
memset(&(webm_ctx), 0, sizeof(webm_ctx));
memset(&webm_ctx, 0, sizeof(webm_ctx));
input.webm_ctx = &webm_ctx;
#endif
#if CONFIG_OBU_NO_IVF
struct ObuDecInputContext obu_ctx = { NULL, NULL, 0, 0 };
obu_ctx.avx_ctx = &aom_input_ctx;
input.obu_ctx = &obu_ctx;
#endif
input.aom_input_ctx = &aom_input_ctx;
......@@ -655,7 +662,7 @@ static int main_loop(int argc, const char **argv_) {
input.aom_input_ctx->file_type = FILE_TYPE_WEBM;
#endif
#if CONFIG_OBU_NO_IVF
else if (file_is_obu(input.aom_input_ctx))
else if (file_is_obu(&obu_ctx))
input.aom_input_ctx->file_type = FILE_TYPE_OBU;
#endif
else if (file_is_raw(input.aom_input_ctx))
......@@ -1025,6 +1032,10 @@ fail2:
if (input.aom_input_ctx->file_type == FILE_TYPE_WEBM)
webm_free(input.webm_ctx);
#endif
#if CONFIG_OBU_NO_IVF
if (input.aom_input_ctx->file_type == FILE_TYPE_OBU)
obudec_free(input.obu_ctx);
#endif
if (input.aom_input_ctx->file_type != FILE_TYPE_WEBM) free(buf);
......
......@@ -87,11 +87,6 @@ static const char *exec_name;
#define MAX_LAYERS 5
struct AvxDecInputContext {
struct AvxInputContext *aom_input_ctx;
struct WebmInputContext *webm_ctx;
};
void usage_exit(void) {
fprintf(stderr, "Usage: %s <infile>\n", exec_name);
exit(EXIT_FAILURE);
......@@ -108,9 +103,8 @@ int main(int argc, char **argv) {
size_t bytes_in_buffer = 0;
size_t buffer_size = 0;
int next_layer_id = 0;
struct AvxDecInputContext input = { NULL, NULL };
struct AvxInputContext aom_input_ctx;
input.aom_input_ctx = &aom_input_ctx;
struct ObuDecInputContext obu_ctx = { &aom_input_ctx, NULL, 0, 0 };
aom_codec_stream_info_t si;
uint8_t tmpbuf[32];
unsigned int i;
......@@ -121,8 +115,8 @@ int main(int argc, char **argv) {
if (!(inputfile = fopen(argv[1], "rb")))
die("Failed to open %s for read.", argv[1]);
input.aom_input_ctx->file = inputfile;
input.aom_input_ctx->filename = argv[1];
obu_ctx.avx_ctx->file = inputfile;
obu_ctx.avx_ctx->filename = argv[1];
decoder = get_aom_decoder_by_index(0);
printf("Using %s\n", aom_codec_iface_name(decoder->codec_interface()));
......@@ -130,7 +124,7 @@ int main(int argc, char **argv) {
if (aom_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
die_codec(&codec, "Failed to initialize decoder.");
if (!file_is_obu(input.aom_input_ctx))
if (!file_is_obu(&obu_ctx))
die_codec(&codec, "Input is not a valid obu file");
// peak sequence header OBU to get enhancement layer count, if any
......@@ -148,8 +142,8 @@ int main(int argc, char **argv) {
die("Failed to open output for writing.");
}
while (!obu_read_temporal_unit(inputfile, &buf, &bytes_in_buffer,
&buffer_size, next_layer_id)) {
while (!obudec_read_temporal_unit(&obu_ctx, &buf, &bytes_in_buffer,
&buffer_size, next_layer_id)) {
aom_codec_iter_t iter = NULL;
aom_image_t *img = NULL;
if (aom_codec_decode(&codec, buf, (unsigned int)bytes_in_buffer, NULL))
......
This diff is collapsed.
......@@ -17,14 +17,32 @@
extern "C" {
#endif
int file_is_obu(struct AvxInputContext *input_ctx);
struct ObuDecInputContext {
struct AvxInputContext *avx_ctx;
uint8_t *buffer;
size_t buffer_capacity;
size_t bytes_buffered;
};
int obu_read_temporal_unit(FILE *infile, uint8_t **buffer, size_t *bytes_read,
// Returns 1 when file data starts with what appears to be a Temporal Delimiter
// OBU as defined by Section 5 of the AV1 bitstream specification.
int file_is_obu(struct ObuDecInputContext *obu_ctx);
// Reads one Temporal Unit from the input file. Returns 0 when a TU is
// successfully read, 1 when end of file is reached, and less than 0 when an
// error occurs. Stores TU data in 'buffer'. Reallocs buffer to match TU size,
// returns buffer capacity via 'buffer_size', and returns size of buffered data
// via 'bytes_read'.
int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
uint8_t **buffer, size_t *bytes_read,
#if CONFIG_SCALABILITY
size_t *buffer_size, int last_layer_id);
size_t *buffer_size, int last_layer_id
#else
size_t *buffer_size);
size_t *buffer_size
#endif
);
void obudec_free(struct ObuDecInputContext *obu_ctx);
#ifdef __cplusplus
} /* extern "C" */
......
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