Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: source/libvpx/vpx_scale/generic/yv12config.c

Issue 394353005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vpx/vpx_encoder.h ('k') | source/libvpx/vpxdec.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, 135 int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
136 int width, int height, 136 int width, int height,
137 int ss_x, int ss_y, int border, 137 int ss_x, int ss_y, int border,
138 vpx_codec_frame_buffer_t *fb, 138 vpx_codec_frame_buffer_t *fb,
139 vpx_get_frame_buffer_cb_fn_t cb, 139 vpx_get_frame_buffer_cb_fn_t cb,
140 void *cb_priv) { 140 void *cb_priv) {
141 if (ybf) { 141 if (ybf) {
142 const int aligned_width = (width + 7) & ~7; 142 const int aligned_width = (width + 7) & ~7;
143 const int aligned_height = (height + 7) & ~7; 143 const int aligned_height = (height + 7) & ~7;
144 const int y_stride = ((aligned_width + 2 * border) + 31) & ~31; 144 const int y_stride = ((aligned_width + 2 * border) + 31) & ~31;
145 const int yplane_size = (aligned_height + 2 * border) * y_stride; 145 const uint64_t yplane_size = (aligned_height + 2 * border) *
146 (uint64_t)y_stride;
146 const int uv_width = aligned_width >> ss_x; 147 const int uv_width = aligned_width >> ss_x;
147 const int uv_height = aligned_height >> ss_y; 148 const int uv_height = aligned_height >> ss_y;
148 const int uv_stride = y_stride >> ss_x; 149 const int uv_stride = y_stride >> ss_x;
149 const int uv_border_w = border >> ss_x; 150 const int uv_border_w = border >> ss_x;
150 const int uv_border_h = border >> ss_y; 151 const int uv_border_h = border >> ss_y;
151 const int uvplane_size = (uv_height + 2 * uv_border_h) * uv_stride; 152 const uint64_t uvplane_size = (uv_height + 2 * uv_border_h) *
153 (uint64_t)uv_stride;
152 #if CONFIG_ALPHA 154 #if CONFIG_ALPHA
153 const int alpha_width = aligned_width; 155 const int alpha_width = aligned_width;
154 const int alpha_height = aligned_height; 156 const int alpha_height = aligned_height;
155 const int alpha_stride = y_stride; 157 const int alpha_stride = y_stride;
156 const int alpha_border_w = border; 158 const int alpha_border_w = border;
157 const int alpha_border_h = border; 159 const int alpha_border_h = border;
158 const int alpha_plane_size = (alpha_height + 2 * alpha_border_h) * 160 const uint64_t alpha_plane_size = (alpha_height + 2 * alpha_border_h) *
159 alpha_stride; 161 (uint64_t)alpha_stride;
160 const int frame_size = yplane_size + 2 * uvplane_size + 162 const uint64_t frame_size = yplane_size + 2 * uvplane_size +
161 alpha_plane_size; 163 alpha_plane_size;
162 #else 164 #else
163 const int frame_size = yplane_size + 2 * uvplane_size; 165 const uint64_t frame_size = yplane_size + 2 * uvplane_size;
164 #endif 166 #endif
165 if (cb != NULL) { 167 if (cb != NULL) {
166 const int align_addr_extra_size = 31; 168 const int align_addr_extra_size = 31;
167 const size_t external_frame_size = frame_size + align_addr_extra_size; 169 const uint64_t external_frame_size = frame_size + align_addr_extra_size;
168 170
169 assert(fb != NULL); 171 assert(fb != NULL);
170 172
173 if (external_frame_size != (size_t)external_frame_size)
174 return -1;
175
171 // Allocation to hold larger frame, or first allocation. 176 // Allocation to hold larger frame, or first allocation.
172 if (cb(cb_priv, external_frame_size, fb) < 0) 177 if (cb(cb_priv, (size_t)external_frame_size, fb) < 0)
173 return -1; 178 return -1;
174 179
175 if (fb->data == NULL || fb->size < external_frame_size) 180 if (fb->data == NULL || fb->size < external_frame_size)
176 return -1; 181 return -1;
177 182
178 // This memset is needed for fixing valgrind error from C loop filter 183 // This memset is needed for fixing valgrind error from C loop filter
179 // due to access uninitialized memory in frame border. It could be 184 // due to access uninitialized memory in frame border. It could be
180 // removed if border is totally removed. 185 // removed if border is totally removed.
181 vpx_memset(fb->data, 0, fb->size); 186 vpx_memset(fb->data, 0, fb->size);
182 187
183 ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32); 188 ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32);
184 } else if (frame_size > ybf->buffer_alloc_sz) { 189 } else if (frame_size > (size_t)ybf->buffer_alloc_sz) {
185 // Allocation to hold larger frame, or first allocation. 190 // Allocation to hold larger frame, or first allocation.
186 vpx_free(ybf->buffer_alloc); 191 vpx_free(ybf->buffer_alloc);
187 ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, frame_size); 192 ybf->buffer_alloc = NULL;
193
194 if (frame_size != (size_t)frame_size)
195 return -1;
196
197 ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, (size_t)frame_size);
188 if (!ybf->buffer_alloc) 198 if (!ybf->buffer_alloc)
189 return -1; 199 return -1;
190 200
191 ybf->buffer_alloc_sz = frame_size; 201 ybf->buffer_alloc_sz = (int)frame_size;
192 202
193 // This memset is needed for fixing valgrind error from C loop filter 203 // This memset is needed for fixing valgrind error from C loop filter
194 // due to access uninitialized memory in frame border. It could be 204 // due to access uninitialized memory in frame border. It could be
195 // removed if border is totally removed. 205 // removed if border is totally removed.
196 vpx_memset(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz); 206 vpx_memset(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz);
197 } 207 }
198 208
199 /* Only support allocating buffers that have a border that's a multiple 209 /* Only support allocating buffers that have a border that's a multiple
200 * of 32. The border restriction is required to get 16-byte alignment of 210 * of 32. The border restriction is required to get 16-byte alignment of
201 * the start of the chroma rows without introducing an arbitrary gap 211 * the start of the chroma rows without introducing an arbitrary gap
202 * between planes, which would break the semantics of things like 212 * between planes, which would break the semantics of things like
203 * vpx_img_set_rect(). */ 213 * vpx_img_set_rect(). */
204 if (border & 0x1f) 214 if (border & 0x1f)
205 return -3; 215 return -3;
206 216
207 ybf->y_crop_width = width; 217 ybf->y_crop_width = width;
208 ybf->y_crop_height = height; 218 ybf->y_crop_height = height;
209 ybf->y_width = aligned_width; 219 ybf->y_width = aligned_width;
210 ybf->y_height = aligned_height; 220 ybf->y_height = aligned_height;
211 ybf->y_stride = y_stride; 221 ybf->y_stride = y_stride;
212 222
213 ybf->uv_crop_width = (width + ss_x) >> ss_x; 223 ybf->uv_crop_width = (width + ss_x) >> ss_x;
214 ybf->uv_crop_height = (height + ss_y) >> ss_y; 224 ybf->uv_crop_height = (height + ss_y) >> ss_y;
215 ybf->uv_width = uv_width; 225 ybf->uv_width = uv_width;
216 ybf->uv_height = uv_height; 226 ybf->uv_height = uv_height;
217 ybf->uv_stride = uv_stride; 227 ybf->uv_stride = uv_stride;
218 228
219 ybf->border = border; 229 ybf->border = border;
220 ybf->frame_size = frame_size; 230 ybf->frame_size = (int)frame_size;
221 231
222 ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border; 232 ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
223 ybf->u_buffer = ybf->buffer_alloc + yplane_size + 233 ybf->u_buffer = ybf->buffer_alloc + yplane_size +
224 (uv_border_h * uv_stride) + uv_border_w; 234 (uv_border_h * uv_stride) + uv_border_w;
225 ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + 235 ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size +
226 (uv_border_h * uv_stride) + uv_border_w; 236 (uv_border_h * uv_stride) + uv_border_w;
227 237
228 #if CONFIG_ALPHA 238 #if CONFIG_ALPHA
229 ybf->alpha_width = alpha_width; 239 ybf->alpha_width = alpha_width;
230 ybf->alpha_height = alpha_height; 240 ybf->alpha_height = alpha_height;
(...skipping 11 matching lines...) Expand all
242 int width, int height, 252 int width, int height,
243 int ss_x, int ss_y, int border) { 253 int ss_x, int ss_y, int border) {
244 if (ybf) { 254 if (ybf) {
245 vp9_free_frame_buffer(ybf); 255 vp9_free_frame_buffer(ybf);
246 return vp9_realloc_frame_buffer(ybf, width, height, ss_x, ss_y, border, 256 return vp9_realloc_frame_buffer(ybf, width, height, ss_x, ss_y, border,
247 NULL, NULL, NULL); 257 NULL, NULL, NULL);
248 } 258 }
249 return -2; 259 return -2;
250 } 260 }
251 #endif 261 #endif
OLDNEW
« no previous file with comments | « source/libvpx/vpx/vpx_encoder.h ('k') | source/libvpx/vpxdec.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698