diff options
Diffstat (limited to 'media/libaom/src/av1/av1_iface_common.h')
-rw-r--r-- | media/libaom/src/av1/av1_iface_common.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/media/libaom/src/av1/av1_iface_common.h b/media/libaom/src/av1/av1_iface_common.h index 4a7af580b8..9b5ffcba45 100644 --- a/media/libaom/src/av1/av1_iface_common.h +++ b/media/libaom/src/av1/av1_iface_common.h @@ -11,6 +11,8 @@ #ifndef AOM_AV1_AV1_IFACE_COMMON_H_ #define AOM_AV1_AV1_IFACE_COMMON_H_ +#include <assert.h> + #include "aom_ports/mem.h" #include "aom_scale/yv12config.h" @@ -52,12 +54,11 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12, img->planes[AOM_PLANE_Y] = yv12->y_buffer; img->planes[AOM_PLANE_U] = yv12->u_buffer; img->planes[AOM_PLANE_V] = yv12->v_buffer; - img->planes[AOM_PLANE_ALPHA] = NULL; img->stride[AOM_PLANE_Y] = yv12->y_stride; img->stride[AOM_PLANE_U] = yv12->uv_stride; img->stride[AOM_PLANE_V] = yv12->uv_stride; - img->stride[AOM_PLANE_ALPHA] = yv12->y_stride; if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) { + bps *= 2; // aom_image_t uses byte strides and a pointer to the first byte // of the image. img->fmt = (aom_img_fmt_t)(img->fmt | AOM_IMG_FMT_HIGHBITDEPTH); @@ -65,17 +66,18 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12, img->planes[AOM_PLANE_Y] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->y_buffer); img->planes[AOM_PLANE_U] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->u_buffer); img->planes[AOM_PLANE_V] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->v_buffer); - img->planes[AOM_PLANE_ALPHA] = NULL; img->stride[AOM_PLANE_Y] = 2 * yv12->y_stride; img->stride[AOM_PLANE_U] = 2 * yv12->uv_stride; img->stride[AOM_PLANE_V] = 2 * yv12->uv_stride; - img->stride[AOM_PLANE_ALPHA] = 2 * yv12->y_stride; } img->bps = bps; img->user_priv = user_priv; img->img_data = yv12->buffer_alloc; img->img_data_owner = 0; img->self_allocd = 0; + img->sz = yv12->frame_size; + assert(!yv12->metadata); + img->metadata = NULL; } static aom_codec_err_t image2yuvconfig(const aom_image_t *img, @@ -127,9 +129,15 @@ static aom_codec_err_t image2yuvconfig(const aom_image_t *img, } else { yv12->flags = 0; } - yv12->border = (yv12->y_stride - img->w) / 2; + + // Note(yunqing): if img is allocated the same as the frame buffer, y_stride + // is 32-byte aligned. Also, handle the cases while allocating img without a + // border or stride_align is less than 32. + int border = (yv12->y_stride - (int)((img->w + 31) & ~31)) / 2; + yv12->border = (border < 0) ? 0 : border; yv12->subsampling_x = img->x_chroma_shift; yv12->subsampling_y = img->y_chroma_shift; + yv12->metadata = img->metadata; return AOM_CODEC_OK; } |