]> granicus.if.org Git - libvpx/commitdiff
Modified vpxdec loop
authorScott LaVarnway <slavarnway@google.com>
Fri, 7 Jun 2013 16:39:03 +0000 (12:39 -0400)
committerScott LaVarnway <slavarnway@google.com>
Fri, 7 Jun 2013 16:39:03 +0000 (12:39 -0400)
to work like vpxenc.  This is required for the frame-based
multithreading.

Change-Id: I338ae9c7d52b0541f3536cc033d6b89f00866e74

vp8/vp8_dx_iface.c
vpxdec.c

index 90a175436dbf517a36d42243de85303deb02f54b..45cf3859e30c04239f9b0c4c1b3574360b7b1890 100644 (file)
@@ -659,7 +659,7 @@ static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t  *ctx,
     /* iter acts as a flip flop, so an image is only returned on the first
      * call to get_frame.
      */
-    if (!(*iter))
+    if (!(*iter) && ctx->yv12_frame_buffers.pbi[0])
     {
         YV12_BUFFER_CONFIG sd;
         int64_t time_stamp = 0, time_end_stamp = 0;
@@ -943,10 +943,10 @@ static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
 {
 
     int *corrupted = va_arg(args, int *);
+    VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0];
 
-    if (corrupted)
+    if (corrupted && pbi)
     {
-        VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0];
         *corrupted = pbi->common.frame_to_show->corrupted;
 
         return VPX_CODEC_OK;
index 41c654faea5230f3969a4cf0da2a5af703da8b72..5bde0c862e99b4310a52c1feabc9eec371dc2278 100644 (file)
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -714,6 +714,7 @@ int main(int argc, const char **argv_) {
   int                     do_scale = 0;
   int                     stream_w = 0, stream_h = 0;
   vpx_image_t             *scaled_img = NULL;
+  int                     frame_avail, got_data;
 
   /* Parse command line */
   exec_name = argv_[0];
@@ -980,30 +981,50 @@ int main(int argc, const char **argv_) {
     arg_skip--;
   }
 
+  frame_avail = 1;
+  got_data = 0;
+
   /* Decode file */
-  while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) {
+  while (frame_avail || got_data) {
     vpx_codec_iter_t  iter = NULL;
     vpx_image_t    *img;
     struct vpx_usec_timer timer;
     int                   corrupted;
 
-    vpx_usec_timer_start(&timer);
+    frame_avail = 0;
+    if (!stop_after || frame_in < stop_after) {
+      if(!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) {
+        frame_avail = 1;
+        frame_in++;
 
-    if (vpx_codec_decode(&decoder, buf, (unsigned int)buf_sz, NULL, 0)) {
-      const char *detail = vpx_codec_error_detail(&decoder);
-      fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&decoder));
+        vpx_usec_timer_start(&timer);
 
-      if (detail)
-        fprintf(stderr, "  Additional information: %s\n", detail);
+        if (vpx_codec_decode(&decoder, buf, (unsigned int)buf_sz, NULL, 0)) {
+          const char *detail = vpx_codec_error_detail(&decoder);
+          fprintf(stderr, "Failed to decode frame: %s\n",
+                  vpx_codec_error(&decoder));
 
-      goto fail;
+          if (detail)
+            fprintf(stderr, "  Additional information: %s\n", detail);
+          goto fail;
+        }
+
+        vpx_usec_timer_mark(&timer);
+        dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer);
+      }
+    }
+
+    vpx_usec_timer_start(&timer);
+
+    got_data = 0;
+    if ((img = vpx_codec_get_frame(&decoder, &iter))) {
+      ++frame_out;
+      got_data = 1;
     }
 
     vpx_usec_timer_mark(&timer);
     dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer);
 
-    ++frame_in;
-
     if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) {
       fprintf(stderr, "Failed VP8_GET_FRAME_CORRUPTED: %s\n",
               vpx_codec_error(&decoder));
@@ -1011,14 +1032,6 @@ int main(int argc, const char **argv_) {
     }
     frames_corrupted += corrupted;
 
-    vpx_usec_timer_start(&timer);
-
-    if ((img = vpx_codec_get_frame(&decoder, &iter)))
-      ++frame_out;
-
-    vpx_usec_timer_mark(&timer);
-    dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer);
-
     if (progress)
       show_progress(frame_in, frame_out, dx_time);