webmdec: make reader interface consistent.
Change-Id: I39d356ac850f469f2e4dd9f7556bf814e292ef88
diff --git a/aomdec.c b/aomdec.c
index 9fd8f0a..e365dbf 100644
--- a/aomdec.c
+++ b/aomdec.c
@@ -238,7 +238,8 @@
switch (input->aom_input_ctx->file_type) {
#if CONFIG_WEBM_IO
case FILE_TYPE_WEBM:
- return webm_read_frame(input->webm_ctx, buf, bytes_in_buffer);
+ return webm_read_frame(input->webm_ctx, buf, bytes_in_buffer,
+ buffer_size);
#endif
case FILE_TYPE_RAW:
return raw_read_frame(input->aom_input_ctx->file, buf, bytes_in_buffer,
diff --git a/tools/dump_obu.cc b/tools/dump_obu.cc
index 63b5f1e..749b5a7 100644
--- a/tools/dump_obu.cc
+++ b/tools/dump_obu.cc
@@ -81,18 +81,10 @@
}
#if CONFIG_WEBM_IO
case FILE_TYPE_WEBM: {
- size_t frame_size = ctx->unit_buffer_size;
- if (webm_read_frame(ctx->webm_ctx, &ctx->unit_buffer, &frame_size)) {
+ if (webm_read_frame(ctx->webm_ctx, &ctx->unit_buffer, unit_size,
+ &ctx->unit_buffer_size)) {
return false;
}
-
- if (frame_size != ctx->unit_buffer_size &&
- frame_size > ctx->unit_buffer_size) {
- // webmdec realloc'd the buffer, store new size.
- ctx->unit_buffer_size = frame_size;
- }
-
- *unit_size = frame_size;
break;
}
#endif
diff --git a/webmdec.cc b/webmdec.cc
index da44940..d0e576b 100644
--- a/webmdec.cc
+++ b/webmdec.cc
@@ -118,7 +118,7 @@
}
int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
- size_t *buffer_size) {
+ size_t *bytes_read, size_t *buffer_size) {
// This check is needed for frame parallel decoding, in which case this
// function could be called even after it has reached end of input stream.
if (webm_ctx->reached_eos) {
@@ -142,7 +142,7 @@
} else if (block_entry_eos || block_entry->EOS()) {
cluster = segment->GetNext(cluster);
if (cluster == NULL || cluster->EOS()) {
- *buffer_size = 0;
+ *bytes_read = 0;
webm_ctx->reached_eos = 1;
return 1;
}
@@ -184,8 +184,9 @@
return -1;
}
webm_ctx->buffer = *buffer;
+ *buffer_size = frame.len;
}
- *buffer_size = frame.len;
+ *bytes_read = frame.len;
webm_ctx->timestamp_ns = block->GetTime(cluster);
webm_ctx->is_key_frame = block->IsKey();
@@ -199,8 +200,9 @@
uint32_t i = 0;
uint8_t *buffer = NULL;
size_t buffer_size = 0;
+ size_t bytes_read = 0;
while (webm_ctx->timestamp_ns < 1000000000 && i < 50) {
- if (webm_read_frame(webm_ctx, &buffer, &buffer_size)) {
+ if (webm_read_frame(webm_ctx, &buffer, &bytes_read, &buffer_size)) {
break;
}
++i;
diff --git a/webmdec.h b/webmdec.h
index 329908e..64d0b98 100644
--- a/webmdec.h
+++ b/webmdec.h
@@ -48,13 +48,14 @@
// Parameters:
// webm_ctx - WebmInputContext object
// buffer - pointer where the frame data will be filled.
+// bytes_read - pointer to bytes read.
// buffer_size - pointer to buffer size.
// Return values:
// 0 - Success
// 1 - End of Stream
// -1 - Error
int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
- size_t *buffer_size);
+ size_t *bytes_read, size_t *buffer_size);
// Guesses the frame rate of the input file based on the container timestamps.
int webm_guess_framerate(struct WebmInputContext *webm_ctx,