Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / libyuv / source / convert_from.cc
index 1e10832..c1a2f62 100644 (file)
@@ -39,14 +39,14 @@ static int I420ToI4xx(const uint8* src_y, int src_stride_y,
                       uint8* dst_v, int dst_stride_v,
                       int src_y_width, int src_y_height,
                       int dst_uv_width, int dst_uv_height) {
-  if (src_y_width == 0 || src_y_height == 0 ||
-      dst_uv_width <= 0 || dst_uv_height <= 0) {
-    return -1;
-  }
   const int dst_y_width = Abs(src_y_width);
   const int dst_y_height = Abs(src_y_height);
   const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1);
   const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1);
+  if (src_y_width == 0 || src_y_height == 0 ||
+      dst_uv_width <= 0 || dst_uv_height <= 0) {
+    return -1;
+  }
   ScalePlane(src_y, src_stride_y, src_y_width, src_y_height,
              dst_y, dst_stride_y, dst_y_width, dst_y_height,
              kFilterBilinear);
@@ -150,6 +150,10 @@ int I422ToYUY2(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_yuy2, int dst_stride_yuy2,
                int width, int height) {
+  int y;
+  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u,
+                        const uint8* src_v, uint8* dst_yuy2, int width) =
+      I422ToYUY2Row_C;
   if (!src_y || !src_u || !src_v || !dst_yuy2 ||
       width <= 0 || height == 0) {
     return -1;
@@ -169,9 +173,6 @@ int I422ToYUY2(const uint8* src_y, int src_stride_y,
     height = 1;
     src_stride_y = src_stride_u = src_stride_v = dst_stride_yuy2 = 0;
   }
-  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u,
-                        const uint8* src_v, uint8* dst_yuy2, int width) =
-      I422ToYUY2Row_C;
 #if defined(HAS_I422TOYUY2ROW_SSE2)
   if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
     I422ToYUY2Row = I422ToYUY2Row_Any_SSE2;
@@ -188,7 +189,7 @@ int I422ToYUY2(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width);
     src_y += src_stride_y;
     src_u += src_stride_u;
@@ -204,6 +205,10 @@ int I420ToYUY2(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_yuy2, int dst_stride_yuy2,
                int width, int height) {
+  int y;
+  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u,
+                        const uint8* src_v, uint8* dst_yuy2, int width) =
+      I422ToYUY2Row_C;
   if (!src_y || !src_u || !src_v || !dst_yuy2 ||
       width <= 0 || height == 0) {
     return -1;
@@ -214,9 +219,6 @@ int I420ToYUY2(const uint8* src_y, int src_stride_y,
     dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
     dst_stride_yuy2 = -dst_stride_yuy2;
   }
-  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u,
-                        const uint8* src_v, uint8* dst_yuy2, int width) =
-      I422ToYUY2Row_C;
 #if defined(HAS_I422TOYUY2ROW_SSE2)
   if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
     I422ToYUY2Row = I422ToYUY2Row_Any_SSE2;
