Merge "examples: use I420 input for encoders"
authorJohn Koleszar <jkoleszar@google.com>
Wed, 26 May 2010 13:27:34 +0000 (06:27 -0700)
committerCode Review <code-review@webmproject.org>
Wed, 26 May 2010 13:27:34 +0000 (06:27 -0700)
build/make/configure.sh
ivfdec.c
ivfenc.c
vp8/vp8_common.mk
vp8/vp8_cx_iface.c
vp8/vp8_dx_iface.c
vpx/src/vpx_image.c
vpx/vpx_image.h

index e7dd584..62d8b64 100755 (executable)
@@ -478,6 +478,42 @@ setup_gnu_toolchain() {
 }
 
 process_common_toolchain() {
+    if [ -z "$toolchain" ]; then
+        uname="$(uname -a)"
+
+        # detect tgt_isa
+        case "$uname" in
+            *x86_64*)
+                tgt_isa=x86_64
+                ;;
+            *i[3456]86*)
+                tgt_isa=x86
+                ;;
+        esac
+
+        # detect tgt_os
+        case "$uname" in
+            *Darwin\ Kernel\ Version\ 8*)
+                tgt_isa=universal
+                tgt_os=darwin8
+                ;;
+            *Darwin\ Kernel\ Version\ 9*)
+                tgt_isa=universal
+                tgt_os=darwin9
+                ;;
+            *Msys*|*Cygwin*)
+                tgt_os=win32
+                ;;
+            *Linux*|*BSD*)
+                tgt_os=linux
+                ;;
+        esac
+
+        if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
+            toolchain=${tgt_isa}-${tgt_os}-gcc
+        fi
+    fi
+
     toolchain=${toolchain:-generic-gnu}
 
     is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
index 94045f2..8ee60b6 100644 (file)
--- a/ivfdec.c
+++ b/ivfdec.c
@@ -534,28 +534,28 @@ int main(int argc, const char **argv_)
                     out = out_open(out_fn, do_md5);
                 }
 
-                buf = img->planes[PLANE_Y];
+                buf = img->planes[VPX_PLANE_Y];
 
                 for (y = 0; y < img->d_h; y++)
                 {
                     out_put(out, buf, img->d_w, do_md5);
-                    buf += img->stride[PLANE_Y];
+                    buf += img->stride[VPX_PLANE_Y];
                 }
 
-                buf = img->planes[flipuv?PLANE_V:PLANE_U];
+                buf = img->planes[flipuv?VPX_PLANE_V:VPX_PLANE_U];
 
                 for (y = 0; y < (1 + img->d_h) / 2; y++)
                 {
                     out_put(out, buf, (1 + img->d_w) / 2, do_md5);
-                    buf += img->stride[PLANE_U];
+                    buf += img->stride[VPX_PLANE_U];
                 }
 
-                buf = img->planes[flipuv?PLANE_U:PLANE_V];
+                buf = img->planes[flipuv?VPX_PLANE_U:VPX_PLANE_V];
 
                 for (y = 0; y < (1 + img->d_h) / 2; y++)
                 {
                     out_put(out, buf, (1 + img->d_w) / 2, do_md5);
-                    buf += img->stride[PLANE_V];
+                    buf += img->stride[VPX_PLANE_V];
                 }
 
                 if (!fn2)
index 1f62199..65d11fa 100644 (file)
--- a/ivfenc.c
+++ b/ivfenc.c
@@ -247,10 +247,10 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int is_ivf)
         switch (plane)
         {
         case 1:
-            ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12? PLANE_V : PLANE_U];
+            ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12? VPX_PLANE_V : VPX_PLANE_U];
             break;
         case 2:
-            ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12?PLANE_U : PLANE_V];
+            ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12?VPX_PLANE_U : VPX_PLANE_V];
             break;
         default:
             ptr = img->planes[plane];
index ec467c5..a9efbd7 100644 (file)
@@ -11,9 +11,6 @@
 #add this file to the installed sources list
 VP8_COMMON_SRCS-yes += vp8_common.mk
 
-#common interface
-VP8_COMMON_SRCS-yes += vp8.h
-
 CFLAGS+=-I$(SRC_PATH_BARE)/$(VP8_PREFIX)common
 VP8_COMMON_SRCS-yes += common/type_aliases.h
 VP8_COMMON_SRCS-yes += common/pragmas.h
