Moved vp8dx_get_raw_frame() call to vp8_get_frame()
authorScott LaVarnway <slavarnway@google.com>
Wed, 19 Sep 2012 19:30:44 +0000 (12:30 -0700)
committerScott LaVarnway <slavarnway@google.com>
Wed, 19 Sep 2012 19:30:44 +0000 (12:30 -0700)
This change is necessary for the frame-based multithreading
implementation.
Since the postproc occurs in this call, vpxdec was modified to time around
vpx_codec_get_frame()

Change-Id: I389acf78b6003cd35e41becc16c893f7d3028523

vp8/vp8_dx_iface.c
vpxdec.c

index fe8c9a0c0bfd8834d19356f8995024726c888824..3290de9fa8a4577e3a870f4a843d5ab912446b8a 100644 (file)
@@ -70,7 +70,7 @@ struct vpx_codec_alg_priv
 #endif
     vpx_image_t             img;
     int                     img_setup;
-    int                     img_avail;
+    void                    *user_priv;
 };
 
 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_t flags)
@@ -345,8 +345,6 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t  *ctx,
 {
     vpx_codec_err_t res = VPX_CODEC_OK;
 
-    ctx->img_avail = 0;
-
     /* Determine the stream parameters. Note that we rely on peek_si to
      * validate that we have a buffer that does not wrap around the top
      * of the heap.
@@ -428,6 +426,27 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t  *ctx,
     }
 
     if (!res && ctx->pbi)
+    {
+        ctx->user_priv = user_priv;
+        if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
+        {
+            VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
+            res = update_error_state(ctx, &pbi->common.error);
+        }
+    }
+
+    return res;
+}
+
+static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t  *ctx,
+                                  vpx_codec_iter_t      *iter)
+{
+    vpx_image_t *img = NULL;
+
+    /* iter acts as a flip flop, so an image is only returned on the first
+     * call to get_frame.
+     */
+    if (!(*iter))
     {
         YV12_BUFFER_CONFIG sd;
         int64_t time_stamp = 0, time_end_stamp = 0;
@@ -454,34 +473,10 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t  *ctx,
 #endif
         }
 
-        if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
+        if (0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, &flags))
         {
-            VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
-            res = update_error_state(ctx, &pbi->common.error);
-        }
-
-        if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, &flags))
-        {
-            yuvconfig2image(&ctx->img, &sd, user_priv);
-            ctx->img_avail = 1;
-        }
-    }
-
-    return res;
-}
+            yuvconfig2image(&ctx->img, &sd, ctx->user_priv);
 
-static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t  *ctx,
-                                  vpx_codec_iter_t      *iter)
-{
-    vpx_image_t *img = NULL;
-
-    if (ctx->img_avail)
-    {
-        /* iter acts as a flip flop, so an image is only returned on the first
-         * call to get_frame.
-         */
-        if (!(*iter))
-        {
             img = &ctx->img;
             *iter = img;
         }
index 865790558209ac0852e0c8ad7a70f76b393671ea..9b728bf822be27a3e8e144377d0613b23e5bd7f2 100644 (file)
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -1066,9 +1066,14 @@ 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);