1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/ycbcr/yuv_row.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,142 @@ 1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +// yuv_row internal functions to handle YUV conversion and scaling to RGB. 1.9 +// These functions are used from both yuv_convert.cc and yuv_scale.cc. 1.10 + 1.11 +// TODO(fbarchard): Write function that can handle rotation and scaling. 1.12 + 1.13 +#ifndef MEDIA_BASE_YUV_ROW_H_ 1.14 +#define MEDIA_BASE_YUV_ROW_H_ 1.15 + 1.16 +#include "chromium_types.h" 1.17 + 1.18 +extern "C" { 1.19 +// Can only do 1x. 1.20 +// This is the second fastest of the scalers. 1.21 +void FastConvertYUVToRGB32Row(const uint8* y_buf, 1.22 + const uint8* u_buf, 1.23 + const uint8* v_buf, 1.24 + uint8* rgb_buf, 1.25 + int width); 1.26 + 1.27 +void FastConvertYUVToRGB32Row_C(const uint8* y_buf, 1.28 + const uint8* u_buf, 1.29 + const uint8* v_buf, 1.30 + uint8* rgb_buf, 1.31 + int width, 1.32 + unsigned int x_shift); 1.33 + 1.34 +void FastConvertYUVToRGB32Row(const uint8* y_buf, 1.35 + const uint8* u_buf, 1.36 + const uint8* v_buf, 1.37 + uint8* rgb_buf, 1.38 + int width); 1.39 + 1.40 +// Can do 1x, half size or any scale down by an integer amount. 1.41 +// Step can be negative (mirroring, rotate 180). 1.42 +// This is the third fastest of the scalers. 1.43 +// Only defined on Windows x86-32. 1.44 +void ConvertYUVToRGB32Row_SSE(const uint8* y_buf, 1.45 + const uint8* u_buf, 1.46 + const uint8* v_buf, 1.47 + uint8* rgb_buf, 1.48 + int width, 1.49 + int step); 1.50 + 1.51 +// Rotate is like Convert, but applies different step to Y versus U and V. 1.52 +// This allows rotation by 90 or 270, by stepping by stride. 1.53 +// This is the forth fastest of the scalers. 1.54 +// Only defined on Windows x86-32. 1.55 +void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf, 1.56 + const uint8* u_buf, 1.57 + const uint8* v_buf, 1.58 + uint8* rgb_buf, 1.59 + int width, 1.60 + int ystep, 1.61 + int uvstep); 1.62 + 1.63 +// Doubler does 4 pixels at a time. Each pixel is replicated. 1.64 +// This is the fastest of the scalers. 1.65 +// Only defined on Windows x86-32. 1.66 +void DoubleYUVToRGB32Row_SSE(const uint8* y_buf, 1.67 + const uint8* u_buf, 1.68 + const uint8* v_buf, 1.69 + uint8* rgb_buf, 1.70 + int width); 1.71 + 1.72 +// Handles arbitrary scaling up or down. 1.73 +// Mirroring is supported, but not 90 or 270 degree rotation. 1.74 +// Chroma is under sampled every 2 pixels for performance. 1.75 +void ScaleYUVToRGB32Row(const uint8* y_buf, 1.76 + const uint8* u_buf, 1.77 + const uint8* v_buf, 1.78 + uint8* rgb_buf, 1.79 + int width, 1.80 + int source_dx); 1.81 + 1.82 +void ScaleYUVToRGB32Row(const uint8* y_buf, 1.83 + const uint8* u_buf, 1.84 + const uint8* v_buf, 1.85 + uint8* rgb_buf, 1.86 + int width, 1.87 + int source_dx); 1.88 + 1.89 +void ScaleYUVToRGB32Row_C(const uint8* y_buf, 1.90 + const uint8* u_buf, 1.91 + const uint8* v_buf, 1.92 + uint8* rgb_buf, 1.93 + int width, 1.94 + int source_dx); 1.95 + 1.96 +// Handles arbitrary scaling up or down with bilinear filtering. 1.97 +// Mirroring is supported, but not 90 or 270 degree rotation. 1.98 +// Chroma is under sampled every 2 pixels for performance. 1.99 +// This is the slowest of the scalers. 1.100 +void LinearScaleYUVToRGB32Row(const uint8* y_buf, 1.101 + const uint8* u_buf, 1.102 + const uint8* v_buf, 1.103 + uint8* rgb_buf, 1.104 + int width, 1.105 + int source_dx); 1.106 + 1.107 +void LinearScaleYUVToRGB32Row(const uint8* y_buf, 1.108 + const uint8* u_buf, 1.109 + const uint8* v_buf, 1.110 + uint8* rgb_buf, 1.111 + int width, 1.112 + int source_dx); 1.113 + 1.114 +void LinearScaleYUVToRGB32Row_C(const uint8* y_buf, 1.115 + const uint8* u_buf, 1.116 + const uint8* v_buf, 1.117 + uint8* rgb_buf, 1.118 + int width, 1.119 + int source_dx); 1.120 + 1.121 + 1.122 +#if defined(_MSC_VER) 1.123 +#define SIMD_ALIGNED(var) __declspec(align(16)) var 1.124 +#else 1.125 +#define SIMD_ALIGNED(var) var __attribute__((aligned(16))) 1.126 +#endif 1.127 +extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]); 1.128 + 1.129 +// x64 uses MMX2 (SSE) so emms is not required. 1.130 +// Warning C4799: function has no EMMS instruction. 1.131 +// EMMS() is slow and should be called by the calling function once per image. 1.132 +#if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64) 1.133 +#if defined(_MSC_VER) 1.134 +#define EMMS() __asm emms 1.135 +#pragma warning(disable: 4799) 1.136 +#else 1.137 +#define EMMS() asm("emms") 1.138 +#endif 1.139 +#else 1.140 +#define EMMS() ((void)0) 1.141 +#endif 1.142 + 1.143 +} // extern "C" 1.144 + 1.145 +#endif // MEDIA_BASE_YUV_ROW_H_