Merge "Adding alpha plane to YV12_BUFFER_CONFIG structure." into experimental

This commit is contained in:
Dmitry Kovalev 2013-05-15 16:49:53 -07:00 committed by Gerrit Code Review
commit 3ba985779c
5 changed files with 42 additions and 51 deletions

View File

@ -543,31 +543,6 @@ static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) {
return VPX_CODEC_OK; 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, static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
unsigned long duration, unsigned long duration,
unsigned long deadline) { unsigned long deadline) {

View File

@ -578,30 +578,6 @@ static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx,
return res; 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, static vpx_codec_err_t vp9_set_reference(vpx_codec_alg_priv_t *ctx,
int ctr_id, int ctr_id,

View File

@ -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_Y] = yv12->y_buffer;
img->planes[VPX_PLANE_U] = yv12->u_buffer; img->planes[VPX_PLANE_U] = yv12->u_buffer;
img->planes[VPX_PLANE_V] = yv12->v_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_Y] = yv12->y_stride;
img->stride[VPX_PLANE_U] = yv12->uv_stride; img->stride[VPX_PLANE_U] = yv12->uv_stride;
img->stride[VPX_PLANE_V] = 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->bps = bps;
img->user_priv = user_priv; img->user_priv = user_priv;
img->img_data = yv12->buffer_alloc; 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; 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_ #endif // VP9_VP9_IFACE_COMMON_H_

View File

@ -76,12 +76,17 @@ int vp8_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
ybf->uv_height = uv_height; ybf->uv_height = uv_height;
ybf->uv_stride = uv_stride; ybf->uv_stride = uv_stride;
ybf->alpha_width = 0;
ybf->alpha_height = 0;
ybf->alpha_stride = 0;
ybf->border = border; ybf->border = border;
ybf->frame_size = frame_size; ybf->frame_size = frame_size;
ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border; 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->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->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 */ ybf->corrupted = 0; /* assume not currupted by errors */
return 0; return 0;

View File

@ -52,9 +52,14 @@ extern "C" {
int uv_stride; int uv_stride;
/* int uvinternal_width; */ /* int uvinternal_width; */
int alpha_width;
int alpha_height;
int alpha_stride;
uint8_t *y_buffer; uint8_t *y_buffer;
uint8_t *u_buffer; uint8_t *u_buffer;
uint8_t *v_buffer; uint8_t *v_buffer;
uint8_t *alpha_buffer;
uint8_t *buffer_alloc; uint8_t *buffer_alloc;
int buffer_alloc_sz; int buffer_alloc_sz;