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