BUG=b/64710201
Unified · Split
| @@ -80,7 +80,7 @@ TEST(EncodeAPI, HighBitDepthCapability) { · 79 unmodified lines | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | #if CONFIG_VP8_ENCODER | 82 | #if CONFIG_VP8_ENCODER |
| 83 | TEST(EncodeAPI, DISABLED_ImageSizeSetting) { | 83 | TEST(EncodeAPI, ImageSizeSetting) { |
| 84 | const int width = 711; | 84 | const int width = 711; |
| 85 | const int height = 360; | 85 | const int height = 360; |
| 86 | const int bps = 12; | 86 | const int bps = 12; |
| @@ -88,11 +88,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, · 87 unmodified lines | |||
| 88 | default: ycs = 0; break; | 88 | default: ycs = 0; break; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /* Calculate storage sizes given the chroma subsampling */ | 91 | /* Calculate storage sizes. If the buffer was allocated externally, the width |
| 92 | align = (1 << xcs) - 1; | 92 | * and height shouldn't be adjusted. */ |
| 93 | w = (d_w + align) & ~align; | 93 | w = d_w; |
| 94 | align = (1 << ycs) - 1; | 94 | h = d_h; |
| 95 | h = (d_h + align) & ~align; | ||
| 96 | s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; | 95 | s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; |
| 97 | s = (s + stride_align - 1) & ~(stride_align - 1); | 96 | s = (s + stride_align - 1) & ~(stride_align - 1); |
| 98 | stride_in_bytes = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s; | 97 | 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, · 12 unmodified lines | |||
| 111 | img->img_data = img_data; | 110 | img->img_data = img_data; |
| 112 | 111 | ||
| 113 | if (!img_data) { | 112 | if (!img_data) { |
| 114 | const uint64_t alloc_size = (fmt & VPX_IMG_FMT_PLANAR) | 113 | uint64_t alloc_size; |
| 115 | ? (uint64_t)h * s * bps / 8 | 114 | /* Calculate storage sizes given the chroma subsampling */ |
| 116 | : (uint64_t)h * s; | 115 | align = xcs ? (1 << xcs) - 1 : 1; |
| 116 | w = (d_w + align - 1) & ~(align - 1); | ||
| 117 | align = ycs ? (1 << ycs) - 1 : 1; | ||
| 118 | h = (d_h + align - 1) & ~(align - 1); | ||
| 119 | |||
| 120 | s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; | ||
| 121 | s = (s + stride_align - 1) & ~(stride_align - 1); | ||
| 122 | stride_in_bytes = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s; | ||
| 123 | alloc_size = (fmt & VPX_IMG_FMT_PLANAR) ? (uint64_t)h * s * bps / 8 | ||
| 124 | : (uint64_t)h * s; | ||
| 117 | 125 | ||
| 118 | if (alloc_size != (size_t)alloc_size) goto fail; | 126 | if (alloc_size != (size_t)alloc_size) goto fail; |
| 119 | 127 | ||