From: Vignesh Venkatasubramanian Date: Mon, 30 Mar 2015 19:58:26 +0000 (-0700) Subject: webmdec: Fix read_frame return value for calls after EOS X-Git-Tag: v1.5.0~810^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f05b19e69a97e451380be011923cf7ed7eab4d5;p=libvpx webmdec: Fix read_frame return value for calls after EOS webm_read_frame assumes that it won't be called once end of file is reached. But for frame parallel mode that turns out to be not true. this patch fixes that behavior by checking for EOS and returning the appropriate value for subsequent calls. Change-Id: Ie2fddbe00493a0f96c4172c67be1eb719f0fe8ed --- diff --git a/webmdec.cc b/webmdec.cc index d591f3e3d..60b01ad4b 100644 --- a/webmdec.cc +++ b/webmdec.cc @@ -63,6 +63,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx, struct VpxInputContext *vpx_ctx) { mkvparser::MkvReader *const reader = new mkvparser::MkvReader(vpx_ctx->file); webm_ctx->reader = reader; + webm_ctx->reached_eos = 0; mkvparser::EBMLHeader header; long long pos = 0; @@ -121,6 +122,11 @@ int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer, size_t *bytes_in_buffer, 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) { + return 1; + } mkvparser::Segment *const segment = reinterpret_cast(webm_ctx->segment); const mkvparser::Cluster* cluster = @@ -140,6 +146,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx, cluster = segment->GetNext(cluster); if (cluster == NULL || cluster->EOS()) { *bytes_in_buffer = 0; + webm_ctx->reached_eos = 1; return 1; } status = cluster->GetFirst(block_entry); diff --git a/webmdec.h b/webmdec.h index 1cd35d41a..7d1638035 100644 --- a/webmdec.h +++ b/webmdec.h @@ -29,6 +29,7 @@ struct WebmInputContext { int video_track_index; uint64_t timestamp_ns; int is_key_frame; + int reached_eos; }; // Checks if the input is a WebM file. If so, initializes WebMInputContext so