1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 12 /**************************************************************************** 13 * 14 * Module Title : yv12extend.c 15 * 16 * Description : 17 * 18 ***************************************************************************/ 19 20 /**************************************************************************** 21 * Header Files 22 ****************************************************************************/ 23 #include "vpx_scale/yv12config.h" 24 #include "vpx_mem/vpx_mem.h" 25 #include <nitro.h> 26 #include <nitro/mi.h> 27 #include <nitro/itcm_begin.h> 28 29 //---- DMA Number 30 #define DMA_NO 3 31 32 /**************************************************************************** 33 * Exports 34 ****************************************************************************/ 35 36 /**************************************************************************** 37 * 38 ****************************************************************************/ 39 void 40 vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf) 41 { 42 int i; 43 unsigned char *src_ptr1, *src_ptr2; 44 unsigned char *dest_ptr1, *dest_ptr2; 45 46 unsigned int Border; 47 int plane_stride; 48 int plane_height; 49 int plane_width; 50 51 /***********/ 52 /* Y Plane */ 53 /***********/ 54 Border = ybf->border; 55 plane_stride = ybf->y_stride; 56 plane_height = ybf->y_height; 57 plane_width = ybf->y_width; 58 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; 64 65 for (i = 0; i < plane_height; i++) 66 { 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; 73 } 74 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; 80 81 for (i = 0; i < (int)Border; i++) 82 { 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; 87 } 88 89 plane_stride /= 2; 90 plane_height /= 2; 91 plane_width /= 2; 92 Border /= 2; 93 94 /***********/ 95 /* U Plane */ 96 /***********/ 97 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; 103 104 for (i = 0; i < plane_height; i++) 105 { 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; 112 } 113 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; 119 120 for (i = 0; i < (int)(Border); i++) 121 { 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; 126 } 127 128 /***********/ 129 /* V Plane */ 130 /***********/ 131 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; 137 138 for (i = 0; i < plane_height; i++) 139 { 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; 146 } 147 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; 153 154 for (i = 0; i < (int)(Border); i++) 155 { 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; 160 } 161 } 162 163 164 165 /**************************************************************************** 166 * 167 * ROUTINE : vp8_yv12_copy_frame 168 * 169 * INPUTS : 170 * 171 * OUTPUTS : None. 172 * 173 * RETURNS : void 174 * 175 * FUNCTION : Copies the source image into the destination image and 176 * updates the destination's UMV borders. 177 * 178 * SPECIAL NOTES : The frames are assumed to be identical in size. 179 * 180 ****************************************************************************/ 181 void 182 vp8_yv12_copy_frame(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc) 183 { 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); 186 187 mi_cpu_copy_fast(src_ybc->buffer_alloc, dst_ybc->buffer_alloc, mem_size); 188 189 /* unsigned char *src_y, *dst_y; 190 unsigned char *src_u, *dst_u; 191 unsigned char *src_v, *dst_v; 192 193 int yheight, uv_height; 194 int ystride, uv_stride; 195 int border; 196 int yoffset, uvoffset; 197 198 border = src_ybc->border; 199 yheight = src_ybc->y_height; 200 uv_height = src_ybc->uv_height; 201 202 ystride = src_ybc->y_stride; 203 uv_stride = src_ybc->uv_stride; 204 205 yoffset = border * (ystride + 1); 206 uvoffset = border/2 * (uv_stride + 1); 207 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; 214 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)); 218 */ 219 } 220 221 #include <nitro/itcm_end.h> 222