diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-26 18:05:08 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-26 18:05:08 +0000 |
commit | 8f472b73a3ece29d11cb4220ab14142cbc62aeb3 (patch) | |
tree | b402cf8e98d622ff0adf4c176b36415753ffcdd1 | |
parent | 3c2126676f227e85629e944a9b39312cb13a8163 (diff) | |
parent | cc42f1d40bcd3af9819af7197454e9329aec930f (diff) | |
download | libvpx-8f472b73a3ece29d11cb4220ab14142cbc62aeb3.tar.gz |
Snap for 4565141 from cc42f1d40bcd3af9819af7197454e9329aec930f to oc-m4-releaseandroid-8.1.0_r23oreo-m4-s1-release
Change-Id: Ia10a9e91736b9aee6db43e8d3e13b57af832f51e
-rw-r--r-- | libvpx/vpx/src/vpx_image.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libvpx/vpx/src/vpx_image.c b/libvpx/vpx/src/vpx_image.c index dba439c10..af7c529a7 100644 --- a/libvpx/vpx/src/vpx_image.c +++ b/libvpx/vpx/src/vpx_image.c @@ -88,11 +88,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, default: ycs = 0; break; } - /* Calculate storage sizes given the chroma subsampling */ - align = (1 << xcs) - 1; - w = (d_w + align) & ~align; - align = (1 << ycs) - 1; - h = (d_h + align) & ~align; + /* Calculate storage sizes. If the buffer was allocated externally, the width + * and height shouldn't be adjusted. */ + w = d_w; + h = d_h; s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; s = (s + stride_align - 1) & ~(stride_align - 1); stride_in_bytes = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s; @@ -111,9 +110,18 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, img->img_data = img_data; if (!img_data) { - const uint64_t alloc_size = (fmt & VPX_IMG_FMT_PLANAR) - ? (uint64_t)h * s * bps / 8 - : (uint64_t)h * s; + uint64_t alloc_size; + /* Calculate storage sizes given the chroma subsampling */ + align = (1 << xcs) - 1; + w = (d_w + align) & ~align; + align = (1 << ycs) - 1; + h = (d_h + align) & ~align; + + s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; + s = (s + stride_align - 1) & ~(stride_align - 1); + stride_in_bytes = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s; + alloc_size = (fmt & VPX_IMG_FMT_PLANAR) ? (uint64_t)h * s * bps / 8 + : (uint64_t)h * s; if (alloc_size != (size_t)alloc_size) goto fail; |