OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 The LibYuv 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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 int src_y_width, int src_y_height, | 39 int src_y_width, int src_y_height, |
40 int dst_uv_width, int dst_uv_height) { | 40 int dst_uv_width, int dst_uv_height) { |
41 const int dst_y_width = Abs(src_y_width); | 41 const int dst_y_width = Abs(src_y_width); |
42 const int dst_y_height = Abs(src_y_height); | 42 const int dst_y_height = Abs(src_y_height); |
43 const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1); | 43 const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1); |
44 const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1); | 44 const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1); |
45 if (src_y_width == 0 || src_y_height == 0 || | 45 if (src_y_width == 0 || src_y_height == 0 || |
46 dst_uv_width <= 0 || dst_uv_height <= 0) { | 46 dst_uv_width <= 0 || dst_uv_height <= 0) { |
47 return -1; | 47 return -1; |
48 } | 48 } |
49 ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, | 49 if (dst_y) { |
50 dst_y, dst_stride_y, dst_y_width, dst_y_height, | 50 ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, |
51 kFilterBilinear); | 51 dst_y, dst_stride_y, dst_y_width, dst_y_height, |
| 52 kFilterBilinear); |
| 53 } |
52 ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, | 54 ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, |
53 dst_u, dst_stride_u, dst_uv_width, dst_uv_height, | 55 dst_u, dst_stride_u, dst_uv_width, dst_uv_height, |
54 kFilterBilinear); | 56 kFilterBilinear); |
55 ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, | 57 ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, |
56 dst_v, dst_stride_v, dst_uv_width, dst_uv_height, | 58 dst_v, dst_stride_v, dst_uv_width, dst_uv_height, |
57 kFilterBilinear); | 59 kFilterBilinear); |
58 return 0; | 60 return 0; |
59 } | 61 } |
60 | 62 |
61 // 420 chroma is 1/2 width, 1/2 height | 63 // 420 chroma is 1/2 width, 1/2 height |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 const uint8* src_v, int src_stride_v, | 367 const uint8* src_v, int src_stride_v, |
366 uint8* dst_y, int dst_stride_y, | 368 uint8* dst_y, int dst_stride_y, |
367 uint8* dst_uv, int dst_stride_uv, | 369 uint8* dst_uv, int dst_stride_uv, |
368 int width, int height) { | 370 int width, int height) { |
369 int y; | 371 int y; |
370 void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, | 372 void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, |
371 int width) = MergeUVRow_C; | 373 int width) = MergeUVRow_C; |
372 // Coalesce rows. | 374 // Coalesce rows. |
373 int halfwidth = (width + 1) >> 1; | 375 int halfwidth = (width + 1) >> 1; |
374 int halfheight = (height + 1) >> 1; | 376 int halfheight = (height + 1) >> 1; |
375 if (!src_y || !src_u || !src_v || !dst_y || !dst_uv || | 377 if (!src_u || !src_v || !dst_uv || |
376 width <= 0 || height == 0) { | 378 width <= 0 || height == 0) { |
377 return -1; | 379 return -1; |
378 } | 380 } |
379 // Negative height means invert the image. | 381 // Negative height means invert the image. |
380 if (height < 0) { | 382 if (height < 0) { |
381 height = -height; | 383 height = -height; |
382 halfheight = (height + 1) >> 1; | 384 halfheight = (height + 1) >> 1; |
383 dst_y = dst_y + (height - 1) * dst_stride_y; | 385 if (dst_y) { |
| 386 dst_y = dst_y + (height - 1) * dst_stride_y; |
| 387 } |
384 dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv; | 388 dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv; |
385 dst_stride_y = -dst_stride_y; | 389 dst_stride_y = -dst_stride_y; |
386 dst_stride_uv = -dst_stride_uv; | 390 dst_stride_uv = -dst_stride_uv; |
387 } | 391 } |
388 if (src_stride_y == width && | 392 if (src_stride_y == width && |
389 dst_stride_y == width) { | 393 dst_stride_y == width) { |
390 width *= height; | 394 width *= height; |
391 height = 1; | 395 height = 1; |
392 src_stride_y = dst_stride_y = 0; | 396 src_stride_y = dst_stride_y = 0; |
393 } | 397 } |
(...skipping 23 matching lines...) Expand all Loading... |
417 #endif | 421 #endif |
418 #if defined(HAS_MERGEUVROW_NEON) | 422 #if defined(HAS_MERGEUVROW_NEON) |
419 if (TestCpuFlag(kCpuHasNEON)) { | 423 if (TestCpuFlag(kCpuHasNEON)) { |
420 MergeUVRow_ = MergeUVRow_Any_NEON; | 424 MergeUVRow_ = MergeUVRow_Any_NEON; |
421 if (IS_ALIGNED(halfwidth, 16)) { | 425 if (IS_ALIGNED(halfwidth, 16)) { |
422 MergeUVRow_ = MergeUVRow_NEON; | 426 MergeUVRow_ = MergeUVRow_NEON; |
423 } | 427 } |
424 } | 428 } |
425 #endif | 429 #endif |
426 | 430 |
427 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); | 431 if (dst_y) { |
| 432 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); |
| 433 } |
428 for (y = 0; y < halfheight; ++y) { | 434 for (y = 0; y < halfheight; ++y) { |
429 // Merge a row of U and V into a row of UV. | 435 // Merge a row of U and V into a row of UV. |
430 MergeUVRow_(src_u, src_v, dst_uv, halfwidth); | 436 MergeUVRow_(src_u, src_v, dst_uv, halfwidth); |
431 src_u += src_stride_u; | 437 src_u += src_stride_u; |
432 src_v += src_stride_v; | 438 src_v += src_stride_v; |
433 dst_uv += dst_stride_uv; | 439 dst_uv += dst_stride_uv; |
434 } | 440 } |
435 return 0; | 441 return 0; |
436 } | 442 } |
437 | 443 |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 default: | 1163 default: |
1158 return -1; // unknown fourcc - return failure code. | 1164 return -1; // unknown fourcc - return failure code. |
1159 } | 1165 } |
1160 return r; | 1166 return r; |
1161 } | 1167 } |
1162 | 1168 |
1163 #ifdef __cplusplus | 1169 #ifdef __cplusplus |
1164 } // extern "C" | 1170 } // extern "C" |
1165 } // namespace libyuv | 1171 } // namespace libyuv |
1166 #endif | 1172 #endif |
OLD | NEW |