History

Fix image width alignment. Enable ImageSizeSetting test.

BUG=b/64710201

Jerome Jiang committed 9 years ago

Commit 5a40c8f1 parent d203a912 files · +17 −9Browse files

Unified · Split

2 files
  1. test/encode_api_test.cc +1 −1
  2. vpx/src/vpx_image.c +16 −8
test/encode_api_test.cc+1−1
@@ -80,7 +80,7 @@ TEST(EncodeAPI, HighBitDepthCapability) { · 79 unmodified lines
8080 }
8181
8282 #if CONFIG_VP8_ENCODER
83−TEST(EncodeAPI, DISABLED_ImageSizeSetting) {
83+TEST(EncodeAPI, ImageSizeSetting) {
8484 const int width = 711;
8585 const int height = 360;
8686 const int bps = 12;
vpx/src/vpx_image.c+16−8
@@ -88,11 +88,10 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, · 87 unmodified lines
8888 default: ycs = 0; break;
8989 }
9090
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;
9695 s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8;
9796 s = (s + stride_align - 1) & ~(stride_align - 1);
9897 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
111110 img->img_data = img_data;
112111
113112 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;
117125
118126 if (alloc_size != (size_t)alloc_size) goto fail;
119127

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t