Merge "vpx_image: add VPX_ prefix to PLANE_*"

This commit is contained in:
John Koleszar 2010-05-25 13:00:51 -07:00 committed by Code Review
commit 0270a790d7
6 changed files with 67 additions and 60 deletions

View File

@ -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)

View File

@ -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];

View 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;

View 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;

View 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)

View 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 */