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)
120 #define SIMD_ALIGNED(var) __declspec(align(16)) var
122 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
124 extern SIMD_ALIGNED(int16 kCoefficientsRgbY
[768][4]);
126 // x64 uses MMX2 (SSE) so emms is not required.
127 // Warning C4799: function has no EMMS instruction.
128 // EMMS() is slow and should be called by the calling function once per image.
129 #if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
130 #if defined(_MSC_VER)
131 #define EMMS() __asm emms
132 #pragma warning(disable: 4799)
134 #define EMMS() asm("emms")
137 #define EMMS() ((void)0)
142 #endif // MEDIA_BASE_YUV_ROW_H_