index b45b212..5883abd 100644 (file)
@@ -536,19 +536,19 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t   *img,
                                        YV12_BUFFER_CONFIG  *yv12)
 {
     vpx_codec_err_t        res = VPX_CODEC_OK;
-    yv12->y_buffer = img->planes[PLANE_Y];
-    yv12->u_buffer = img->planes[PLANE_U];
-    yv12->v_buffer = img->planes[PLANE_V];
+    yv12->y_buffer = img->planes[VPX_PLANE_Y];
+    yv12->u_buffer = img->planes[VPX_PLANE_U];
+    yv12->v_buffer = img->planes[VPX_PLANE_V];
 
     yv12->y_width  = img->d_w;
     yv12->y_height = img->d_h;
     yv12->uv_width = (1 + yv12->y_width) / 2;
     yv12->uv_height = (1 + yv12->y_height) / 2;
 
-    yv12->y_stride = img->stride[PLANE_Y];
-    yv12->uv_stride = img->stride[PLANE_U];
+    yv12->y_stride = img->stride[VPX_PLANE_Y];
+    yv12->uv_stride = img->stride[VPX_PLANE_U];
 
-    yv12->border  = (img->stride[PLANE_Y] - img->w) / 2;
+    yv12->border  = (img->stride[VPX_PLANE_Y] - img->w) / 2;
     yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12); //REG_YUV = 0
     return res;
 }
@@ -857,9 +857,9 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
             */
 
         ctx->preview_img.bps = 12;
-        ctx->preview_img.planes[PLANE_Y] = sd.y_buffer;
-        ctx->preview_img.planes[PLANE_U] = sd.u_buffer;
-        ctx->preview_img.planes[PLANE_V] = sd.v_buffer;
+        ctx->preview_img.planes[VPX_PLANE_Y] = sd.y_buffer;
+        ctx->preview_img.planes[VPX_PLANE_U] = sd.u_buffer;
+        ctx->preview_img.planes[VPX_PLANE_V] = sd.v_buffer;
 
         if (sd.clrtype == REG_YUV)
             ctx->preview_img.fmt = VPX_IMG_FMT_I420;
@@ -871,9 +871,9 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
 
         ctx->preview_img.d_w = ctx->cfg.g_w;
         ctx->preview_img.d_h = ctx->cfg.g_h;
-        ctx->preview_img.stride[PLANE_Y] = sd.y_stride;
-        ctx->preview_img.stride[PLANE_U] = sd.uv_stride;
-        ctx->preview_img.stride[PLANE_V] = sd.uv_stride;
+        ctx->preview_img.stride[VPX_PLANE_Y] = sd.y_stride;
+        ctx->preview_img.stride[VPX_PLANE_U] = sd.uv_stride;
+        ctx->preview_img.stride[VPX_PLANE_V] = sd.uv_stride;
         ctx->preview_img.w   = sd.y_width;
         ctx->preview_img.h   = sd.y_height;
 
index 9108bc2..19c59cd 100644 (file)
@@ -557,19 +557,19 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t   *img,
                                        YV12_BUFFER_CONFIG  *yv12)
 {
     vpx_codec_err_t        res = VPX_CODEC_OK;
-    yv12->y_buffer = img->planes[PLANE_Y];
-    yv12->u_buffer = img->planes[PLANE_U];
-    yv12->v_buffer = img->planes[PLANE_V];
+    yv12->y_buffer = img->planes[VPX_PLANE_Y];
+    yv12->u_buffer = img->planes[VPX_PLANE_U];
+    yv12->v_buffer = img->planes[VPX_PLANE_V];
 
     yv12->y_width  = img->d_w;
     yv12->y_height = img->d_h;
     yv12->uv_width = yv12->y_width / 2;
     yv12->uv_height = yv12->y_height / 2;
 
-    yv12->y_stride = img->stride[PLANE_Y];
-    yv12->uv_stride = img->stride[PLANE_U];
+    yv12->y_stride = img->stride[VPX_PLANE_Y];
+    yv12->uv_stride = img->stride[VPX_PLANE_U];
 
-    yv12->border  = (img->stride[PLANE_Y] - img->d_w) / 2;
+    yv12->border  = (img->stride[VPX_PLANE_Y] - img->d_w) / 2;
     yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12);
 
     return res;
index 881ab1a..55ee391 100644 (file)
@@ -133,8 +133,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t  *img,
     img->bps = bps;
 
     /* Calculate strides */
-    img->stride[PLANE_Y] = img->stride[PLANE_ALPHA] = s;
-    img->stride[PLANE_U] = img->stride[PLANE_V] = s >> xcs;
+    img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = s;
+    img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = s >> xcs;
 
     /* Default viewport to entire image */
     if (!vpx_img_set_rect(img, 0, 0, d_w, d_h))
