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

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

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 9 years, 4 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
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
11 11
12 #include "vpx_scale/yv12config.h" 12 #include "vpx_scale/yv12config.h"
13 #include "vpx_mem/vpx_mem.h" 13 #include "vpx_mem/vpx_mem.h"
14 14
15 /**************************************************************************** 15 /****************************************************************************
16 * Exports 16 * Exports
17 ****************************************************************************/ 17 ****************************************************************************/
18 18
19 /**************************************************************************** 19 /****************************************************************************
20 * 20 *
21 ****************************************************************************/ 21 ****************************************************************************/
22 int 22 int
23 vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf) 23 vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
24 { 24 {
25 if (ybf) 25 if (ybf)
26 { 26 {
27 duck_free(ybf->buffer_alloc); 27 vpx_free(ybf->buffer_alloc);
28 28
29 ybf->buffer_alloc = 0; 29 /* buffer_alloc isn't accessed by most functions. Rather y_buffer,
30 u_buffer and v_buffer point to buffer_alloc and are used. Clear out
31 all of this so that a freed pointer isn't inadvertently used */
32 vpx_memset (ybf, 0, sizeof (YV12_BUFFER_CONFIG));
30 } 33 }
31 else 34 else
32 { 35 {
33 return -1; 36 return -1;
34 } 37 }
35 38
36 return 0; 39 return 0;
37 } 40 }
38 41
39 /**************************************************************************** 42 /****************************************************************************
40 * 43 *
41 ****************************************************************************/ 44 ****************************************************************************/
42 int 45 int
43 vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border) 46 vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border)
44 { 47 {
45 /*NOTE:*/ 48 /*NOTE:*/
46 49
47 int yplane_size = (height + 2 * border) * (width + 2 * border);
48 int uvplane_size = ((1 + height) / 2 + border) * ((1 + width) / 2 + border);
49
50 if (ybf) 50 if (ybf)
51 { 51 {
52 int y_stride = ((width + 2 * border) + 31) & ~31;
53 int yplane_size = (height + 2 * border) * y_stride;
54 int uv_width = width >> 1;
55 int uv_height = height >> 1;
56 /** There is currently a bunch of code which assumes
57 * uv_stride == y_stride/2, so enforce this here. */
58 int uv_stride = y_stride >> 1;
59 int uvplane_size = (uv_height + border) * uv_stride;
60
52 vp8_yv12_de_alloc_frame_buffer(ybf); 61 vp8_yv12_de_alloc_frame_buffer(ybf);
53 62
63 /** Only support allocating buffers that have a height and width that
64 * are multiples of 16, and a border that's a multiple of 32.
65 * The border restriction is required to get 16-byte alignment of the
66 * start of the chroma rows without intoducing an arbitrary gap
67 * between planes, which would break the semantics of things like
68 * vpx_img_set_rect(). */
69 if ((width & 0xf) | (height & 0xf) | (border & 0x1f))
70 return -3;
71
54 ybf->y_width = width; 72 ybf->y_width = width;
55 ybf->y_height = height; 73 ybf->y_height = height;
56 ybf->y_stride = width + 2 * border; 74 ybf->y_stride = y_stride;
57 75
58 ybf->uv_width = (1 + width) / 2; 76 ybf->uv_width = uv_width;
59 ybf->uv_height = (1 + height) / 2; 77 ybf->uv_height = uv_height;
60 ybf->uv_stride = ybf->uv_width + border; 78 ybf->uv_stride = uv_stride;
61 79
62 ybf->border = border; 80 ybf->border = border;
63 ybf->frame_size = yplane_size + 2 * uvplane_size; 81 ybf->frame_size = yplane_size + 2 * uvplane_size;
64 82
65 /* Added 2 extra lines to framebuffer so that copy12x12 doesn't fail 83 ybf->buffer_alloc = (unsigned char *) vpx_memalign(32, ybf->frame_size);
66 * when we have a large motion vector in V on the last v block.
67 * Note : We never use these pixels anyway so this doesn't hurt.
68 */
69 ybf->buffer_alloc = (unsigned char *) duck_memalign(32, ybf->frame_size + (ybf->y_stride * 2) + 32, 0);
70 84
71 if (ybf->buffer_alloc == NULL) 85 if (ybf->buffer_alloc == NULL)
72 return -1; 86 return -1;
73 87
74 ybf->y_buffer = ybf->buffer_alloc + (border * ybf->y_stride) + border; 88 ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
75 89 ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2 * uv_stri de) + border / 2;
76 if (yplane_size & 0xf) 90 ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2 * uv_stride) + border / 2;
77 yplane_size += 16 - (yplane_size & 0xf);
78
79 ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2 * ybf->uv _stride) + border / 2;
80 ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2 * ybf->uv_stride) + border / 2;
81 91
82 ybf->corrupted = 0; /* assume not currupted by errors */ 92 ybf->corrupted = 0; /* assume not currupted by errors */
83 } 93 }
84 else 94 else
85 { 95 {
86 return -2; 96 return -2;
87 } 97 }
88 98
89 return 0; 99 return 0;
90 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698