michael@0: // Copyright (c) 2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // yuv_row internal functions to handle YUV conversion and scaling to RGB. michael@0: // These functions are used from both yuv_convert.cc and yuv_scale.cc. michael@0: michael@0: // TODO(fbarchard): Write function that can handle rotation and scaling. michael@0: michael@0: #ifndef MEDIA_BASE_YUV_ROW_H_ michael@0: #define MEDIA_BASE_YUV_ROW_H_ michael@0: michael@0: #include "chromium_types.h" michael@0: michael@0: extern "C" { michael@0: // Can only do 1x. michael@0: // This is the second fastest of the scalers. michael@0: void FastConvertYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width); michael@0: michael@0: void FastConvertYUVToRGB32Row_C(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: unsigned int x_shift); michael@0: michael@0: void FastConvertYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width); michael@0: michael@0: // Can do 1x, half size or any scale down by an integer amount. michael@0: // Step can be negative (mirroring, rotate 180). michael@0: // This is the third fastest of the scalers. michael@0: // Only defined on Windows x86-32. michael@0: void ConvertYUVToRGB32Row_SSE(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int step); michael@0: michael@0: // Rotate is like Convert, but applies different step to Y versus U and V. michael@0: // This allows rotation by 90 or 270, by stepping by stride. michael@0: // This is the forth fastest of the scalers. michael@0: // Only defined on Windows x86-32. michael@0: void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int ystep, michael@0: int uvstep); michael@0: michael@0: // Doubler does 4 pixels at a time. Each pixel is replicated. michael@0: // This is the fastest of the scalers. michael@0: // Only defined on Windows x86-32. michael@0: void DoubleYUVToRGB32Row_SSE(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width); michael@0: michael@0: // Handles arbitrary scaling up or down. michael@0: // Mirroring is supported, but not 90 or 270 degree rotation. michael@0: // Chroma is under sampled every 2 pixels for performance. michael@0: void ScaleYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: void ScaleYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: void ScaleYUVToRGB32Row_C(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: // Handles arbitrary scaling up or down with bilinear filtering. michael@0: // Mirroring is supported, but not 90 or 270 degree rotation. michael@0: // Chroma is under sampled every 2 pixels for performance. michael@0: // This is the slowest of the scalers. michael@0: void LinearScaleYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: void LinearScaleYUVToRGB32Row(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: void LinearScaleYUVToRGB32Row_C(const uint8* y_buf, michael@0: const uint8* u_buf, michael@0: const uint8* v_buf, michael@0: uint8* rgb_buf, michael@0: int width, michael@0: int source_dx); michael@0: michael@0: michael@0: #if defined(_MSC_VER) michael@0: #define SIMD_ALIGNED(var) __declspec(align(16)) var michael@0: #else michael@0: #define SIMD_ALIGNED(var) var __attribute__((aligned(16))) michael@0: #endif michael@0: extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]); michael@0: michael@0: // x64 uses MMX2 (SSE) so emms is not required. michael@0: // Warning C4799: function has no EMMS instruction. michael@0: // EMMS() is slow and should be called by the calling function once per image. michael@0: #if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64) michael@0: #if defined(_MSC_VER) michael@0: #define EMMS() __asm emms michael@0: #pragma warning(disable: 4799) michael@0: #else michael@0: #define EMMS() asm("emms") michael@0: #endif michael@0: #else michael@0: #define EMMS() ((void)0) michael@0: #endif michael@0: michael@0: } // extern "C" michael@0: michael@0: #endif // MEDIA_BASE_YUV_ROW_H_