@@ -180,8 +180,8 @@ int vpx_img_set_rect(vpx_image_t  *img,
         /* Calculate plane pointers */
         if (!(img->fmt & VPX_IMG_FMT_PLANAR))
         {
-            img->planes[PLANE_PACKED] =
-                img->img_data + x * img->bps / 8 + y * img->stride[PLANE_PACKED];
+            img->planes[VPX_PLANE_PACKED] =
+                img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED];
         }
         else
         {
@@ -189,33 +189,33 @@ int vpx_img_set_rect(vpx_image_t  *img,
 
             if (img->fmt & VPX_IMG_FMT_HAS_ALPHA)
             {
-                img->planes[PLANE_ALPHA] =
-                    data + x + y * img->stride[PLANE_ALPHA];
-                data += img->h * img->stride[PLANE_ALPHA];
+                img->planes[VPX_PLANE_ALPHA] =
+                    data + x + y * img->stride[VPX_PLANE_ALPHA];
+                data += img->h * img->stride[VPX_PLANE_ALPHA];
             }
 
-            img->planes[PLANE_Y] = data + x + y * img->stride[PLANE_Y];
-            data += img->h * img->stride[PLANE_Y];
+            img->planes[VPX_PLANE_Y] = data + x + y * img->stride[VPX_PLANE_Y];
+            data += img->h * img->stride[VPX_PLANE_Y];
 
             if (!(img->fmt & VPX_IMG_FMT_UV_FLIP))
             {
-                img->planes[PLANE_U] = data
+                img->planes[VPX_PLANE_U] = data
                                        + (x >> img->x_chroma_shift)
-                                       + (y >> img->y_chroma_shift) * img->stride[PLANE_U];
-                data += (img->h >> img->y_chroma_shift) * img->stride[PLANE_U];
-                img->planes[PLANE_V] = data
+                                       + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
+                data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
+                img->planes[VPX_PLANE_V] = data
                                        + (x >> img->x_chroma_shift)
-                                       + (y >> img->y_chroma_shift) * img->stride[PLANE_V];
+                                       + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
             }
             else
             {
-                img->planes[PLANE_V] = data
+                img->planes[VPX_PLANE_V] = data
                                        + (x >> img->x_chroma_shift)
-                                       + (y >> img->y_chroma_shift) * img->stride[PLANE_V];
-                data += (img->h >> img->y_chroma_shift) * img->stride[PLANE_V];
-                img->planes[PLANE_U] = data
+                                       + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
+                data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V];
+                img->planes[VPX_PLANE_U] = data
                                        + (x >> img->x_chroma_shift)
-                                       + (y >> img->y_chroma_shift) * img->stride[PLANE_U];
+                                       + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U];
             }
         }
 
@@ -233,19 +233,19 @@ void vpx_img_flip(vpx_image_t *img)
      * stride parameter will be promoted to unsigned, causing errors when
      * the lhs is a larger type than the rhs.
      */
-    img->planes[PLANE_Y] += (signed)(img->d_h - 1) * img->stride[PLANE_Y];
-    img->stride[PLANE_Y] = -img->stride[PLANE_Y];
+    img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y];
+    img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y];
 
-    img->planes[PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
-                            * img->stride[PLANE_U];
-    img->stride[PLANE_U] = -img->stride[PLANE_U];
+    img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
+                            * img->stride[VPX_PLANE_U];
+    img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U];
 
-    img->planes[PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
-                            * img->stride[PLANE_V];
-    img->stride[PLANE_V] = -img->stride[PLANE_V];
+    img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1)
+                            * img->stride[VPX_PLANE_V];
+    img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V];
 
-    img->planes[PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[PLANE_ALPHA];
-    img->stride[PLANE_ALPHA] = -img->stride[PLANE_ALPHA];
+    img->planes[VPX_PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA];
+    img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA];
 }
 
 void vpx_img_free(vpx_image_t *img)
index 1d86152..7b235a4 100644 (file)
@@ -110,11 +110,18 @@ extern "C" {
         unsigned int  y_chroma_shift;   /**< subsampling order, Y */
 
         /* Image data pointers. */
-#define PLANE_PACKED 0   /**< To be used for all packed formats */
-#define PLANE_Y   0      /**< Y (Luminance) plane */
-#define PLANE_U   1      /**< U (Chroma) plane */
-#define PLANE_V   2      /**< V (Chroma) plane */
-#define PLANE_ALPHA 3    /**< A (Transparancy) plane */
+#define VPX_PLANE_PACKED 0   /**< To be used for all packed formats */
+#define VPX_PLANE_Y      0   /**< Y (Luminance) plane */
+#define VPX_PLANE_U      1   /**< U (Chroma) plane */
+#define VPX_PLANE_V      2   /**< V (Chroma) plane */
+#define VPX_PLANE_ALPHA  3   /**< A (Transparancy) plane */
+#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
+#define PLANE_PACKED     VPX_PLANE_PACKED 
+#define PLANE_Y          VPX_PLANE_Y
+#define PLANE_U          VPX_PLANE_U
+#define PLANE_V          VPX_PLANE_V
+#define PLANE_ALPHA      VPX_PLANE_ALPHA 
+#endif
         unsigned char *planes[4];  /**< pointer to the top left pixel for each plane */
         int      stride[4];  /**< stride between rows for each plane */