| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This webpage shows layout of YV12 and other YUV formats | 5 // This webpage shows layout of YV12 and other YUV formats |
| 6 // http://www.fourcc.org/yuv.php | 6 // http://www.fourcc.org/yuv.php |
| 7 // The actual conversion is best described here | 7 // The actual conversion is best described here |
| 8 // http://en.wikipedia.org/wiki/YUV | 8 // http://en.wikipedia.org/wiki/YUV |
| 9 // An article on optimizing YUV conversion using tables instead of multiplies | 9 // An article on optimizing YUV conversion using tables instead of multiplies |
| 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf | 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf |
| 11 // | 11 // |
| 12 // YV12 is a full plane of Y and a half height, half width chroma planes | 12 // YV12 is a full plane of Y and a half height, half width chroma planes |
| 13 // YV16 is a full plane of Y and a full height, half width chroma planes | 13 // YV16 is a full plane of Y and a full height, half width chroma planes |
| 14 // | 14 // |
| 15 // ARGB pixel format is output, which on little endian is stored as BGRA. | 15 // ARGB pixel format is output, which on little endian is stored as BGRA. |
| 16 // The alpha is set to 255, allowing the application to use RGBA or RGB32. | 16 // The alpha is set to 255, allowing the application to use RGBA or RGB32. |
| 17 | 17 |
| 18 #include "media/base/yuv_convert.h" | 18 #include "media/base/yuv_convert.h" |
| 19 | 19 |
| 20 #include "base/cpu.h" | 20 #include "base/cpu.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "media/base/simd/convert_rgb_to_yuv.h" | 25 #include "media/base/simd/convert_rgb_to_yuv.h" |
| 25 #include "media/base/simd/convert_yuv_to_rgb.h" | 26 #include "media/base/simd/convert_yuv_to_rgb.h" |
| 26 #include "media/base/simd/filter_yuv.h" | 27 #include "media/base/simd/filter_yuv.h" |
| 27 | 28 |
| 28 #if defined(ARCH_CPU_X86_FAMILY) | 29 #if defined(ARCH_CPU_X86_FAMILY) |
| 29 #if defined(COMPILER_MSVC) | 30 #if defined(COMPILER_MSVC) |
| 30 #include <intrin.h> | 31 #include <intrin.h> |
| 31 #else | 32 #else |
| 32 #include <mmintrin.h> | 33 #include <mmintrin.h> |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 438 |
| 438 // Intermediate buffer for vertical interpolation. | 439 // Intermediate buffer for vertical interpolation. |
| 439 // 4096 bytes allows 3 buffers to fit in 12k, which fits in a 16K L1 cache, | 440 // 4096 bytes allows 3 buffers to fit in 12k, which fits in a 16K L1 cache, |
| 440 // and is bigger than most users will generally need. | 441 // and is bigger than most users will generally need. |
| 441 // The buffer is 16-byte aligned and padded with 16 extra bytes; some of the | 442 // The buffer is 16-byte aligned and padded with 16 extra bytes; some of the |
| 442 // FilterYUVRowProcs have alignment requirements, and the SSE version can | 443 // FilterYUVRowProcs have alignment requirements, and the SSE version can |
| 443 // write up to 16 bytes past the end of the buffer. | 444 // write up to 16 bytes past the end of the buffer. |
| 444 const int kFilterBufferSize = 4096; | 445 const int kFilterBufferSize = 4096; |
| 445 const bool kAvoidUsingOptimizedFilter = source_width > kFilterBufferSize; | 446 const bool kAvoidUsingOptimizedFilter = source_width > kFilterBufferSize; |
| 446 uint8 yuv_temp[16 + kFilterBufferSize * 3 + 16]; | 447 uint8 yuv_temp[16 + kFilterBufferSize * 3 + 16]; |
| 448 // memset() yuv_temp to 0 to avoid bogus warnings when running on Valgrind. |
| 449 if (RunningOnValgrind()) |
| 450 memset(yuv_temp, 0, sizeof(yuv_temp)); |
| 447 uint8* y_temp = reinterpret_cast<uint8*>( | 451 uint8* y_temp = reinterpret_cast<uint8*>( |
| 448 reinterpret_cast<uintptr_t>(yuv_temp + 15) & ~15); | 452 reinterpret_cast<uintptr_t>(yuv_temp + 15) & ~15); |
| 449 uint8* u_temp = y_temp + kFilterBufferSize; | 453 uint8* u_temp = y_temp + kFilterBufferSize; |
| 450 uint8* v_temp = u_temp + kFilterBufferSize; | 454 uint8* v_temp = u_temp + kFilterBufferSize; |
| 451 | 455 |
| 452 // Move to the top-left pixel of output. | 456 // Move to the top-left pixel of output. |
| 453 rgb_buf += dest_rect_top * rgb_pitch; | 457 rgb_buf += dest_rect_top * rgb_pitch; |
| 454 rgb_buf += dest_rect_left * 4; | 458 rgb_buf += dest_rect_left * 4; |
| 455 | 459 |
| 456 // For each destination row perform interpolation and color space | 460 // For each destination row perform interpolation and color space |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 width, | 650 width, |
| 647 height, | 651 height, |
| 648 ystride, | 652 ystride, |
| 649 uvstride, | 653 uvstride, |
| 650 astride, | 654 astride, |
| 651 rgbstride, | 655 rgbstride, |
| 652 yuv_type); | 656 yuv_type); |
| 653 } | 657 } |
| 654 | 658 |
| 655 } // namespace media | 659 } // namespace media |
| OLD | NEW |