diff --git a/webmdec.c b/webmdec.c
index 7cacdf922e89f89b87bc81f7689e110fa93a26f0..0341e82340b6f3479302d3b3462105190e997f0a 100644
--- a/webmdec.c
+++ b/webmdec.c
@@ -114,6 +114,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
                     size_t *buffer_size) {
   if (webm_ctx->chunk >= webm_ctx->chunks) {
     uint32_t track;
+    int status;
 
     do {
       /* End of this packet, get another. */
@@ -122,21 +123,23 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
         webm_ctx->pkt = NULL;
       }
 
-      if (nestegg_read_packet(webm_ctx->nestegg_ctx, &webm_ctx->pkt) <= 0 ||
-          nestegg_packet_track(webm_ctx->pkt, &track)) {
-        return 1;
-      }
+      status = nestegg_read_packet(webm_ctx->nestegg_ctx, &webm_ctx->pkt);
+      if (status <= 0)
+        return status ? status : 1;
+
+      if (nestegg_packet_track(webm_ctx->pkt, &track))
+        return -1;
     } while (track != webm_ctx->video_track);
 
     if (nestegg_packet_count(webm_ctx->pkt, &webm_ctx->chunks))
-      return 1;
+      return -1;
 
     webm_ctx->chunk = 0;
   }
 
   if (nestegg_packet_data(webm_ctx->pkt, webm_ctx->chunk,
                           buffer, bytes_in_buffer)) {
-    return 1;
+    return -1;
   }
 
   webm_ctx->chunk++;
diff --git a/webmdec.h b/webmdec.h
index fa5a52eaf10930fa3c19b39d667a95714ff64f50..108c6ade9b5b90ab7a9af1944856e7d10650b66c 100644
--- a/webmdec.h
+++ b/webmdec.h
@@ -31,6 +31,11 @@ struct WebmInputContext {
 int file_is_webm(struct WebmInputContext *webm_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,
                     uint8_t **buffer,
                     size_t *bytes_in_buffer,