diff options
author | Timothy B. Terriberry <tterribe@xiph.org> | 2011-07-20 10:20:31 -0700 |
---|---|---|
committer | Timothy B. Terriberry <tterribe@xiph.org> | 2011-07-20 10:20:31 -0700 |
commit | 7d1b37cdac8ae096e1d33aa7adb2834784cc897e (patch) | |
tree | ea11c18f7f0ee11e2a2b8c5a7009b2b27f7a8059 /vp8/vp8_dx_iface.c | |
parent | b2d9700f5313770957878fa36f9971c367f479df (diff) | |
download | libvpx-7d1b37cdac8ae096e1d33aa7adb2834784cc897e.tar libvpx-7d1b37cdac8ae096e1d33aa7adb2834784cc897e.tar.gz libvpx-7d1b37cdac8ae096e1d33aa7adb2834784cc897e.tar.bz2 libvpx-7d1b37cdac8ae096e1d33aa7adb2834784cc897e.zip |
Increase chrow row alignment to 16 bytes.
This is done by expanding luma row to 32-byte alignment, since
there is currently a bunch of code that assumes that
uv_stride == y_stride/2 (see, for example, vp8/common/postproc.c,
common/reconinter.c, common/arm/neon/recon16x16mb_neon.asm,
encoder/temporal_filter.c, and possibly others; I haven't done a
full audit).
It also uses replaces the hardcoded border of 16 in a number of
encoder buffers with VP8BORDERINPIXELS (currently 32), as the
chroma rows start at an offset of border/2.
Together, these two changes have the nice advantage that simply
dumping the frame memory as a contiguous blob produces a valid,
if padded, image.
Change-Id: Iaf5ea722ae5c82d5daa50f6e2dade9de753f1003
Diffstat (limited to 'vp8/vp8_dx_iface.c')
-rw-r--r-- | vp8/vp8_dx_iface.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index 58dc486de..13a072bff 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -301,6 +301,36 @@ update_error_state(vpx_codec_alg_priv_t *ctx, return res; } +static void yuvconfig2image(vpx_image_t *img, + const YV12_BUFFER_CONFIG *yv12, + void *user_priv) +{ + /** vpx_img_wrap() doesn't allow specifying independent strides for + * the Y, U, and V planes, nor other alignment adjustments that + * might be representable by a YV12_BUFFER_CONFIG, so we just + * initialize all the fields.*/ + img->fmt = yv12->clrtype == REG_YUV ? + VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420; + img->w = yv12->y_stride; + img->h = (yv12->y_height + 2 * VP8BORDERINPIXELS + 15) & ~15; + img->d_w = yv12->y_width; + img->d_h = yv12->y_height; + img->x_chroma_shift = 1; + img->y_chroma_shift = 1; + 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->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->bps = 12; + img->user_priv = user_priv; + img->img_data = yv12->buffer_alloc; + img->img_data_owner = 0; + img->self_allocd = 0; +} static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, const uint8_t *data, @@ -429,21 +459,8 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, &flags)) { - /* Align width/height */ - unsigned int a_w = (sd.y_width + 15) & ~15; - unsigned int a_h = (sd.y_height + 15) & ~15; - - vpx_img_wrap(&ctx->img, VPX_IMG_FMT_I420, - a_w + 2 * VP8BORDERINPIXELS, - a_h + 2 * VP8BORDERINPIXELS, - 1, - sd.buffer_alloc); - vpx_img_set_rect(&ctx->img, - VP8BORDERINPIXELS, VP8BORDERINPIXELS, - sd.y_width, sd.y_height); - ctx->img.user_priv = user_priv; + yuvconfig2image(&ctx->img, &sd, user_priv); ctx->img_avail = 1; - } } |