shithub: libvpx

Download patch

ref: 3c054811bde9f4430ae40e9f07d1e14589c8d7e0
parent: 6f8b3039afbb5c3118bf1363d4c7ff854e506d97
author: Dmitry Kovalev <dkovalev@google.com>
date: Fri Jan 17 07:19:19 EST 2014

Adding vpx_image_scale() function in vpxdec.

Change-Id: I29eaffff5089b26e8778a977c3b3da11800f1c49

--- a/vpxdec.c
+++ b/vpxdec.c
@@ -131,6 +131,21 @@
 };
 #endif
 
+static int vpx_image_scale(vpx_image_t *src, vpx_image_t *dst,
+                           FilterMode mode) {
+  assert(src->fmt == VPX_IMG_FMT_I420);
+  assert(dst->fmt == VPX_IMG_FMT_I420);
+  return I420Scale(src->planes[VPX_PLANE_Y], src->stride[VPX_PLANE_Y],
+                   src->planes[VPX_PLANE_U], src->stride[VPX_PLANE_U],
+                   src->planes[VPX_PLANE_V], src->stride[VPX_PLANE_V],
+                   src->d_w, src->d_h,
+                   dst->planes[VPX_PLANE_Y], dst->stride[VPX_PLANE_Y],
+                   dst->planes[VPX_PLANE_U], dst->stride[VPX_PLANE_U],
+                   dst->planes[VPX_PLANE_V], dst->stride[VPX_PLANE_V],
+                   dst->d_w, dst->d_h,
+                   mode);
+}
+
 void usage_exit() {
   int i;
 
@@ -490,8 +505,6 @@
   int                     num_external_frame_buffers = 0;
   int                     fb_lru_cache = 0;
   vpx_codec_frame_buffer_t *frame_buffers = NULL;
-  int                     display_width = 0;
-  int                     display_height = 0;
 
   struct VpxDecInputContext input = {0};
   struct VpxInputContext vpx_input_ctx = {0};
@@ -866,8 +879,8 @@
           // use the width and height specified in the container. If either of
           // these is set to 0, use the display size set in the first frame
           // header.
-          display_width = vpx_input_ctx.width;
-          display_height = vpx_input_ctx.height;
+          int display_width = vpx_input_ctx.width;
+          int display_height = vpx_input_ctx.height;
           if (!display_width || !display_height) {
             int display_size[2];
             if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE,
@@ -884,23 +897,12 @@
                                      display_height, 16);
         }
 
-        if (img->d_w != display_width || img->d_h != display_height) {
-          assert(img->fmt == VPX_IMG_FMT_I420);
-          I420Scale(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y],
-                    img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U],
-                    img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V],
-                    img->d_w, img->d_h,
-                    scaled_img->planes[VPX_PLANE_Y],
-                    scaled_img->stride[VPX_PLANE_Y],
-                    scaled_img->planes[VPX_PLANE_U],
-                    scaled_img->stride[VPX_PLANE_U],
-                    scaled_img->planes[VPX_PLANE_V],
-                    scaled_img->stride[VPX_PLANE_V],
-                    display_width, display_height,
-                    kFilterBox);
+        if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) {
+          vpx_image_scale(img, scaled_img, kFilterBox);
           img = scaled_img;
         }
       }
+
       if (img) {
         const int PLANES_YUV[] = {VPX_PLANE_Y, VPX_PLANE_U, VPX_PLANE_V};
         const int PLANES_YVU[] = {VPX_PLANE_Y, VPX_PLANE_V, VPX_PLANE_U};