From b7a4f8a6db9e83ef23e4d51341db2404d938e57e Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Wed, 15 May 2013 16:29:20 -0700 Subject: [PATCH] Adding alpha plane to YV12_BUFFER_CONFIG structure. Change-Id: I8b2687138df636b2b78c8cc5156e3882b0009de0 --- vp9/vp9_cx_iface.c | 25 ------------------------- vp9/vp9_dx_iface.c | 24 ------------------------ vp9/vp9_iface_common.h | 34 ++++++++++++++++++++++++++++++++-- vpx_scale/generic/yv12config.c | 5 +++++ vpx_scale/yv12config.h | 5 +++++ 5 files changed, 42 insertions(+), 51 deletions(-) diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 45609da..9326165 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -543,31 +543,6 @@ static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) { return VPX_CODEC_OK; } -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[VPX_PLANE_Y]; - yv12->u_buffer = img->planes[VPX_PLANE_U]; - yv12->v_buffer = img->planes[VPX_PLANE_V]; - - yv12->y_crop_width = img->d_w; - yv12->y_crop_height = img->d_h; - yv12->y_width = img->d_w; - yv12->y_height = img->d_h; - - yv12->uv_width = img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2 - : yv12->y_width; - yv12->uv_height = img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 - : yv12->y_height; - - yv12->y_stride = img->stride[VPX_PLANE_Y]; - yv12->uv_stride = img->stride[VPX_PLANE_U]; - - yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2; - yv12->clrtype = REG_YUV; - return res; -} - static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, unsigned long duration, unsigned long deadline) { diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 85022c9..811cea7 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -578,30 +578,6 @@ static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx, return res; } -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[VPX_PLANE_Y]; - yv12->u_buffer = img->planes[VPX_PLANE_U]; - yv12->v_buffer = img->planes[VPX_PLANE_V]; - - yv12->y_crop_width = img->d_w; - yv12->y_crop_height = img->d_h; - 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[VPX_PLANE_Y]; - yv12->uv_stride = img->stride[VPX_PLANE_U]; - - 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; -} - static vpx_codec_err_t vp9_set_reference(vpx_codec_alg_priv_t *ctx, int ctr_id, diff --git a/vp9/vp9_iface_common.h b/vp9/vp9_iface_common.h index 96de5f5..84b4d39 100644 --- a/vp9/vp9_iface_common.h +++ b/vp9/vp9_iface_common.h @@ -37,11 +37,11 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12, img->planes[VPX_PLANE_Y] = yv12->y_buffer; img->planes[VPX_PLANE_U] = yv12->u_buffer; img->planes[VPX_PLANE_V] = yv12->v_buffer; - img->planes[VPX_PLANE_ALPHA] = NULL; + img->planes[VPX_PLANE_ALPHA] = yv12->alpha_buffer; img->stride[VPX_PLANE_Y] = yv12->y_stride; img->stride[VPX_PLANE_U] = yv12->uv_stride; img->stride[VPX_PLANE_V] = yv12->uv_stride; - img->stride[VPX_PLANE_ALPHA] = yv12->y_stride; + img->stride[VPX_PLANE_ALPHA] = yv12->alpha_stride; img->bps = bps; img->user_priv = user_priv; img->img_data = yv12->buffer_alloc; @@ -49,4 +49,34 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12, img->self_allocd = 0; } +static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, + YV12_BUFFER_CONFIG *yv12) { + 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->alpha_buffer = img->planes[VPX_PLANE_ALPHA]; + + yv12->y_crop_width = img->d_w; + yv12->y_crop_height = img->d_h; + yv12->y_width = img->d_w; + yv12->y_height = img->d_h; + + yv12->uv_width = img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2 + : yv12->y_width; + yv12->uv_height = img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 + : yv12->y_height; + + yv12->alpha_width = yv12->alpha_buffer ? img->d_w : 0; + yv12->alpha_height = yv12->alpha_buffer ? img->d_h : 0; + + yv12->y_stride = img->stride[VPX_PLANE_Y]; + yv12->uv_stride = img->stride[VPX_PLANE_U]; + yv12->alpha_stride = yv12->alpha_buffer ? img->stride[VPX_PLANE_ALPHA] : 0; + + yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2; + yv12->clrtype = REG_YUV; + + return VPX_CODEC_OK; +} + #endif // VP9_VP9_IFACE_COMMON_H_ diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index cd66f00..99e3543 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -76,12 +76,17 @@ int vp8_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, ybf->uv_height = uv_height; ybf->uv_stride = uv_stride; + ybf->alpha_width = 0; + ybf->alpha_height = 0; + ybf->alpha_stride = 0; + ybf->border = border; ybf->frame_size = frame_size; ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border; ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2 * uv_stride) + border / 2; ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2 * uv_stride) + border / 2; + ybf->alpha_buffer = NULL; ybf->corrupted = 0; /* assume not currupted by errors */ return 0; diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h index 85396c0..7b8bd85 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -52,9 +52,14 @@ extern "C" { int uv_stride; /* int uvinternal_width; */ + int alpha_width; + int alpha_height; + int alpha_stride; + uint8_t *y_buffer; uint8_t *u_buffer; uint8_t *v_buffer; + uint8_t *alpha_buffer; uint8_t *buffer_alloc; int buffer_alloc_sz; -- 2.7.4