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

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

Issue 1302353004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 3 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
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 #include <assert.h> 11 #include <assert.h>
12 #include "./vpx_config.h" 12 #include "./vpx_config.h"
13 #include "./vpx_scale_rtcd.h" 13 #include "./vpx_scale_rtcd.h"
14 #include "vpx/vpx_integer.h" 14 #include "vpx/vpx_integer.h"
15 #include "vpx_mem/vpx_mem.h" 15 #include "vpx_mem/vpx_mem.h"
16 #include "vpx_ports/mem.h" 16 #include "vpx_ports/mem.h"
17 #include "vpx_scale/yv12config.h" 17 #include "vpx_scale/yv12config.h"
18 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 18 #if CONFIG_VP9_HIGHBITDEPTH
19 #include "vp9/common/vp9_common.h" 19 #include "vp9/common/vp9_common.h"
20 #endif 20 #endif
21 21
22 static void extend_plane(uint8_t *const src, int src_stride, 22 static void extend_plane(uint8_t *const src, int src_stride,
23 int width, int height, 23 int width, int height,
24 int extend_top, int extend_left, 24 int extend_top, int extend_left,
25 int extend_bottom, int extend_right) { 25 int extend_bottom, int extend_right) {
26 int i; 26 int i;
27 const int linesize = extend_left + extend_right + width; 27 const int linesize = extend_left + extend_right + width;
28 28
(...skipping 24 matching lines...) Expand all
53 memcpy(dst_ptr1, src_ptr1, linesize); 53 memcpy(dst_ptr1, src_ptr1, linesize);
54 dst_ptr1 += src_stride; 54 dst_ptr1 += src_stride;
55 } 55 }
56 56
57 for (i = 0; i < extend_bottom; ++i) { 57 for (i = 0; i < extend_bottom; ++i) {
58 memcpy(dst_ptr2, src_ptr2, linesize); 58 memcpy(dst_ptr2, src_ptr2, linesize);
59 dst_ptr2 += src_stride; 59 dst_ptr2 += src_stride;
60 } 60 }
61 } 61 }
62 62
63 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 63 #if CONFIG_VP9_HIGHBITDEPTH
64 static void extend_plane_high(uint8_t *const src8, int src_stride, 64 static void extend_plane_high(uint8_t *const src8, int src_stride,
65 int width, int height, 65 int width, int height,
66 int extend_top, int extend_left, 66 int extend_top, int extend_left,
67 int extend_bottom, int extend_right) { 67 int extend_bottom, int extend_right) {
68 int i; 68 int i;
69 const int linesize = extend_left + extend_right + width; 69 const int linesize = extend_left + extend_right + width;
70 uint16_t *src = CONVERT_TO_SHORTPTR(src8); 70 uint16_t *src = CONVERT_TO_SHORTPTR(src8);
71 71
72 /* copy the left and right most columns out */ 72 /* copy the left and right most columns out */
73 uint16_t *src_ptr1 = src; 73 uint16_t *src_ptr1 = src;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { 107 void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
108 const int uv_border = ybf->border / 2; 108 const int uv_border = ybf->border / 2;
109 109
110 assert(ybf->border % 2 == 0); 110 assert(ybf->border % 2 == 0);
111 assert(ybf->y_height - ybf->y_crop_height < 16); 111 assert(ybf->y_height - ybf->y_crop_height < 16);
112 assert(ybf->y_width - ybf->y_crop_width < 16); 112 assert(ybf->y_width - ybf->y_crop_width < 16);
113 assert(ybf->y_height - ybf->y_crop_height >= 0); 113 assert(ybf->y_height - ybf->y_crop_height >= 0);
114 assert(ybf->y_width - ybf->y_crop_width >= 0); 114 assert(ybf->y_width - ybf->y_crop_width >= 0);
115 115
116 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 116 #if CONFIG_VP9_HIGHBITDEPTH
117 if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) { 117 if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) {
118 extend_plane_high( 118 extend_plane_high(
119 ybf->y_buffer, ybf->y_stride, 119 ybf->y_buffer, ybf->y_stride,
120 ybf->y_crop_width, ybf->y_crop_height, 120 ybf->y_crop_width, ybf->y_crop_height,
121 ybf->border, ybf->border, 121 ybf->border, ybf->border,
122 ybf->border + ybf->y_height - ybf->y_crop_height, 122 ybf->border + ybf->y_height - ybf->y_crop_height,
123 ybf->border + ybf->y_width - ybf->y_crop_width); 123 ybf->border + ybf->y_width - ybf->y_crop_width);
124 124
125 extend_plane_high( 125 extend_plane_high(
126 ybf->u_buffer, ybf->uv_stride, 126 ybf->u_buffer, ybf->uv_stride,
(...skipping 23 matching lines...) Expand all
150 uv_border + ybf->uv_height - ybf->uv_crop_height, 150 uv_border + ybf->uv_height - ybf->uv_crop_height,
151 uv_border + ybf->uv_width - ybf->uv_crop_width); 151 uv_border + ybf->uv_width - ybf->uv_crop_width);
152 152
153 extend_plane(ybf->v_buffer, ybf->uv_stride, 153 extend_plane(ybf->v_buffer, ybf->uv_stride,
154 ybf->uv_crop_width, ybf->uv_crop_height, 154 ybf->uv_crop_width, ybf->uv_crop_height,
155 uv_border, uv_border, 155 uv_border, uv_border,
156 uv_border + ybf->uv_height - ybf->uv_crop_height, 156 uv_border + ybf->uv_height - ybf->uv_crop_height,
157 uv_border + ybf->uv_width - ybf->uv_crop_width); 157 uv_border + ybf->uv_width - ybf->uv_crop_width);
158 } 158 }
159 159
160 #if CONFIG_VP9 160 #if CONFIG_VP9 || CONFIG_VP10
161 static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size) { 161 static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size) {
162 const int c_w = ybf->uv_crop_width; 162 const int c_w = ybf->uv_crop_width;
163 const int c_h = ybf->uv_crop_height; 163 const int c_h = ybf->uv_crop_height;
164 const int ss_x = ybf->uv_width < ybf->y_width; 164 const int ss_x = ybf->uv_width < ybf->y_width;
165 const int ss_y = ybf->uv_height < ybf->y_height; 165 const int ss_y = ybf->uv_height < ybf->y_height;
166 const int c_et = ext_size >> ss_y; 166 const int c_et = ext_size >> ss_y;
167 const int c_el = ext_size >> ss_x; 167 const int c_el = ext_size >> ss_x;
168 const int c_eb = c_et + ybf->uv_height - ybf->uv_crop_height; 168 const int c_eb = c_et + ybf->uv_height - ybf->uv_crop_height;
169 const int c_er = c_el + ybf->uv_width - ybf->uv_crop_width; 169 const int c_er = c_el + ybf->uv_width - ybf->uv_crop_width;
170 170
(...skipping 22 matching lines...) Expand all
193 ext_size + ybf->y_height - ybf->y_crop_height, 193 ext_size + ybf->y_height - ybf->y_crop_height,
194 ext_size + ybf->y_width - ybf->y_crop_width); 194 ext_size + ybf->y_width - ybf->y_crop_width);
195 195
196 extend_plane(ybf->u_buffer, ybf->uv_stride, 196 extend_plane(ybf->u_buffer, ybf->uv_stride,
197 c_w, c_h, c_et, c_el, c_eb, c_er); 197 c_w, c_h, c_et, c_el, c_eb, c_er);
198 198
199 extend_plane(ybf->v_buffer, ybf->uv_stride, 199 extend_plane(ybf->v_buffer, ybf->uv_stride,
200 c_w, c_h, c_et, c_el, c_eb, c_er); 200 c_w, c_h, c_et, c_el, c_eb, c_er);
201 } 201 }
202 202
203 void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { 203 void vpx_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
204 extend_frame(ybf, ybf->border); 204 extend_frame(ybf, ybf->border);
205 } 205 }
206 206
207 void vp9_extend_frame_inner_borders_c(YV12_BUFFER_CONFIG *ybf) { 207 void vpx_extend_frame_inner_borders_c(YV12_BUFFER_CONFIG *ybf) {
208 const int inner_bw = (ybf->border > VP9INNERBORDERINPIXELS) ? 208 const int inner_bw = (ybf->border > VP9INNERBORDERINPIXELS) ?
209 VP9INNERBORDERINPIXELS : ybf->border; 209 VP9INNERBORDERINPIXELS : ybf->border;
210 extend_frame(ybf, inner_bw); 210 extend_frame(ybf, inner_bw);
211 } 211 }
212 212
213 #if CONFIG_VP9_HIGHBITDEPTH 213 #if CONFIG_VP9_HIGHBITDEPTH
214 void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) { 214 void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) {
215 uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); 215 uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
216 uint16_t *src = CONVERT_TO_SHORTPTR(src8); 216 uint16_t *src = CONVERT_TO_SHORTPTR(src8);
217 memcpy(dst, src, num * sizeof(uint16_t)); 217 memcpy(dst, src, num * sizeof(uint16_t));
218 } 218 }
219 #endif // CONFIG_VP9_HIGHBITDEPTH 219 #endif // CONFIG_VP9_HIGHBITDEPTH
220 #endif // CONFIG_VP9 220 #endif // CONFIG_VP9 || CONFIG_VP10
221 221
222 // Copies the source image into the destination image and updates the 222 // Copies the source image into the destination image and updates the
223 // destination's UMV borders. 223 // destination's UMV borders.
224 // Note: The frames are assumed to be identical in size. 224 // Note: The frames are assumed to be identical in size.
225 void vp8_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_ybc, 225 void vp8_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_ybc,
226 YV12_BUFFER_CONFIG *dst_ybc) { 226 YV12_BUFFER_CONFIG *dst_ybc) {
227 int row; 227 int row;
228 const uint8_t *src = src_ybc->y_buffer; 228 const uint8_t *src = src_ybc->y_buffer;
229 uint8_t *dst = dst_ybc->y_buffer; 229 uint8_t *dst = dst_ybc->y_buffer;
230 230
231 #if 0 231 #if 0
232 /* These assertions are valid in the codec, but the libvpx-tester uses 232 /* These assertions are valid in the codec, but the libvpx-tester uses
233 * this code slightly differently. 233 * this code slightly differently.
234 */ 234 */
235 assert(src_ybc->y_width == dst_ybc->y_width); 235 assert(src_ybc->y_width == dst_ybc->y_width);
236 assert(src_ybc->y_height == dst_ybc->y_height); 236 assert(src_ybc->y_height == dst_ybc->y_height);
237 #endif 237 #endif
238 238
239 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 239 #if CONFIG_VP9_HIGHBITDEPTH
240 if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) { 240 if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
241 assert(dst_ybc->flags & YV12_FLAG_HIGHBITDEPTH); 241 assert(dst_ybc->flags & YV12_FLAG_HIGHBITDEPTH);
242 for (row = 0; row < src_ybc->y_height; ++row) { 242 for (row = 0; row < src_ybc->y_height; ++row) {
243 memcpy_short_addr(dst, src, src_ybc->y_width); 243 memcpy_short_addr(dst, src, src_ybc->y_width);
244 src += src_ybc->y_stride; 244 src += src_ybc->y_stride;
245 dst += dst_ybc->y_stride; 245 dst += dst_ybc->y_stride;
246 } 246 }
247 247
248 src = src_ybc->u_buffer; 248 src = src_ybc->u_buffer;
249 dst = dst_ybc->u_buffer; 249 dst = dst_ybc->u_buffer;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 vp8_yv12_extend_frame_borders_c(dst_ybc); 297 vp8_yv12_extend_frame_borders_c(dst_ybc);
298 } 298 }
299 299
300 void vpx_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, 300 void vpx_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc,
301 YV12_BUFFER_CONFIG *dst_ybc) { 301 YV12_BUFFER_CONFIG *dst_ybc) {
302 int row; 302 int row;
303 const uint8_t *src = src_ybc->y_buffer; 303 const uint8_t *src = src_ybc->y_buffer;
304 uint8_t *dst = dst_ybc->y_buffer; 304 uint8_t *dst = dst_ybc->y_buffer;
305 305
306 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 306 #if CONFIG_VP9_HIGHBITDEPTH
307 if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) { 307 if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) {
308 const uint16_t *src16 = CONVERT_TO_SHORTPTR(src); 308 const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
309 uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst); 309 uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
310 for (row = 0; row < src_ybc->y_height; ++row) { 310 for (row = 0; row < src_ybc->y_height; ++row) {
311 memcpy(dst16, src16, src_ybc->y_width * sizeof(uint16_t)); 311 memcpy(dst16, src16, src_ybc->y_width * sizeof(uint16_t));
312 src16 += src_ybc->y_stride; 312 src16 += src_ybc->y_stride;
313 dst16 += dst_ybc->y_stride; 313 dst16 += dst_ybc->y_stride;
314 } 314 }
315 return; 315 return;
316 } 316 }
317 #endif 317 #endif
318 318
319 for (row = 0; row < src_ybc->y_height; ++row) { 319 for (row = 0; row < src_ybc->y_height; ++row) {
320 memcpy(dst, src, src_ybc->y_width); 320 memcpy(dst, src, src_ybc->y_width);
321 src += src_ybc->y_stride; 321 src += src_ybc->y_stride;
322 dst += dst_ybc->y_stride; 322 dst += dst_ybc->y_stride;
323 } 323 }
324 } 324 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_scale/generic/yv12config.c ('k') | source/libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698