2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 #include "vpx_scale/yv12config.h"
13 #include "vpx_mem/vpx_mem.h"
14 #include "vpx_scale/vpxscale.h"
16 /****************************************************************************
18 ****************************************************************************/
20 /****************************************************************************
22 ****************************************************************************/
24 vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG
*ybf
)
27 unsigned char *src_ptr1
, *src_ptr2
;
28 unsigned char *dest_ptr1
, *dest_ptr2
;
39 plane_stride
= ybf
->y_stride
;
40 plane_height
= ybf
->y_height
;
41 plane_width
= ybf
->y_width
;
43 /* copy the left and right most columns out */
44 src_ptr1
= ybf
->y_buffer
;
45 src_ptr2
= src_ptr1
+ plane_width
- 1;
46 dest_ptr1
= src_ptr1
- Border
;
47 dest_ptr2
= src_ptr2
+ 1;
49 for (i
= 0; i
< plane_height
; i
++)
51 vpx_memset(dest_ptr1
, src_ptr1
[0], Border
);
52 vpx_memset(dest_ptr2
, src_ptr2
[0], Border
);
53 src_ptr1
+= plane_stride
;
54 src_ptr2
+= plane_stride
;
55 dest_ptr1
+= plane_stride
;
56 dest_ptr2
+= plane_stride
;
59 /* Now copy the top and bottom source lines into each line of the respective borders */
60 src_ptr1
= ybf
->y_buffer
- Border
;
61 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
62 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
63 dest_ptr2
= src_ptr2
+ plane_stride
;
65 for (i
= 0; i
< (int)Border
; i
++)
67 vpx_memcpy(dest_ptr1
, src_ptr1
, plane_stride
);
68 vpx_memcpy(dest_ptr2
, src_ptr2
, plane_stride
);
69 dest_ptr1
+= plane_stride
;
70 dest_ptr2
+= plane_stride
;
77 plane_stride
= ybf
->uv_stride
;
78 plane_height
= ybf
->uv_height
;
79 plane_width
= ybf
->uv_width
;
82 /* copy the left and right most columns out */
83 src_ptr1
= ybf
->u_buffer
;
84 src_ptr2
= src_ptr1
+ plane_width
- 1;
85 dest_ptr1
= src_ptr1
- Border
;
86 dest_ptr2
= src_ptr2
+ 1;
88 for (i
= 0; i
< plane_height
; i
++)
90 vpx_memset(dest_ptr1
, src_ptr1
[0], Border
);
91 vpx_memset(dest_ptr2
, src_ptr2
[0], Border
);
92 src_ptr1
+= plane_stride
;
93 src_ptr2
+= plane_stride
;
94 dest_ptr1
+= plane_stride
;
95 dest_ptr2
+= plane_stride
;
98 /* Now copy the top and bottom source lines into each line of the respective borders */
99 src_ptr1
= ybf
->u_buffer
- Border
;
100 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
101 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
102 dest_ptr2
= src_ptr2
+ plane_stride
;
104 for (i
= 0; i
< (int)(Border
); i
++)
106 vpx_memcpy(dest_ptr1
, src_ptr1
, plane_stride
);
107 vpx_memcpy(dest_ptr2
, src_ptr2
, plane_stride
);
108 dest_ptr1
+= plane_stride
;
109 dest_ptr2
+= plane_stride
;
116 /* copy the left and right most columns out */
117 src_ptr1
= ybf
->v_buffer
;
118 src_ptr2
= src_ptr1
+ plane_width
- 1;
119 dest_ptr1
= src_ptr1
- Border
;
120 dest_ptr2
= src_ptr2
+ 1;
122 for (i
= 0; i
< plane_height
; i
++)
124 vpx_memset(dest_ptr1
, src_ptr1
[0], Border
);
125 vpx_memset(dest_ptr2
, src_ptr2
[0], Border
);
126 src_ptr1
+= plane_stride
;
127 src_ptr2
+= plane_stride
;
128 dest_ptr1
+= plane_stride
;
129 dest_ptr2
+= plane_stride
;
132 /* Now copy the top and bottom source lines into each line of the respective borders */
133 src_ptr1
= ybf
->v_buffer
- Border
;
134 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
135 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
136 dest_ptr2
= src_ptr2
+ plane_stride
;
138 for (i
= 0; i
< (int)(Border
); i
++)
140 vpx_memcpy(dest_ptr1
, src_ptr1
, plane_stride
);
141 vpx_memcpy(dest_ptr2
, src_ptr2
, plane_stride
);
142 dest_ptr1
+= plane_stride
;
143 dest_ptr2
+= plane_stride
;
149 extend_frame_borders_yonly(YV12_BUFFER_CONFIG
*ybf
)
152 unsigned char *src_ptr1
, *src_ptr2
;
153 unsigned char *dest_ptr1
, *dest_ptr2
;
163 Border
= ybf
->border
;
164 plane_stride
= ybf
->y_stride
;
165 plane_height
= ybf
->y_height
;
166 plane_width
= ybf
->y_width
;
168 /* copy the left and right most columns out */
169 src_ptr1
= ybf
->y_buffer
;
170 src_ptr2
= src_ptr1
+ plane_width
- 1;
171 dest_ptr1
= src_ptr1
- Border
;
172 dest_ptr2
= src_ptr2
+ 1;
174 for (i
= 0; i
< plane_height
; i
++)
176 vpx_memset(dest_ptr1
, src_ptr1
[0], Border
);
177 vpx_memset(dest_ptr2
, src_ptr2
[0], Border
);
178 src_ptr1
+= plane_stride
;
179 src_ptr2
+= plane_stride
;
180 dest_ptr1
+= plane_stride
;
181 dest_ptr2
+= plane_stride
;
184 /* Now copy the top and bottom source lines into each line of the respective borders */
185 src_ptr1
= ybf
->y_buffer
- Border
;
186 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
187 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
188 dest_ptr2
= src_ptr2
+ plane_stride
;
190 for (i
= 0; i
< (int)Border
; i
++)
192 vpx_memcpy(dest_ptr1
, src_ptr1
, plane_stride
);
193 vpx_memcpy(dest_ptr2
, src_ptr2
, plane_stride
);
194 dest_ptr1
+= plane_stride
;
195 dest_ptr2
+= plane_stride
;
207 /****************************************************************************
209 * ROUTINE : vp8_yv12_copy_frame
217 * FUNCTION : Copies the source image into the destination image and
218 * updates the destination's UMV borders.
220 * SPECIAL NOTES : The frames are assumed to be identical in size.
222 ****************************************************************************/
224 vp8_yv12_copy_frame(YV12_BUFFER_CONFIG
*src_ybc
, YV12_BUFFER_CONFIG
*dst_ybc
)
227 unsigned char *source
, *dest
;
229 source
= src_ybc
->y_buffer
;
230 dest
= dst_ybc
->y_buffer
;
232 for (row
= 0; row
< src_ybc
->y_height
; row
++)
234 vpx_memcpy(dest
, source
, src_ybc
->y_width
);
235 source
+= src_ybc
->y_stride
;
236 dest
+= dst_ybc
->y_stride
;
239 source
= src_ybc
->u_buffer
;
240 dest
= dst_ybc
->u_buffer
;
242 for (row
= 0; row
< src_ybc
->uv_height
; row
++)
244 vpx_memcpy(dest
, source
, src_ybc
->uv_width
);
245 source
+= src_ybc
->uv_stride
;
246 dest
+= dst_ybc
->uv_stride
;
249 source
= src_ybc
->v_buffer
;
250 dest
= dst_ybc
->v_buffer
;
252 for (row
= 0; row
< src_ybc
->uv_height
; row
++)
254 vpx_memcpy(dest
, source
, src_ybc
->uv_width
);
255 source
+= src_ybc
->uv_stride
;
256 dest
+= dst_ybc
->uv_stride
;
259 vp8_yv12_extend_frame_borders_ptr(dst_ybc
);
263 vp8_yv12_copy_frame_yonly(YV12_BUFFER_CONFIG
*src_ybc
, YV12_BUFFER_CONFIG
*dst_ybc
)
266 unsigned char *source
, *dest
;
269 source
= src_ybc
->y_buffer
;
270 dest
= dst_ybc
->y_buffer
;
272 for (row
= 0; row
< src_ybc
->y_height
; row
++)
274 vpx_memcpy(dest
, source
, src_ybc
->y_width
);
275 source
+= src_ybc
->y_stride
;
276 dest
+= dst_ybc
->y_stride
;
279 extend_frame_borders_yonly(dst_ybc
);