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