2 * Copyright (c) 2010 The VP8 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 /****************************************************************************
14 * Module Title : yv12extend.c
18 ***************************************************************************/
20 /****************************************************************************
22 ****************************************************************************/
23 #include "vpx_scale/yv12config.h"
24 #include "vpx_mem/vpx_mem.h"
27 #include <nitro/itcm_begin.h>
32 /****************************************************************************
34 ****************************************************************************/
36 /****************************************************************************
38 ****************************************************************************/
40 vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG
*ybf
)
43 unsigned char *src_ptr1
, *src_ptr2
;
44 unsigned char *dest_ptr1
, *dest_ptr2
;
55 plane_stride
= ybf
->y_stride
;
56 plane_height
= ybf
->y_height
;
57 plane_width
= ybf
->y_width
;
59 // copy the left and right most columns out
60 src_ptr1
= ybf
->y_buffer
;
61 src_ptr2
= src_ptr1
+ plane_width
- 1;
62 dest_ptr1
= src_ptr1
- Border
;
63 dest_ptr2
= src_ptr2
+ 1;
65 for (i
= 0; i
< plane_height
; i
++)
67 mi_cpu_fill8(dest_ptr1
, src_ptr1
[0], Border
);
68 mi_cpu_fill8(dest_ptr2
, src_ptr2
[0], Border
);
69 src_ptr1
+= plane_stride
;
70 src_ptr2
+= plane_stride
;
71 dest_ptr1
+= plane_stride
;
72 dest_ptr2
+= plane_stride
;
75 // Now copy the top and bottom source lines into each line of the respective borders
76 src_ptr1
= ybf
->y_buffer
- Border
;
77 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
78 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
79 dest_ptr2
= src_ptr2
+ plane_stride
;
81 for (i
= 0; i
< (int)Border
; i
++)
83 mi_cpu_copy_fast(src_ptr1
, dest_ptr1
, plane_stride
);
84 mi_cpu_copy_fast(src_ptr2
, dest_ptr2
, plane_stride
);
85 dest_ptr1
+= plane_stride
;
86 dest_ptr2
+= plane_stride
;
98 // copy the left and right most columns out
99 src_ptr1
= ybf
->u_buffer
;
100 src_ptr2
= src_ptr1
+ plane_width
- 1;
101 dest_ptr1
= src_ptr1
- Border
;
102 dest_ptr2
= src_ptr2
+ 1;
104 for (i
= 0; i
< plane_height
; i
++)
106 mi_cpu_fill8(dest_ptr1
, src_ptr1
[0], Border
);
107 mi_cpu_fill8(dest_ptr2
, src_ptr2
[0], Border
);
108 src_ptr1
+= plane_stride
;
109 src_ptr2
+= plane_stride
;
110 dest_ptr1
+= plane_stride
;
111 dest_ptr2
+= plane_stride
;
114 // Now copy the top and bottom source lines into each line of the respective borders
115 src_ptr1
= ybf
->u_buffer
- Border
;
116 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
117 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
118 dest_ptr2
= src_ptr2
+ plane_stride
;
120 for (i
= 0; i
< (int)(Border
); i
++)
122 mi_cpu_copy_fast(src_ptr1
, dest_ptr1
, plane_stride
);
123 mi_cpu_copy_fast(src_ptr2
, dest_ptr2
, plane_stride
);
124 dest_ptr1
+= plane_stride
;
125 dest_ptr2
+= plane_stride
;
132 // copy the left and right most columns out
133 src_ptr1
= ybf
->v_buffer
;
134 src_ptr2
= src_ptr1
+ plane_width
- 1;
135 dest_ptr1
= src_ptr1
- Border
;
136 dest_ptr2
= src_ptr2
+ 1;
138 for (i
= 0; i
< plane_height
; i
++)
140 mi_cpu_fill8(dest_ptr1
, src_ptr1
[0], Border
);
141 mi_cpu_fill8(dest_ptr2
, src_ptr2
[0], Border
);
142 src_ptr1
+= plane_stride
;
143 src_ptr2
+= plane_stride
;
144 dest_ptr1
+= plane_stride
;
145 dest_ptr2
+= plane_stride
;
148 // Now copy the top and bottom source lines into each line of the respective borders
149 src_ptr1
= ybf
->v_buffer
- Border
;
150 src_ptr2
= src_ptr1
+ (plane_height
* plane_stride
) - plane_stride
;
151 dest_ptr1
= src_ptr1
- (Border
* plane_stride
);
152 dest_ptr2
= src_ptr2
+ plane_stride
;
154 for (i
= 0; i
< (int)(Border
); i
++)
156 mi_cpu_copy_fast(src_ptr1
, dest_ptr1
, plane_stride
);
157 mi_cpu_copy_fast(src_ptr2
, dest_ptr2
, plane_stride
);
158 dest_ptr1
+= plane_stride
;
159 dest_ptr2
+= plane_stride
;
165 /****************************************************************************
167 * ROUTINE : vp8_yv12_copy_frame
175 * FUNCTION : Copies the source image into the destination image and
176 * updates the destination's UMV borders.
178 * SPECIAL NOTES : The frames are assumed to be identical in size.
180 ****************************************************************************/
182 vp8_yv12_copy_frame(YV12_BUFFER_CONFIG
*src_ybc
, YV12_BUFFER_CONFIG
*dst_ybc
)
184 int yplane_size
= (src_ybc
->y_height
+ 2 * src_ybc
->border
) * (src_ybc
->y_stride
);
185 int mem_size
= (yplane_size
* 3 / 2) + (src_ybc
->y_stride
* 2);
187 mi_cpu_copy_fast(src_ybc
->buffer_alloc
, dst_ybc
->buffer_alloc
, mem_size
);
189 /* unsigned char *src_y, *dst_y;
190 unsigned char *src_u, *dst_u;
191 unsigned char *src_v, *dst_v;
193 int yheight, uv_height;
194 int ystride, uv_stride;
196 int yoffset, uvoffset;
198 border = src_ybc->border;
199 yheight = src_ybc->y_height;
200 uv_height = src_ybc->uv_height;
202 ystride = src_ybc->y_stride;
203 uv_stride = src_ybc->uv_stride;
205 yoffset = border * (ystride + 1);
206 uvoffset = border/2 * (uv_stride + 1);
208 src_y = src_ybc->y_buffer - yoffset;
209 dst_y = dst_ybc->y_buffer - yoffset;
210 src_u = src_ybc->u_buffer - uvoffset;
211 dst_u = dst_ybc->u_buffer - uvoffset;
212 src_v = src_ybc->v_buffer - uvoffset;
213 dst_v = dst_ybc->v_buffer - uvoffset;
215 mi_cpu_copy_fast (src_y, dst_y, ystride * (yheight + 2 * border));
216 mi_cpu_copy_fast (src_u, dst_u, uv_stride * (uv_height + border));
217 mi_cpu_copy_fast (src_v, dst_v, uv_stride * (uv_height + border));
221 #include <nitro/itcm_end.h>