@@ -233,7 +235,7 @@ int I420ToYUY2(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height - 1; y += 2) {
+  for (y = 0; y < height - 1; y += 2) {
     I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width);
     I422ToYUY2Row(src_y + src_stride_y, src_u, src_v,
                   dst_yuy2 + dst_stride_yuy2, width);
@@ -254,6 +256,10 @@ int I422ToUYVY(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_uyvy, int dst_stride_uyvy,
                int width, int height) {
+  int y;
+  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u,
+                        const uint8* src_v, uint8* dst_uyvy, int width) =
+      I422ToUYVYRow_C;
   if (!src_y || !src_u || !src_v || !dst_uyvy ||
       width <= 0 || height == 0) {
     return -1;
@@ -273,9 +279,6 @@ int I422ToUYVY(const uint8* src_y, int src_stride_y,
     height = 1;
     src_stride_y = src_stride_u = src_stride_v = dst_stride_uyvy = 0;
   }
-  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u,
-                        const uint8* src_v, uint8* dst_uyvy, int width) =
-      I422ToUYVYRow_C;
 #if defined(HAS_I422TOUYVYROW_SSE2)
   if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
     I422ToUYVYRow = I422ToUYVYRow_Any_SSE2;
@@ -292,7 +295,7 @@ int I422ToUYVY(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width);
     src_y += src_stride_y;
     src_u += src_stride_u;
@@ -308,6 +311,10 @@ int I420ToUYVY(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_uyvy, int dst_stride_uyvy,
                int width, int height) {
+  int y;
+  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u,
+                        const uint8* src_v, uint8* dst_uyvy, int width) =
+      I422ToUYVYRow_C;
   if (!src_y || !src_u || !src_v || !dst_uyvy ||
       width <= 0 || height == 0) {
     return -1;
@@ -318,9 +325,6 @@ int I420ToUYVY(const uint8* src_y, int src_stride_y,
     dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
     dst_stride_uyvy = -dst_stride_uyvy;
   }
-  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u,
-                        const uint8* src_v, uint8* dst_uyvy, int width) =
-      I422ToUYVYRow_C;
 #if defined(HAS_I422TOUYVYROW_SSE2)
   if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
     I422ToUYVYRow = I422ToUYVYRow_Any_SSE2;
@@ -337,7 +341,7 @@ int I420ToUYVY(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height - 1; y += 2) {
+  for (y = 0; y < height - 1; y += 2) {
     I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width);
     I422ToUYVYRow(src_y + src_stride_y, src_u, src_v,
                   dst_uyvy + dst_stride_uyvy, width);
@@ -359,6 +363,12 @@ int I420ToNV12(const uint8* src_y, int src_stride_y,
                uint8* dst_y, int dst_stride_y,
                uint8* dst_uv, int dst_stride_uv,
                int width, int height) {
+  int y;
+  void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
+      int width) = MergeUVRow_C;
+  // Coalesce rows.
+  int halfwidth = (width + 1) >> 1;
+  int halfheight = (height + 1) >> 1;
   if (!src_y || !src_u || !src_v || !dst_y || !dst_uv ||
       width <= 0 || height == 0) {
     return -1;
@@ -366,15 +376,12 @@ int I420ToNV12(const uint8* src_y, int src_stride_y,
   // Negative height means invert the image.
   if (height < 0) {
     height = -height;
-    int halfheight = (height + 1) >> 1;
+    halfheight = (height + 1) >> 1;
     dst_y = dst_y + (height - 1) * dst_stride_y;
     dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv;
     dst_stride_y = -dst_stride_y;
     dst_stride_uv = -dst_stride_uv;
   }
-  // Coalesce rows.
-  int halfwidth = (width + 1) >> 1;
-  int halfheight = (height + 1) >> 1;
   if (src_stride_y == width &&
       dst_stride_y == width) {
     width *= height;
@@ -389,8 +396,6 @@ int I420ToNV12(const uint8* src_y, int src_stride_y,
     halfheight = 1;
     src_stride_u = src_stride_v = dst_stride_uv = 0;
   }
-  void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
-                      int width) = MergeUVRow_C;
 #if defined(HAS_MERGEUVROW_SSE2)
   if (TestCpuFlag(kCpuHasSSE2) && halfwidth >= 16) {
     MergeUVRow_ = MergeUVRow_Any_SSE2;
@@ -422,7 +427,7 @@ int I420ToNV12(const uint8* src_y, int src_stride_y,
 #endif
 
   CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
-  for (int y = 0; y < halfheight; ++y) {
+  for (y = 0; y < halfheight; ++y) {
     // Merge a row of U and V into a row of UV.
     MergeUVRow_(src_u, src_v, dst_uv, halfwidth);
     src_u += src_stride_u;
@@ -454,6 +459,12 @@ int I420ToARGB(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_argb, int dst_stride_argb,
                int width, int height) {
+  int y;
+  void (*I422ToARGBRow)(const uint8* y_buf,
+                        const uint8* u_buf,
+                        const uint8* v_buf,
+                        uint8* rgb_buf,
+                        int width) = I422ToARGBRow_C;
   if (!src_y || !src_u || !src_v || !dst_argb ||
       width <= 0 || height == 0) {
     return -1;
@@ -464,11 +475,6 @@ int I420ToARGB(const uint8* src_y, int src_stride_y,
     dst_argb = dst_argb + (height - 1) * dst_stride_argb;
     dst_stride_argb = -dst_stride_argb;
   }
-  void (*I422ToARGBRow)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToARGBRow_C;
 #if defined(HAS_I422TOARGBROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
@@ -506,7 +512,7 @@ int I420ToARGB(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToARGBRow(src_y, src_u, src_v, dst_argb, width);
     dst_argb += dst_stride_argb;
     src_y += src_stride_y;
@@ -525,6 +531,12 @@ int I420ToBGRA(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_bgra, int dst_stride_bgra,
                int width, int height) {
+  int y;
+  void (*I422ToBGRARow)(const uint8* y_buf,
+                        const uint8* u_buf,
+                        const uint8* v_buf,
+                        uint8* rgb_buf,
+                        int width) = I422ToBGRARow_C;
   if (!src_y || !src_u || !src_v || !dst_bgra ||
       width <= 0 || height == 0) {
     return -1;
@@ -535,11 +547,6 @@ int I420ToBGRA(const uint8* src_y, int src_stride_y,
     dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra;
     dst_stride_bgra = -dst_stride_bgra;
   }
-  void (*I422ToBGRARow)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToBGRARow_C;
 #if defined(HAS_I422TOBGRAROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToBGRARow = I422ToBGRARow_Any_SSSE3;
@@ -567,7 +574,7 @@ int I420ToBGRA(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToBGRARow(src_y, src_u, src_v, dst_bgra, width);
     dst_bgra += dst_stride_bgra;
     src_y += src_stride_y;
@@ -586,6 +593,12 @@ int I420ToABGR(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_abgr, int dst_stride_abgr,
                int width, int height) {
+  int y;
+  void (*I422ToABGRRow)(const uint8* y_buf,
+                        const uint8* u_buf,
+                        const uint8* v_buf,
+                        uint8* rgb_buf,
+                        int width) = I422ToABGRRow_C;
   if (!src_y || !src_u || !src_v || !dst_abgr ||
       width <= 0 || height == 0) {
     return -1;
@@ -596,11 +609,6 @@ int I420ToABGR(const uint8* src_y, int src_stride_y,
     dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr;
     dst_stride_abgr = -dst_stride_abgr;
   }
-  void (*I422ToABGRRow)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToABGRRow_C;
 #if defined(HAS_I422TOABGRROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToABGRRow = I422ToABGRRow_Any_SSSE3;
@@ -620,7 +628,7 @@ int I420ToABGR(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width);
     dst_abgr += dst_stride_abgr;
     src_y += src_stride_y;
@@ -639,6 +647,12 @@ int I420ToRGBA(const uint8* src_y, int src_stride_y,
                const uint8* src_v, int src_stride_v,
                uint8* dst_rgba, int dst_stride_rgba,
                int width, int height) {
+  int y;
+  void (*I422ToRGBARow)(const uint8* y_buf,
+                        const uint8* u_buf,
+                        const uint8* v_buf,
+                        uint8* rgb_buf,
+                        int width) = I422ToRGBARow_C;
   if (!src_y || !src_u || !src_v || !dst_rgba ||
       width <= 0 || height == 0) {
     return -1;
@@ -649,11 +663,6 @@ int I420ToRGBA(const uint8* src_y, int src_stride_y,
     dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba;
     dst_stride_rgba = -dst_stride_rgba;
   }
-  void (*I422ToRGBARow)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToRGBARow_C;
 #if defined(HAS_I422TORGBAROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToRGBARow = I422ToRGBARow_Any_SSSE3;
@@ -673,7 +682,7 @@ int I420ToRGBA(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToRGBARow(src_y, src_u, src_v, dst_rgba, width);
     dst_rgba += dst_stride_rgba;
     src_y += src_stride_y;
@@ -692,6 +701,12 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y,
                 const uint8* src_v, int src_stride_v,
                 uint8* dst_rgb24, int dst_stride_rgb24,
                 int width, int height) {
+  int y;
+  void (*I422ToRGB24Row)(const uint8* y_buf,
+                         const uint8* u_buf,
+                         const uint8* v_buf,
+                         uint8* rgb_buf,
+                         int width) = I422ToRGB24Row_C;
   if (!src_y || !src_u || !src_v || !dst_rgb24 ||
       width <= 0 || height == 0) {
     return -1;
@@ -702,11 +717,6 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y,
     dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24;
     dst_stride_rgb24 = -dst_stride_rgb24;
   }
-  void (*I422ToRGB24Row)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToRGB24Row_C;
 #if defined(HAS_I422TORGB24ROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToRGB24Row = I422ToRGB24Row_Any_SSSE3;
@@ -723,7 +733,7 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToRGB24Row(src_y, src_u, src_v, dst_rgb24, width);
     dst_rgb24 += dst_stride_rgb24;
     src_y += src_stride_y;
@@ -742,6 +752,12 @@ int I420ToRAW(const uint8* src_y, int src_stride_y,
                 const uint8* src_v, int src_stride_v,
                 uint8* dst_raw, int dst_stride_raw,
                 int width, int height) {
+  int y;
+  void (*I422ToRAWRow)(const uint8* y_buf,
+                       const uint8* u_buf,
+                       const uint8* v_buf,
+                       uint8* rgb_buf,
+                       int width) = I422ToRAWRow_C;
   if (!src_y || !src_u || !src_v || !dst_raw ||
       width <= 0 || height == 0) {
     return -1;
@@ -752,11 +768,6 @@ int I420ToRAW(const uint8* src_y, int src_stride_y,
     dst_raw = dst_raw + (height - 1) * dst_stride_raw;
     dst_stride_raw = -dst_stride_raw;
   }
-  void (*I422ToRAWRow)(const uint8* y_buf,
-                        const uint8* u_buf,
-                        const uint8* v_buf,
-                        uint8* rgb_buf,
-                        int width) = I422ToRAWRow_C;
 #if defined(HAS_I422TORAWROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToRAWRow = I422ToRAWRow_Any_SSSE3;
@@ -773,7 +784,7 @@ int I420ToRAW(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToRAWRow(src_y, src_u, src_v, dst_raw, width);
     dst_raw += dst_stride_raw;
     src_y += src_stride_y;
@@ -792,6 +803,12 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
                    const uint8* src_v, int src_stride_v,
                    uint8* dst_argb1555, int dst_stride_argb1555,
                    int width, int height) {
+  int y;
+  void (*I422ToARGB1555Row)(const uint8* y_buf,
+                            const uint8* u_buf,
+                            const uint8* v_buf,
+                            uint8* rgb_buf,
+                            int width) = I422ToARGB1555Row_C;
   if (!src_y || !src_u || !src_v || !dst_argb1555 ||
       width <= 0 || height == 0) {
     return -1;
@@ -802,11 +819,6 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
     dst_argb1555 = dst_argb1555 + (height - 1) * dst_stride_argb1555;
     dst_stride_argb1555 = -dst_stride_argb1555;
   }
-  void (*I422ToARGB1555Row)(const uint8* y_buf,
-                          const uint8* u_buf,
-                          const uint8* v_buf,
-                          uint8* rgb_buf,
-                          int width) = I422ToARGB1555Row_C;
 #if defined(HAS_I422TOARGB1555ROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToARGB1555Row = I422ToARGB1555Row_Any_SSSE3;
@@ -823,7 +835,7 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToARGB1555Row(src_y, src_u, src_v, dst_argb1555, width);
     dst_argb1555 += dst_stride_argb1555;
     src_y += src_stride_y;
@@ -843,6 +855,12 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y,
                    const uint8* src_v, int src_stride_v,
                    uint8* dst_argb4444, int dst_stride_argb4444,
                    int width, int height) {
+  int y;
+  void (*I422ToARGB4444Row)(const uint8* y_buf,
+                            const uint8* u_buf,
+                            const uint8* v_buf,
+                            uint8* rgb_buf,
+                            int width) = I422ToARGB4444Row_C;
   if (!src_y || !src_u || !src_v || !dst_argb4444 ||
       width <= 0 || height == 0) {
     return -1;
@@ -853,11 +871,6 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y,
     dst_argb4444 = dst_argb4444 + (height - 1) * dst_stride_argb4444;
     dst_stride_argb4444 = -dst_stride_argb4444;
   }
-  void (*I422ToARGB4444Row)(const uint8* y_buf,
-                          const uint8* u_buf,
-                          const uint8* v_buf,
-                          uint8* rgb_buf,
-                          int width) = I422ToARGB4444Row_C;
 #if defined(HAS_I422TOARGB4444ROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToARGB4444Row = I422ToARGB4444Row_Any_SSSE3;
@@ -874,7 +887,7 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToARGB4444Row(src_y, src_u, src_v, dst_argb4444, width);
     dst_argb4444 += dst_stride_argb4444;
     src_y += src_stride_y;
@@ -893,6 +906,12 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
                  const uint8* src_v, int src_stride_v,
                  uint8* dst_rgb565, int dst_stride_rgb565,
                  int width, int height) {
+  int y;
+  void (*I422ToRGB565Row)(const uint8* y_buf,
+                          const uint8* u_buf,
+                          const uint8* v_buf,
+                          uint8* rgb_buf,
+                          int width) = I422ToRGB565Row_C;
   if (!src_y || !src_u || !src_v || !dst_rgb565 ||
       width <= 0 || height == 0) {
     return -1;
@@ -903,11 +922,6 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
     dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565;
     dst_stride_rgb565 = -dst_stride_rgb565;
   }
-  void (*I422ToRGB565Row)(const uint8* y_buf,
-                          const uint8* u_buf,
-                          const uint8* v_buf,
-                          uint8* rgb_buf,
-                          int width) = I422ToRGB565Row_C;
 #if defined(HAS_I422TORGB565ROW_SSSE3)
   if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
     I422ToRGB565Row = I422ToRGB565Row_Any_SSSE3;
@@ -924,7 +938,7 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
   }
 #endif
 
-  for (int y = 0; y < height; ++y) {
+  for (y = 0; y < height; ++y) {
     I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, width);
     dst_rgb565 += dst_stride_rgb565;
     src_y += src_stride_y;
@@ -945,11 +959,11 @@ int ConvertFromI420(const uint8* y, int y_stride,
                     int width, int height,
                     uint32 fourcc) {
   uint32 format = CanonicalFourCC(fourcc);
+  int r = 0;
   if (!y || !u|| !v || !dst_sample ||
       width <= 0 || height == 0) {
     return -1;
   }
-  int r = 0;
   switch (format) {
     // Single plane formats
     case FOURCC_YUY2: