Commit 6cd4a10e authored by James Zern's avatar James Zern Committed by John Koleszar
Browse files

Put img_fmt in the vpx namespace

Avoid an potential name clashes and match other external types.
s/IMG_FMT/VPX_$&/g
s/img_fmt/vpx_$&/g

Change-Id: Ia7ad5bbb6424416b37e71e5f5eb1eca31c3c707f
parent 1df0314e
...@@ -127,7 +127,7 @@ int main(int argc, char **argv) { ...@@ -127,7 +127,7 @@ int main(int argc, char **argv) {
height = strtol(argv[2], NULL, 0); height = strtol(argv[2], NULL, 0);
if(width < 16 || width%2 || height <16 || height%2) if(width < 16 || width%2 || height <16 || height%2)
die("Invalid resolution: %ldx%ld", width, height); die("Invalid resolution: %ldx%ld", width, height);
if(!vpx_img_alloc(&raw, IMG_FMT_YV12, width, height, 1)) if(!vpx_img_alloc(&raw, VPX_IMG_FMT_YV12, width, height, 1))
die("Faile to allocate image", width, height); die("Faile to allocate image", width, height);
if(!(outfile = fopen(argv[4], "wb"))) if(!(outfile = fopen(argv[4], "wb")))
die("Failed to open %s for writing", argv[4]); die("Failed to open %s for writing", argv[4]);
......
...@@ -247,10 +247,10 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int is_ivf) ...@@ -247,10 +247,10 @@ static int read_frame(FILE *f, vpx_image_t *img, unsigned int is_ivf)
switch (plane) switch (plane)
{ {
case 1: case 1:
ptr = img->planes[img->fmt==IMG_FMT_YV12? PLANE_V : PLANE_U]; ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12? PLANE_V : PLANE_U];
break; break;
case 2: case 2:
ptr = img->planes[img->fmt==IMG_FMT_YV12?PLANE_U : PLANE_V]; ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12?PLANE_U : PLANE_V];
break; break;
default: default:
ptr = img->planes[plane]; ptr = img->planes[plane];
...@@ -869,7 +869,7 @@ int main(int argc, const char **argv_) ...@@ -869,7 +869,7 @@ int main(int argc, const char **argv_)
SHOW(kf_max_dist); SHOW(kf_max_dist);
} }
vpx_img_alloc(&raw, arg_use_i420 ? IMG_FMT_I420 : IMG_FMT_YV12, vpx_img_alloc(&raw, arg_use_i420 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_YV12,
cfg.g_w, cfg.g_h, 1); cfg.g_w, cfg.g_h, 1);
// This was added so that ivfenc will create monotically increasing // This was added so that ivfenc will create monotically increasing
......
...@@ -211,10 +211,10 @@ static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx, ...@@ -211,10 +211,10 @@ static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx,
{ {
switch (img->fmt) switch (img->fmt)
{ {
case IMG_FMT_YV12: case VPX_IMG_FMT_YV12:
case IMG_FMT_I420: case VPX_IMG_FMT_I420:
case IMG_FMT_VPXI420: case VPX_IMG_FMT_VPXI420:
case IMG_FMT_VPXYV12: case VPX_IMG_FMT_VPXYV12:
break; break;
default: default:
ERROR("Invalid image format. Only YV12 and I420 images are supported"); ERROR("Invalid image format. Only YV12 and I420 images are supported");
...@@ -549,7 +549,7 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, ...@@ -549,7 +549,7 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
yv12->uv_stride = img->stride[PLANE_U]; yv12->uv_stride = img->stride[PLANE_U];
yv12->border = (img->stride[PLANE_Y] - img->w) / 2; yv12->border = (img->stride[PLANE_Y] - img->w) / 2;
yv12->clrtype = (img->fmt == IMG_FMT_VPXI420 || img->fmt == IMG_FMT_VPXYV12); //REG_YUV = 0 yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12); //REG_YUV = 0
return res; return res;
} }
...@@ -846,7 +846,7 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) ...@@ -846,7 +846,7 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
{ {
/* /*
vpx_img_wrap(&ctx->preview_img, IMG_FMT_YV12, vpx_img_wrap(&ctx->preview_img, VPX_IMG_FMT_YV12,
sd.y_width + 2*VP8BORDERINPIXELS, sd.y_width + 2*VP8BORDERINPIXELS,
sd.y_height + 2*VP8BORDERINPIXELS, sd.y_height + 2*VP8BORDERINPIXELS,
1, 1,
...@@ -862,9 +862,9 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) ...@@ -862,9 +862,9 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
ctx->preview_img.planes[PLANE_V] = sd.v_buffer; ctx->preview_img.planes[PLANE_V] = sd.v_buffer;
if (sd.clrtype == REG_YUV) if (sd.clrtype == REG_YUV)
ctx->preview_img.fmt = IMG_FMT_I420; ctx->preview_img.fmt = VPX_IMG_FMT_I420;
else else
ctx->preview_img.fmt = IMG_FMT_VPXI420; ctx->preview_img.fmt = VPX_IMG_FMT_VPXI420;
ctx->preview_img.x_chroma_shift = 1; ctx->preview_img.x_chroma_shift = 1;
ctx->preview_img.y_chroma_shift = 1; ctx->preview_img.y_chroma_shift = 1;
......
...@@ -434,7 +434,7 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, ...@@ -434,7 +434,7 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
unsigned int a_w = (sd.y_width + 15) & ~15; unsigned int a_w = (sd.y_width + 15) & ~15;
unsigned int a_h = (sd.y_height + 15) & ~15; unsigned int a_h = (sd.y_height + 15) & ~15;
vpx_img_wrap(&ctx->img, IMG_FMT_I420, vpx_img_wrap(&ctx->img, VPX_IMG_FMT_I420,
a_w + 2 * VP8BORDERINPIXELS, a_w + 2 * VP8BORDERINPIXELS,
a_h + 2 * VP8BORDERINPIXELS, a_h + 2 * VP8BORDERINPIXELS,
1, 1,
...@@ -570,7 +570,7 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, ...@@ -570,7 +570,7 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
yv12->uv_stride = img->stride[PLANE_U]; yv12->uv_stride = img->stride[PLANE_U];
yv12->border = (img->stride[PLANE_Y] - img->d_w) / 2; yv12->border = (img->stride[PLANE_Y] - img->d_w) / 2;
yv12->clrtype = (img->fmt == IMG_FMT_VPXI420 || img->fmt == IMG_FMT_VPXYV12); yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12);
return res; return res;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "vpx_codec/vpx_image.h" #include "vpx_codec/vpx_image.h"
static vpx_image_t *img_alloc_helper(vpx_image_t *img, static vpx_image_t *img_alloc_helper(vpx_image_t *img,
img_fmt_t fmt, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_w,
unsigned int d_h, unsigned int d_h,
unsigned int stride_align, unsigned int stride_align,
...@@ -34,29 +34,29 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, ...@@ -34,29 +34,29 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
/* Get sample size for this format */ /* Get sample size for this format */
switch (fmt) switch (fmt)
{ {
case IMG_FMT_RGB32: case VPX_IMG_FMT_RGB32:
case IMG_FMT_RGB32_LE: case VPX_IMG_FMT_RGB32_LE:
case IMG_FMT_ARGB: case VPX_IMG_FMT_ARGB:
case IMG_FMT_ARGB_LE: case VPX_IMG_FMT_ARGB_LE:
bps = 32; bps = 32;
break; break;
case IMG_FMT_RGB24: case VPX_IMG_FMT_RGB24:
case IMG_FMT_BGR24: case VPX_IMG_FMT_BGR24:
bps = 24; bps = 24;
break; break;
case IMG_FMT_RGB565: case VPX_IMG_FMT_RGB565:
case IMG_FMT_RGB565_LE: case VPX_IMG_FMT_RGB565_LE:
case IMG_FMT_RGB555: case VPX_IMG_FMT_RGB555:
case IMG_FMT_RGB555_LE: case VPX_IMG_FMT_RGB555_LE:
case IMG_FMT_UYVY: case VPX_IMG_FMT_UYVY:
case IMG_FMT_YUY2: case VPX_IMG_FMT_YUY2:
case IMG_FMT_YVYU: case VPX_IMG_FMT_YVYU:
bps = 16; bps = 16;
break; break;
case IMG_FMT_I420: case VPX_IMG_FMT_I420:
case IMG_FMT_YV12: case VPX_IMG_FMT_YV12:
case IMG_FMT_VPXI420: case VPX_IMG_FMT_VPXI420:
case IMG_FMT_VPXYV12: case VPX_IMG_FMT_VPXYV12:
bps = 12; bps = 12;
break; break;
default: default:
...@@ -67,10 +67,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, ...@@ -67,10 +67,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
/* Get chroma shift values for this format */ /* Get chroma shift values for this format */
switch (fmt) switch (fmt)
{ {
case IMG_FMT_I420: case VPX_IMG_FMT_I420:
case IMG_FMT_YV12: case VPX_IMG_FMT_YV12:
case IMG_FMT_VPXI420: case VPX_IMG_FMT_VPXI420:
case IMG_FMT_VPXYV12: case VPX_IMG_FMT_VPXYV12:
xcs = 1; xcs = 1;
break; break;
default: default:
...@@ -80,10 +80,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, ...@@ -80,10 +80,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
switch (fmt) switch (fmt)
{ {
case IMG_FMT_I420: case VPX_IMG_FMT_I420:
case IMG_FMT_YV12: case VPX_IMG_FMT_YV12:
case IMG_FMT_VPXI420: case VPX_IMG_FMT_VPXI420:
case IMG_FMT_VPXYV12: case VPX_IMG_FMT_VPXYV12:
ycs = 1; ycs = 1;
break; break;
default: default:
...@@ -96,7 +96,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, ...@@ -96,7 +96,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
w = (d_w + align) & ~align; w = (d_w + align) & ~align;
align = (1 << ycs) - 1; align = (1 << ycs) - 1;
h = (d_h + align) & ~align; h = (d_h + align) & ~align;
s = (fmt & IMG_FMT_PLANAR) ? w : bps * w / 8; s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8;
s = (s + stride_align - 1) & ~(stride_align - 1); s = (s + stride_align - 1) & ~(stride_align - 1);
/* Allocate the new image */ /* Allocate the new image */
...@@ -118,7 +118,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, ...@@ -118,7 +118,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
if (!img_data) if (!img_data)
{ {
img->img_data = malloc((fmt & IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s); img->img_data = malloc((fmt & VPX_IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s);
img->img_data_owner = 1; img->img_data_owner = 1;
} }
...@@ -146,7 +146,7 @@ fail: ...@@ -146,7 +146,7 @@ fail:
} }
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_image_t *vpx_img_alloc(vpx_image_t *img,
img_fmt_t fmt, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_w,
unsigned int d_h, unsigned int d_h,
unsigned int stride_align) unsigned int stride_align)
...@@ -155,7 +155,7 @@ vpx_image_t *vpx_img_alloc(vpx_image_t *img, ...@@ -155,7 +155,7 @@ vpx_image_t *vpx_img_alloc(vpx_image_t *img,
} }
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_image_t *vpx_img_wrap(vpx_image_t *img,
img_fmt_t fmt, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_w,
unsigned int d_h, unsigned int d_h,
unsigned int stride_align, unsigned int stride_align,
...@@ -178,7 +178,7 @@ int vpx_img_set_rect(vpx_image_t *img, ...@@ -178,7 +178,7 @@ int vpx_img_set_rect(vpx_image_t *img,
img->d_h = h; img->d_h = h;
/* Calculate plane pointers */ /* Calculate plane pointers */
if (!(img->fmt & IMG_FMT_PLANAR)) if (!(img->fmt & VPX_IMG_FMT_PLANAR))
{ {
img->planes[PLANE_PACKED] = img->planes[PLANE_PACKED] =
img->img_data + x * img->bps / 8 + y * img->stride[PLANE_PACKED]; img->img_data + x * img->bps / 8 + y * img->stride[PLANE_PACKED];
...@@ -187,7 +187,7 @@ int vpx_img_set_rect(vpx_image_t *img, ...@@ -187,7 +187,7 @@ int vpx_img_set_rect(vpx_image_t *img,
{ {
data = img->img_data; data = img->img_data;
if (img->fmt & IMG_FMT_HAS_ALPHA) if (img->fmt & VPX_IMG_FMT_HAS_ALPHA)
{ {
img->planes[PLANE_ALPHA] = img->planes[PLANE_ALPHA] =
data + x + y * img->stride[PLANE_ALPHA]; data + x + y * img->stride[PLANE_ALPHA];
...@@ -197,7 +197,7 @@ int vpx_img_set_rect(vpx_image_t *img, ...@@ -197,7 +197,7 @@ int vpx_img_set_rect(vpx_image_t *img,
img->planes[PLANE_Y] = data + x + y * img->stride[PLANE_Y]; img->planes[PLANE_Y] = data + x + y * img->stride[PLANE_Y];
data += img->h * img->stride[PLANE_Y]; data += img->h * img->stride[PLANE_Y];
if (!(img->fmt & IMG_FMT_UV_FLIP)) if (!(img->fmt & VPX_IMG_FMT_UV_FLIP))
{ {
img->planes[PLANE_U] = data img->planes[PLANE_U] = data
+ (x >> img->x_chroma_shift) + (x >> img->x_chroma_shift)
......
...@@ -30,39 +30,39 @@ extern "C" { ...@@ -30,39 +30,39 @@ extern "C" {
#define VPX_IMAGE_ABI_VERSION (1) /**<\hideinitializer*/ #define VPX_IMAGE_ABI_VERSION (1) /**<\hideinitializer*/
#define IMG_FMT_PLANAR 0x100 /**< Image is a planar format */ #define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format */
#define IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U plane in memory */ #define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U plane in memory */
#define IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel componnent */ #define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel componnent */
/*!\brief List of supported image formats */ /*!\brief List of supported image formats */
typedef enum img_fmt { typedef enum vpx_img_fmt {
IMG_FMT_NONE, VPX_IMG_FMT_NONE,
IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */ VPX_IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */
IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */ VPX_IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */
IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */ VPX_IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */
IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */ VPX_IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */
IMG_FMT_UYVY, /**< UYVY packed YUV */ VPX_IMG_FMT_UYVY, /**< UYVY packed YUV */
IMG_FMT_YUY2, /**< YUYV packed YUV */ VPX_IMG_FMT_YUY2, /**< YUYV packed YUV */
IMG_FMT_YVYU, /**< YVYU packed YUV */ VPX_IMG_FMT_YVYU, /**< YVYU packed YUV */
IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */ VPX_IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */
IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */ VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */ VPX_IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */
IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */ VPX_IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */
IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */ VPX_IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */
IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */ VPX_IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
IMG_FMT_YV12 = IMG_FMT_PLANAR | IMG_FMT_UV_FLIP | 1, /**< planar YVU */ VPX_IMG_FMT_YV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
IMG_FMT_I420 = IMG_FMT_PLANAR | 2, VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
IMG_FMT_VPXYV12 = IMG_FMT_PLANAR | IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */ VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
IMG_FMT_VPXI420 = IMG_FMT_PLANAR | 4, /** < planar 4:2:0 format with vpx color space */ VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4, /** < planar 4:2:0 format with vpx color space */
} }
img_fmt_t; /**< alias for enum img_fmt */ vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
/**\brief Image Descriptor */ /**\brief Image Descriptor */
typedef struct vpx_image typedef struct vpx_image
{ {
img_fmt_t fmt; /**< Image Format */ vpx_img_fmt_t fmt; /**< Image Format */
/* Image storage dimensions */ /* Image storage dimensions */
unsigned int w; /**< Stored image width */ unsigned int w; /**< Stored image width */
...@@ -126,7 +126,7 @@ extern "C" { ...@@ -126,7 +126,7 @@ extern "C" {
* returned. * returned.
*/ */
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_image_t *vpx_img_alloc(vpx_image_t *img,
img_fmt_t fmt, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_w,
unsigned int d_h, unsigned int d_h,
unsigned int align); unsigned int align);
...@@ -151,7 +151,7 @@ extern "C" { ...@@ -151,7 +151,7 @@ extern "C" {
* returned. * returned.
*/ */
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_image_t *vpx_img_wrap(vpx_image_t *img,
img_fmt_t fmt, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_w,
unsigned int d_h, unsigned int d_h,
unsigned int align, unsigned int align,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment