1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // yuv_row internal functions to handle YUV conversion and scaling to RGB.
6 // These functions are used from both yuv_convert.cc and yuv_scale.cc.
8 // TODO(fbarchard): Write function that can handle rotation and scaling.
10 #ifndef MEDIA_BASE_YUV_ROW_H_
11 #define MEDIA_BASE_YUV_ROW_H_
13 #include "chromium_types.h"
17 // This is the second fastest of the scalers.
18 void FastConvertYUVToRGB32Row(const uint8
* y_buf
,
24 void FastConvertYUVToRGB32Row_C(const uint8
* y_buf
,
29 unsigned int x_shift
);
31 void FastConvertYUVToRGB32Row(const uint8
* y_buf
,
37 // Can do 1x, half size or any scale down by an integer amount.
38 // Step can be negative (mirroring, rotate 180).
39 // This is the third fastest of the scalers.
40 // Only defined on Windows x86-32.
41 void ConvertYUVToRGB32Row_SSE(const uint8
* y_buf
,
48 // Rotate is like Convert, but applies different step to Y versus U and V.
49 // This allows rotation by 90 or 270, by stepping by stride.
50 // This is the forth fastest of the scalers.
51 // Only defined on Windows x86-32.
52 void RotateConvertYUVToRGB32Row_SSE(const uint8
* y_buf
,
60 // Doubler does 4 pixels at a time. Each pixel is replicated.
61 // This is the fastest of the scalers.
62 // Only defined on Windows x86-32.
63 void DoubleYUVToRGB32Row_SSE(const uint8
* y_buf
,
69 // Handles arbitrary scaling up or down.
70 // Mirroring is supported, but not 90 or 270 degree rotation.
71 // Chroma is under sampled every 2 pixels for performance.
72 void ScaleYUVToRGB32Row(const uint8
* y_buf
,
79 void ScaleYUVToRGB32Row(const uint8
* y_buf
,
86 void ScaleYUVToRGB32Row_C(const uint8
* y_buf
,
93 // Handles arbitrary scaling up or down with bilinear filtering.
94 // Mirroring is supported, but not 90 or 270 degree rotation.
95 // Chroma is under sampled every 2 pixels for performance.
96 // This is the slowest of the scalers.
97 void LinearScaleYUVToRGB32Row(const uint8
* y_buf
,
104 void LinearScaleYUVToRGB32Row(const uint8
* y_buf
,
111 void LinearScaleYUVToRGB32Row_C(const uint8
* y_buf
,
119 #if defined(_MSC_VER) && !defined(__CLR_VER) && !defined(__clang__)
120 #if defined(VISUALC_HAS_AVX2)
121 #define SIMD_ALIGNED(var) __declspec(align(32)) var
123 #define SIMD_ALIGNED(var) __declspec(align(16)) var
125 #elif defined(__GNUC__) || defined(__clang__)
126 // Caveat GCC 4.2 to 4.7 have a known issue using vectors with const.
127 #if defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)
128 #define SIMD_ALIGNED(var) var __attribute__((aligned(32)))
130 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
133 #define SIMD_ALIGNED(var) var
136 extern SIMD_ALIGNED(const int16 kCoefficientsRgbY
[768][4]);
138 // x64 uses MMX2 (SSE) so emms is not required.
139 // Warning C4799: function has no EMMS instruction.
140 // EMMS() is slow and should be called by the calling function once per image.
141 #if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
142 #if defined(_MSC_VER)
143 #define EMMS() __asm emms
144 #pragma warning(disable: 4799)
146 #define EMMS() asm("emms")
149 #define EMMS() ((void)0)
154 #endif // MEDIA_BASE_YUV_ROW_H_