webmdec: Fix return values for webm_read_frame

Fix return values for webm_read_frame so that we can distinguish between
error and end of stream. 0 - Success, 1 - End of stream, -1 error.

Change-Id: Ic35d0c7d7a166e027711a3d2300ecdda25a5d0cc
This commit is contained in:
Vignesh Venkatasubramanian 2014-04-14 15:21:22 -07:00
parent 096b44f43b
commit b92eb54106
2 changed files with 14 additions and 6 deletions

View File

@ -114,6 +114,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
size_t *buffer_size) { size_t *buffer_size) {
if (webm_ctx->chunk >= webm_ctx->chunks) { if (webm_ctx->chunk >= webm_ctx->chunks) {
uint32_t track; uint32_t track;
int status;
do { do {
/* End of this packet, get another. */ /* End of this packet, get another. */
@ -122,21 +123,23 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
webm_ctx->pkt = NULL; webm_ctx->pkt = NULL;
} }
if (nestegg_read_packet(webm_ctx->nestegg_ctx, &webm_ctx->pkt) <= 0 || status = nestegg_read_packet(webm_ctx->nestegg_ctx, &webm_ctx->pkt);
nestegg_packet_track(webm_ctx->pkt, &track)) { if (status <= 0)
return 1; return status ? status : 1;
}
if (nestegg_packet_track(webm_ctx->pkt, &track))
return -1;
} while (track != webm_ctx->video_track); } while (track != webm_ctx->video_track);
if (nestegg_packet_count(webm_ctx->pkt, &webm_ctx->chunks)) if (nestegg_packet_count(webm_ctx->pkt, &webm_ctx->chunks))
return 1; return -1;
webm_ctx->chunk = 0; webm_ctx->chunk = 0;
} }
if (nestegg_packet_data(webm_ctx->pkt, webm_ctx->chunk, if (nestegg_packet_data(webm_ctx->pkt, webm_ctx->chunk,
buffer, bytes_in_buffer)) { buffer, bytes_in_buffer)) {
return 1; return -1;
} }
webm_ctx->chunk++; webm_ctx->chunk++;

View File

@ -31,6 +31,11 @@ struct WebmInputContext {
int file_is_webm(struct WebmInputContext *webm_ctx, int file_is_webm(struct WebmInputContext *webm_ctx,
struct VpxInputContext *vpx_ctx); struct VpxInputContext *vpx_ctx);
/* Reads a WebM video frame. Return values:
* 0 - Success
* 1 - End of File
* -1 - Error
*/
int webm_read_frame(struct WebmInputContext *webm_ctx, int webm_read_frame(struct WebmInputContext *webm_ctx,
uint8_t **buffer, uint8_t **buffer,
size_t *bytes_in_buffer, size_t *bytes_in_buffer,