Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-02-27 12:15:12 +08:00
commit 7c0ddca067
280 changed files with 111730 additions and 37706 deletions

View file

@ -12,28 +12,28 @@ namespace dom {
/*
* Utility function form libyuv source files.
*/
static __inline int32 clamp0(int32 v) {
static __inline int32_t clamp0(int32_t v) {
return ((-(v) >> 31) & (v));
}
static __inline int32 clamp255(int32 v) {
static __inline int32_t clamp255(int32_t v) {
return (((255 - (v)) >> 31) | (v)) & 255;
}
static __inline uint32 Clamp(int32 val) {
static __inline uint32_t Clamp(int32_t val) {
int v = clamp0(val);
return (uint32)(clamp255(v));
return (uint32_t)(clamp255(v));
}
#define YG 74 /* (int8)(1.164 * 64 + 0.5) */
#define YG 74 /* (int8_t)(1.164 * 64 + 0.5) */
#define UB 127 /* min(63,(int8)(2.018 * 64)) */
#define UG -25 /* (int8)(-0.391 * 64 - 0.5) */
#define UB 127 /* min(63,(int8_t)(2.018 * 64)) */
#define UG -25 /* (int8_t)(-0.391 * 64 - 0.5) */
#define UR 0
#define VB 0
#define VG -52 /* (int8)(-0.813 * 64 - 0.5) */
#define VR 102 /* (int8)(1.596 * 64 + 0.5) */
#define VG -52 /* (int8_t)(-0.813 * 64 - 0.5) */
#define VR 102 /* (int8_t)(1.596 * 64 + 0.5) */
// Bias
#define BB UB * 128 + VB * 128
@ -41,28 +41,28 @@ static __inline uint32 Clamp(int32 val) {
#define BR UR * 128 + VR * 128
static __inline void
YuvPixel(uint8 y, uint8 u, uint8 v, uint8* b, uint8* g, uint8* r)
YuvPixel(uint8_t y, uint8_t u, uint8_t v, uint8_t* b, uint8_t* g, uint8_t* r)
{
int32 y1 = ((int32)(y) - 16) * YG;
*b = Clamp((int32)((u * UB + v * VB) - (BB) + y1) >> 6);
*g = Clamp((int32)((u * UG + v * VG) - (BG) + y1) >> 6);
*r = Clamp((int32)((u * UR + v * VR) - (BR) + y1) >> 6);
int32_t y1 = ((int32_t)(y) - 16) * YG;
*b = Clamp((int32_t)((u * UB + v * VB) - (BB) + y1) >> 6);
*g = Clamp((int32_t)((u * UG + v * VG) - (BG) + y1) >> 6);
*r = Clamp((int32_t)((u * UR + v * VR) - (BR) + y1) >> 6);
}
static __inline int
RGBToY(uint8 r, uint8 g, uint8 b)
RGBToY(uint8_t r, uint8_t g, uint8_t b)
{
return (66 * r + 129 * g + 25 * b + 0x1080) >> 8;
}
static __inline int
RGBToU(uint8 r, uint8 g, uint8 b)
RGBToU(uint8_t r, uint8_t g, uint8_t b)
{
return (112 * b - 74 * g - 38 * r + 0x8080) >> 8;
}
static __inline int
RGBToV(uint8 r, uint8 g, uint8 b)
RGBToV(uint8_t r, uint8_t g, uint8_t b)
{
return (112 * r - 94 * g - 18 * b + 0x8080) >> 8;
}

View file

@ -207,6 +207,7 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
data.mPicSize = aPicture.Size();
data.mStereoMode = aInfo.mStereoMode;
data.mYUVColorSpace = aBuffer.mYUVColorSpace;
data.mColorRange = aBuffer.mColorRange;
aVideoImage->SetDelayedConversion(true);
if (aCopyData) {

View file

@ -449,6 +449,7 @@ public:
Plane mPlanes[3];
YUVColorSpace mYUVColorSpace = YUVColorSpace::BT601;
ColorRange mColorRange = ColorRange::LIMITED;
};
// Constructs a VideoData object. If aImage is nullptr, creates a new Image

View file

@ -391,7 +391,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
switch (surf->GetFormat()) {
case SurfaceFormat::B8G8R8A8:
case SurfaceFormat::B8G8R8X8:
rv = libyuv::ARGBToI420(static_cast<uint8*>(map.GetData()),
rv = libyuv::ARGBToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(),
y, mFrameWidth,
cb, halfWidth,
@ -399,7 +399,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
mFrameWidth, mFrameHeight);
break;
case SurfaceFormat::R5G6B5_UINT16:
rv = libyuv::RGB565ToI420(static_cast<uint8*>(map.GetData()),
rv = libyuv::RGB565ToI420(static_cast<uint8_t*>(map.GetData()),
map.GetStride(),
y, mFrameWidth,
cb, halfWidth,

View file

@ -246,6 +246,8 @@ AOMDecoder::DoDecode(MediaRawData* aSample)
LOG("Unhandled colorspace %d", img->mc);
break;
}
b.mColorRange = img->range == AOM_CR_FULL_RANGE ? ColorRange::FULL
: ColorRange::LIMITED;
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,

View file

@ -173,6 +173,7 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
return YUVColorSpace::BT601;
}
}();
// TODO: need a newer libvpx to support full color range
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,

View file

@ -154,6 +154,7 @@ FFmpegLibWrapper::Link()
AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
AV_FUNC_OPTION(av_frame_get_color_range, AV_FUNC_AVUTIL_ALL)
#undef AV_FUNC
#undef AV_FUNC_OPTION

View file

@ -87,6 +87,7 @@ struct FFmpegLibWrapper
// libavutil optional
int (*av_frame_get_colorspace)(const AVFrame *frame);
int (*av_frame_get_color_range)(const AVFrame *frame);
PRLibrary* mAVCodecLib;
PRLibrary* mAVUtilLib;

View file

@ -388,6 +388,11 @@ FFmpegVideoDecoder<LIBAV_VER>::CreateImage(int64_t aOffset, int64_t aPts,
break;
}
}
if (mLib->av_frame_get_color_range) {
auto range = mLib->av_frame_get_color_range(mFrame);
b.mColorRange = range == AVCOL_RANGE_JPEG ? ColorRange::FULL : ColorRange::LIMITED;
}
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,
mImageContainer,

View file

@ -171,18 +171,14 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
uniform sampler2D uCrTexture; \n\
uniform vec2 uYTexScale; \n\
uniform vec2 uCbCrTexScale; \n\
uniform mat3 uYuvColorMatrix; \n\
uniform mat4 uYuvColorMatrix; \n\
void main() \n\
{ \n\
float y = texture2D(uYTexture, vTexCoord * uYTexScale).r; \n\
float cb = texture2D(uCbTexture, vTexCoord * uCbCrTexScale).r; \n\
float cr = texture2D(uCrTexture, vTexCoord * uCbCrTexScale).r; \n\
y = y - 0.06275; \n\
cb = cb - 0.50196; \n\
cr = cr - 0.50196; \n\
vec3 yuv = vec3(y, cb, cr); \n\
gl_FragColor.rgb = uYuvColorMatrix * yuv; \n\
gl_FragColor.a = 1.0; \n\
vec4 yuv = vec4(y, cb, cr, 1.0); \n\
gl_FragColor = uYuvColorMatrix * yuv; \n\
} \n\
";
@ -667,8 +663,8 @@ GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage)
mGL->fUniform2f(mCbCrTexScaleLoc, (float)yuvData->mCbCrSize.width/yuvData->mCbCrStride, 1.0f);
}
const float* yuvToRgb = gfxUtils::Get3x3YuvColorMatrix(yuvData->mYUVColorSpace);
mGL->fUniformMatrix3fv(mYuvColorMatrixLoc, 1, 0, yuvToRgb);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x4ColumnMajor(yuvData->mYUVColorSpace, yuvData->mColorRange);
mGL->fUniformMatrix4fv(mYuvColorMatrixLoc, 1, 0, yuvToRgb);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
for (int i = 0; i < 3; i++) {

View file

@ -961,6 +961,14 @@ struct ParamTraits<mozilla::YUVColorSpace>
mozilla::YUVColorSpace::UNKNOWN>
{};
template <>
struct ParamTraits<mozilla::ColorRange>
: public ContiguousEnumSerializer<
mozilla::ColorRange,
mozilla::ColorRange::LIMITED,
mozilla::ColorRange::UNKNOWN>
{};
template <>
struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
{

View file

@ -159,6 +159,7 @@ BufferTextureData*
BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aBufferSize,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags)
{
if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) {
@ -173,7 +174,7 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
// afterwards since we don't know the dimensions of the texture at this point.
BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), gfx::IntSize(),
0, 0, 0, StereoMode::MONO,
aYUVColorSpace,
aYUVColorSpace, aColorRange,
hasIntermediateBuffer);
return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr,
@ -186,6 +187,7 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags)
{
uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(aYSize, aCbCrSize);
@ -206,7 +208,7 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset,
crOffset, aStereoMode, aYUVColorSpace,
hasIntermediateBuffer);
aColorRange, hasIntermediateBuffer);
return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor,
gfx::BackendType::NONE, bufSize, aTextureFlags);
@ -254,6 +256,12 @@ BufferTextureData::GetYUVColorSpace() const
return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor);
}
Maybe<ColorRange>
BufferTextureData::GetColorRange() const
{
return ImageDataSerializer::ColorRangeFromBufferDescriptor(mDescriptor);
}
Maybe<StereoMode>
BufferTextureData::GetStereoMode() const
{

View file

@ -33,6 +33,7 @@ public:
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags);
// It is generally better to use CreateForYCbCr instead.
@ -41,6 +42,7 @@ public:
static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aSize,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags);
virtual bool Lock(OpenMode aMode) override { return true; }
@ -66,6 +68,7 @@ public:
Maybe<gfx::IntSize> GetCbCrSize() const;
Maybe<YUVColorSpace> GetYUVColorSpace() const;
Maybe<ColorRange> GetColorRange() const;
Maybe<StereoMode> GetStereoMode() const;

View file

@ -158,14 +158,17 @@ struct EffectRGB : public TexturedEffect
struct EffectYCbCr : public TexturedEffect
{
EffectYCbCr(TextureSource *aSource, YUVColorSpace aYUVColorSpace, gfx::SamplingFilter aSamplingFilter)
EffectYCbCr(TextureSource *aSource, YUVColorSpace aYUVColorSpace, ColorRange aColorRange,
gfx::SamplingFilter aSamplingFilter)
: TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter)
, mYUVColorSpace(aYUVColorSpace)
, mColorRange(aColorRange)
{}
virtual const char* Name() { return "EffectYCbCr"; }
YUVColorSpace mYUVColorSpace;
ColorRange mColorRange;
};
struct EffectNV12 : public TexturedEffect
@ -271,7 +274,9 @@ CreateTexturedEffect(TextureHost* aHost,
RefPtr<TexturedEffect> result;
if (aHost->GetReadFormat() == gfx::SurfaceFormat::YUV) {
MOZ_ASSERT(aHost->GetYUVColorSpace() != YUVColorSpace::UNKNOWN);
result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(), aSamplingFilter);
MOZ_ASSERT(aHost->GetColorRange() != ColorRange::UNKNOWN);
result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(), aHost->GetColorRange(),
aSamplingFilter);
} else {
result = CreateTexturedEffect(aHost->GetReadFormat(),
aSource,

View file

@ -672,6 +672,7 @@ struct PlanarYCbCrData {
gfx::IntSize mPicSize;
StereoMode mStereoMode;
YUVColorSpace mYUVColorSpace;
ColorRange mColorRange;
gfx::IntRect GetPictureRect() const {
return gfx::IntRect(mPicX, mPicY,
@ -684,7 +685,7 @@ struct PlanarYCbCrData {
, mCbChannel(nullptr), mCrChannel(nullptr)
, mCbCrStride(0), mCbCrSize(0, 0) , mCbSkip(0), mCrSkip(0)
, mPicX(0), mPicY(0), mPicSize(0, 0), mStereoMode(StereoMode::MONO)
, mYUVColorSpace(YUVColorSpace::BT601)
, mYUVColorSpace(YUVColorSpace::BT601), mColorRange(ColorRange::LIMITED)
{}
};

View file

@ -171,7 +171,6 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescri
}
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
{
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:
@ -182,6 +181,17 @@ Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& a
MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor");
}
}
Maybe<ColorRange> ColorRangeFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:
return Nothing();
case BufferDescriptor::TYCbCrDescriptor:
return Some(aDescriptor.get_YCbCrDescriptor().colorRange());
default:
MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor");
}
}
Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor)
@ -252,6 +262,7 @@ DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aD
ycbcrData.mCbCrSize = cbCrSize;
ycbcrData.mPicSize = ySize;
ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace();
ycbcrData.mColorRange = aDescriptor.colorRange();
gfx::ConvertYCbCrToRGB(ycbcrData,
gfx::SurfaceFormat::B8G8R8X8,

View file

@ -65,6 +65,7 @@ gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<ColorRange> ColorRangeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor);

View file

@ -123,6 +123,12 @@ enum class YUVColorSpace {
UNKNOWN,
};
enum class ColorRange {
LIMITED,
FULL,
UNKNOWN,
};
} // namespace mozilla
#endif

View file

@ -104,7 +104,7 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar
}
texture = TextureClient::CreateForYCbCr(aForwarder,
data->mYSize, data->mCbCrSize, data->mStereoMode,
data->mYUVColorSpace,
data->mYUVColorSpace, data->mColorRange,
TextureFlags::DEFAULT);
if (!texture) {
return nullptr;

View file

@ -1217,6 +1217,7 @@ TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags)
{
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
@ -1229,7 +1230,7 @@ TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator,
TextureData* data = BufferTextureData::CreateForYCbCr(aAllocator, aYSize, aCbCrSize,
aStereoMode, aYUVColorSpace,
aTextureFlags);
aColorRange, aTextureFlags);
if (!data) {
return nullptr;
}
@ -1243,6 +1244,7 @@ already_AddRefed<TextureClient>
TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags)
{
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
@ -1251,7 +1253,7 @@ TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
TextureData* data =
BufferTextureData::CreateForYCbCrWithBufferSize(aAllocator, aSize, aYUVColorSpace,
aTextureFlags);
aColorRange, aTextureFlags);
if (!data) {
return nullptr;
}

View file

@ -360,6 +360,7 @@ public:
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags);
// Creates and allocates a TextureClient (can be accessed through raw
@ -379,6 +380,7 @@ public:
CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize,
YUVColorSpace aYUVColorSpace,
ColorRange aColorRange,
TextureFlags aTextureFlags);
// Creates and allocates a TextureClient of the same type.

View file

@ -108,6 +108,8 @@ YCbCrTextureClientAllocationHelper::IsCompatible(TextureClient* aTextureClient)
bufferData->GetCbCrSize().ref() != mData.mCbCrSize ||
bufferData->GetYUVColorSpace().isNothing() ||
bufferData->GetYUVColorSpace().ref() != mData.mYUVColorSpace ||
bufferData->GetColorRange().isNothing() ||
bufferData->GetColorRange().ref() != mData.mColorRange ||
bufferData->GetStereoMode().isNothing() ||
bufferData->GetStereoMode().ref() != mData.mStereoMode) {
return false;
@ -122,6 +124,7 @@ YCbCrTextureClientAllocationHelper::Allocate(KnowsCompositor* aAllocator)
mData.mYSize, mData.mCbCrSize,
mData.mStereoMode,
mData.mYUVColorSpace,
mData.mColorRange,
mTextureFlags);
}

View file

@ -68,6 +68,15 @@ GPUVideoTextureHost::GetYUVColorSpace() const
return YUVColorSpace::UNKNOWN;
}
ColorRange
GPUVideoTextureHost::GetColorRange() const
{
if (mWrappedTextureHost) {
return mWrappedTextureHost->GetColorRange();
}
return ColorRange::UNKNOWN;
}
gfx::IntSize
GPUVideoTextureHost::GetSize() const
{

View file

@ -36,6 +36,7 @@ public:
}
virtual YUVColorSpace GetYUVColorSpace() const override;
virtual ColorRange GetColorRange() const override;
virtual gfx::IntSize GetSize() const override;

View file

@ -828,6 +828,16 @@ BufferTextureHost::GetYUVColorSpace() const
return YUVColorSpace::UNKNOWN;
}
ColorRange
BufferTextureHost::GetColorRange() const
{
if (mFormat == gfx::SurfaceFormat::YUV) {
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
return desc.colorRange();
}
return ColorRange::UNKNOWN;
}
bool
BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
{

View file

@ -420,6 +420,7 @@ public:
virtual gfx::SurfaceFormat GetReadFormat() const { return GetFormat(); }
virtual YUVColorSpace GetYUVColorSpace() const { return YUVColorSpace::UNKNOWN; }
virtual ColorRange GetColorRange() const { return ColorRange::UNKNOWN; }
/**
* Called during the transaction. The TextureSource may or may not be composited.
@ -672,6 +673,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const override;
virtual YUVColorSpace GetYUVColorSpace() const override;
virtual ColorRange GetColorRange() const override;
virtual gfx::IntSize GetSize() const override { return mSize; }

View file

@ -886,7 +886,8 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
return;
}
const float* yuvToRgb = gfxUtils::Get4x3YuvColorMatrix(ycbcrEffect->mYUVColorSpace);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x4XRowMajor(
ycbcrEffect->mYUVColorSpace, ycbcrEffect->mColorRange);
memcpy(&mPSConstants.yuvColorMatrix, yuvToRgb, sizeof(mPSConstants.yuvColorMatrix));
TextureSourceD3D11* sourceY = source->GetSubSource(Y)->AsSourceD3D11();

View file

@ -35,7 +35,7 @@ struct PixelShaderConstants
float layerColor[4];
float layerOpacity[4];
int blendConfig[4];
float yuvColorMatrix[3][4];
float yuvColorMatrix[4][4];
};
struct DeviceAttachmentsD3D11;

View file

@ -25,7 +25,7 @@ float fLayerOpacity : register(ps, c1);
// w = is premultiplied
uint4 iBlendConfig : register(ps, c2);
row_major float3x3 mYuvColorMatrix : register(ps, c3);
row_major float4x4 mYuvColorMatrix : register(ps, c3);
sampler sSampler : register(ps, s0);
@ -205,17 +205,14 @@ For [0,1] instead of [0,255], and to 5 places:
*/
float4 CalculateYCbCrColor(const float2 aTexCoords)
{
float3 yuv;
float4 color;
float4 yuv;
yuv.x = tY.Sample(sSampler, aTexCoords).r - 0.06275;
yuv.y = tCb.Sample(sSampler, aTexCoords).r - 0.50196;
yuv.z = tCr.Sample(sSampler, aTexCoords).r - 0.50196;
yuv.x = tY.Sample(sSampler, aTexCoords).r;
yuv.y = tCb.Sample(sSampler, aTexCoords).r;
yuv.z = tCr.Sample(sSampler, aTexCoords).r;
yuv.w = 1.0;
color.rgb = mul(mYuvColorMatrix, yuv);
color.a = 1.0f;
return color;
return mul(mYuvColorMatrix, yuv);
}
float4 YCbCrShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target

View file

@ -361,6 +361,7 @@ public:
// Bug 1305906 fixes YUVColorSpace handling
virtual YUVColorSpace GetYUVColorSpace() const override { return YUVColorSpace::BT601; }
virtual ColorRange GetColorRange() const override { return ColorRange::LIMITED; }
virtual bool Lock() override;

View file

@ -413,7 +413,8 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
}
const float* yuvToRgb = gfxUtils::Get4x3YuvColorMatrix(ycbcrEffect->mYUVColorSpace);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x4XRowMajor(
ycbcrEffect->mYUVColorSpace, ycbcrEffect->mColorRange);
d3d9Device->SetPixelShaderConstantF(CBmYuvColorMatrix, yuvToRgb, 3);
TextureSourceD3D9* sourceY = source->GetSubSource(Y)->AsSourceD3D9();

View file

@ -18,7 +18,7 @@ sampler s2DMask;
float fLayerOpacity;
float4 fLayerColor;
row_major float3x3 mYuvColorMatrix : register(ps, c1);
row_major float4x4 mYuvColorMatrix : register(ps, c1);
struct VS_INPUT {
float4 vPosition : POSITION;
@ -162,17 +162,14 @@ For [0,1] instead of [0,255], and to 5 places:
*/
float4 YCbCrShader(const VS_OUTPUT aVertex) : COLOR
{
float3 yuv;
float4 color;
float4 yuv;
yuv.x = tex2D(s2DY, aVertex.vTexCoords).a - 0.06275;
yuv.y = tex2D(s2DCb, aVertex.vTexCoords).a - 0.50196;
yuv.z = tex2D(s2DCr, aVertex.vTexCoords).a - 0.50196;
yuv.x = tY.Sample(sSampler, aTexCoords).r;
yuv.y = tCb.Sample(sSampler, aTexCoords).r;
yuv.z = tCr.Sample(sSampler, aTexCoords).r;
yuv.w = 1.0;
color.rgb = mul(mYuvColorMatrix, yuv);
color.a = 1.0f;
return color * fLayerOpacity;
return mul(mYuvColorMatrix, yuv);
}
float4 SolidColorShader(const VS_OUTPUT aVertex) : COLOR

View file

@ -368,6 +368,7 @@ public:
// Bug 1305906 fixes YUVColorSpace handling
virtual YUVColorSpace GetYUVColorSpace() const override { return YUVColorSpace::BT601; }
virtual ColorRange GetColorRange() const override { return ColorRange::LIMITED; }
virtual bool Lock() override;
virtual void Unlock() override;

View file

@ -7,6 +7,7 @@ using nsIntRegion from "nsRegion.h";
using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
using mozilla::StereoMode from "ImageTypes.h";
using mozilla::YUVColorSpace from "ImageTypes.h";
using mozilla::ColorRange from "ImageTypes.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
@ -104,6 +105,7 @@ struct YCbCrDescriptor {
uint32_t crOffset;
StereoMode stereoMode;
YUVColorSpace yUVColorSpace;
ColorRange colorRange;
bool hasIntermediateBuffer;
};

View file

@ -120,6 +120,7 @@ SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
mTextureClient = TextureClient::CreateForYCbCrWithBufferSize(mCompositable->GetForwarder(),
size,
YUVColorSpace::BT601,
ColorRange::LIMITED,
mCompositable->GetTextureFlags());
// get new buffer _without_ setting mBuffer.
@ -165,7 +166,8 @@ SharedPlanarYCbCrImage::AdoptData(const Data &aData)
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())->SetDesciptor(
YCbCrDescriptor(aData.mYSize, aData.mCbCrSize, yOffset, cbOffset, crOffset,
aData.mStereoMode, aData.mYUVColorSpace, hasIntermediateBuffer)
aData.mStereoMode, aData.mYUVColorSpace, aData.mColorRange,
hasIntermediateBuffer)
);
return true;
@ -222,6 +224,7 @@ SharedPlanarYCbCrImage::Allocate(PlanarYCbCrData& aData)
mData.mPicSize = aData.mPicSize;
mData.mStereoMode = aData.mStereoMode;
mData.mYUVColorSpace = aData.mYUVColorSpace;
mData.mColorRange = aData.mColorRange;
// those members are not always equal to aData's, due to potentially different
// packing.
mData.mYSkip = 0;

View file

@ -1303,7 +1303,7 @@ CompositorOGL::DrawGeometry(const Geometry& aGeometry,
program->SetYCbCrTextureUnits(Y, Cb, Cr);
program->SetTextureTransform(Matrix4x4());
program->SetYUVColorSpace(effectYCbCr->mYUVColorSpace);
program->SetYUVColorSpace(effectYCbCr->mYUVColorSpace, effectYCbCr->mColorRange);
if (maskType != MaskType::MaskNone) {
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE3, maskQuadTransform);

View file

@ -377,7 +377,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
fs << "uniform sampler2D uYTexture;" << endl;
fs << "uniform sampler2D uCbTexture;" << endl;
fs << "uniform sampler2D uCrTexture;" << endl;
fs << "uniform mat3 uYuvColorMatrix;" << endl;
fs << "uniform mat4 uYuvColorMatrix;" << endl;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_NV12) {
fs << "uniform " << sampler2D << " uYTexture;" << endl;
fs << "uniform " << sampler2D << " uCbTexture;" << endl;
@ -436,12 +436,8 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
}
}
fs << " y = y - 0.06275;" << endl;
fs << " cb = cb - 0.50196;" << endl;
fs << " cr = cr - 0.50196;" << endl;
fs << " vec3 yuv = vec3(y, cb, cr);" << endl;
fs << " color.rgb = uYuvColorMatrix * yuv;" << endl;
fs << " color.a = 1.0;" << endl;
fs << " vec4 yuv = vec4(y, cb, cr, 1.0);" << endl;
fs << " color = uYuvColorMatrix * yuv;" << endl;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
fs << " COLOR_PRECISION vec3 onBlack = " << texture2D << "(uBlackTexture, coord * uTexCoordMultiplier).rgb;" << endl;
@ -964,10 +960,10 @@ ShaderProgramOGL::SetBlurRadius(float aRX, float aRY)
}
void
ShaderProgramOGL::SetYUVColorSpace(YUVColorSpace aYUVColorSpace)
ShaderProgramOGL::SetYUVColorSpace(YUVColorSpace aYUVColorSpace, ColorRange aColorRange)
{
const float* yuvToRgb = gfxUtils::Get3x3YuvColorMatrix(aYUVColorSpace);
SetMatrix3fvUniform(KnownUniform::YuvColorMatrix, yuvToRgb);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x4ColumnMajor(aYUVColorSpace, aColorRange);
SetMatrixUniform(KnownUniform::YuvColorMatrix, yuvToRgb);
}
} // namespace layers

View file

@ -479,7 +479,7 @@ public:
SetUniform(KnownUniform::CbCrTexCoordMultiplier, 2, f);
}
void SetYUVColorSpace(YUVColorSpace aYUVColorSpace);
void SetYUVColorSpace(YUVColorSpace aYUVColorSpace, ColorRange aColorRange);
// Set whether we want the component alpha shader to return the color
// vector (pass 1, false) or the alpha vector (pass2, true). With support

View file

@ -292,6 +292,7 @@ TEST(Layers, TextureYCbCrSerialization) {
RefPtr<TextureClient> client = TextureClient::CreateForYCbCr(imageBridge, clientData.mYSize, clientData.mCbCrSize,
StereoMode::MONO, YUVColorSpace::BT601,
ColorRange::LIMITED,
TextureFlags::DEALLOCATE_CLIENT);
TestTextureClientYCbCr(client, clientData);

View file

@ -1084,59 +1084,71 @@ gfxUtils::EncodeSourceSurface(SourceSurface* aSurface,
// https://jdashg.github.io/misc/colors/from-coeffs.html
const float kBT601NarrowYCbCrToRGB_RowMajor[16] = {
1.16438f, 0.00000f, 1.59603f, -0.87420f, 1.16438f, -0.39176f,
-0.81297f, 0.53167f, 1.16438f, 2.01723f, 0.00000f, -1.08563f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
1.16438f, 0.00000f, 1.59603f, -0.87420f,
1.16438f, -0.39176f, -0.81297f, 0.53167f,
1.16438f, 2.01723f, 0.00000f, -1.08563f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
const float kBT601FullYCbCrToRGB_RowMajor[16] = {
1.00000f, 0.00000f, 1.40752f, -0.70652f,
1.00000f, -0.34549f, -0.71695f, 0.53330f,
1.00000f, 1.77898f, -0.00000f, -0.89298f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
const float kBT709NarrowYCbCrToRGB_RowMajor[16] = {
1.16438f, 0.00000f, 1.79274f, -0.97295f, 1.16438f, -0.21325f,
-0.53291f, 0.30148f, 1.16438f, 2.11240f, 0.00000f, -1.13340f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
1.16438f, 0.00000f, 1.79274f, -0.97295f,
1.16438f, -0.21325f, -0.53291f, 0.30148f,
1.16438f, 2.11240f, 0.00000f, -1.13340f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
const float kBT709FullYCbCrToRGB_RowMajor[16] = {
1.00000f, 0.00000f, 1.58100f, -0.79360f,
1.00000f, -0.18806f, -0.46997f, 0.33030f,
1.00000f, 1.86291f, 0.00000f, -0.93511f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
const float kIdentityNarrowYCbCrToRGB_RowMajor[16] = {
0.00000f, 0.00000f, 1.00000f, 0.00000f, 1.00000f, 0.00000f,
0.00000f, 0.00000f, 0.00000f, 1.00000f, 0.00000f, 0.00000f,
0.00000f, 0.00000f, 0.00000f, 1.00000f};
/* static */ const float*
gfxUtils::Get4x3YuvColorMatrix(YUVColorSpace aYUVColorSpace)
gfxUtils::YuvToRgbMatrix4x4XRowMajor(YUVColorSpace aYUVColorSpace, ColorRange aColorRange)
{
#define X(x) \
{ x[0], x[1], x[2], 0.0f, x[4], x[5], x[6], 0.0f, x[8], x[9], x[10], 0.0f }
static const float rec601[12] = X(kBT601NarrowYCbCrToRGB_RowMajor);
static const float rec709[12] = X(kBT709NarrowYCbCrToRGB_RowMajor);
static const float identity[12] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
#undef X
switch (aYUVColorSpace) {
case YUVColorSpace::BT601:
return rec601;
return aColorRange == ColorRange::LIMITED ? kBT601NarrowYCbCrToRGB_RowMajor
: kBT601FullYCbCrToRGB_RowMajor;
case YUVColorSpace::BT709:
return rec709;
return aColorRange == ColorRange::LIMITED ? kBT709NarrowYCbCrToRGB_RowMajor
: kBT709FullYCbCrToRGB_RowMajor;
case YUVColorSpace::IDENTITY:
return identity;
return kIdentityNarrowYCbCrToRGB_RowMajor;
default:
MOZ_CRASH("Bad YUVColorSpace");
}
}
/* static */ const float*
gfxUtils::Get3x3YuvColorMatrix(YUVColorSpace aYUVColorSpace)
gfxUtils::YuvToRgbMatrix4x4ColumnMajor(YUVColorSpace aYUVColorSpace, ColorRange aColorRange)
{
#define X(x) \
{ x[0], x[4], x[8], x[1], x[5], x[9], x[2], x[6], x[10] }
{ x[0], x[4], x[8], 0.0f, \
x[1], x[5], x[9], 0.0f, \
x[2], x[6], x[10], 0.0f, \
x[3], x[7], x[11], 1.0f }
static const float rec601[9] = X(kBT601NarrowYCbCrToRGB_RowMajor);
static const float rec709[9] = X(kBT709NarrowYCbCrToRGB_RowMajor);
static const float identity[9] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
static const float rec601Narrow[16] = X(kBT601NarrowYCbCrToRGB_RowMajor);
static const float rec601Full[16] = X(kBT601FullYCbCrToRGB_RowMajor);
static const float rec709Narrow[16] = X(kBT709NarrowYCbCrToRGB_RowMajor);
static const float rec709Full[16] = X(kBT709FullYCbCrToRGB_RowMajor);
static const float identity[16] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
#undef X
switch (aYUVColorSpace) {
case YUVColorSpace::BT601:
return rec601;
return aColorRange == ColorRange::LIMITED ? rec601Narrow : rec601Full;
case YUVColorSpace::BT709:
return rec709;
return aColorRange == ColorRange::LIMITED ? rec709Narrow : rec709Full;
case YUVColorSpace::IDENTITY:
return identity;
default:

View file

@ -43,6 +43,7 @@ public:
typedef mozilla::gfx::SurfaceFormat SurfaceFormat;
typedef mozilla::image::ImageRegion ImageRegion;
typedef mozilla::YUVColorSpace YUVColorSpace;
typedef mozilla::ColorRange ColorRange;
/*
* Premultiply or Unpremultiply aSourceSurface, writing the result
@ -139,9 +140,11 @@ public:
/**
* Get array of yuv to rgb conversion matrix.
*/
static const float* Get4x3YuvColorMatrix(YUVColorSpace aYUVColorSpace);
static const float* YuvToRgbMatrix4x4XRowMajor(YUVColorSpace aYUVColorSpace,
ColorRange aColorRange);
static const float* Get3x3YuvColorMatrix(YUVColorSpace aYUVColorSpace);
static const float* YuvToRgbMatrix4x4ColumnMajor(YUVColorSpace aYUVColorSpace,
ColorRange aColorRange);
/**
* Creates a copy of aSurface, but having the SurfaceFormat aFormat.

View file

@ -119,6 +119,7 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
aStride,
yuvtype,
aData.mYUVColorSpace,
aData.mColorRange,
FILTER_BILINEAR);
} else { // no prescale
#if defined(HAVE_YCBCR_TO_RGB565)
@ -149,7 +150,8 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
aData.mCbCrStride,
aStride,
yuvtype,
aData.mYUVColorSpace);
aData.mYUVColorSpace,
aData.mColorRange);
}
}

View file

@ -11,6 +11,7 @@
#include "scale_yuv_argb.h"
#include "libyuv/convert_argb.h"
#include "libyuv/scale.h"
#include <assert.h>
@ -20,12 +21,32 @@
#include "libyuv/row.h"
#include "libyuv/scale_row.h"
#include "libyuv/video_common.h"
#include "mozilla/Assertions.h"
#ifdef __cplusplus
namespace libyuv {
extern "C" {
#endif
const YuvConstants* GetYUVConstants(mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range)
{
switch (yuv_color_space) {
case mozilla::YUVColorSpace::BT709:
return color_range == mozilla::ColorRange::LIMITED
? &libyuv::kYuvH709Constants
: &libyuv::kYuvF709Constants;
default:
MOZ_FALLTHROUGH_ASSERT("Unsupported YUVColorSpace");
case mozilla::YUVColorSpace::BT601:
return color_range == mozilla::ColorRange::LIMITED
? &libyuv::kYuvI601Constants
: &libyuv::kYuvJPEGConstants;
}
}
// YUV to RGB conversion and scaling functions were implemented by referencing
// scale_argb.cc
//
@ -68,21 +89,21 @@ struct YUVBuferIter {
int src_stride_y;
int src_stride_u;
int src_stride_v;
const uint8* src_y;
const uint8* src_u;
const uint8* src_v;
const uint8_t* src_y;
const uint8_t* src_u;
const uint8_t* src_v;
uint32 src_fourcc;
uint32_t src_fourcc;
const struct YuvConstants* yuvconstants;
int y_index;
const uint8* src_row_y;
const uint8* src_row_u;
const uint8* src_row_v;
const uint8_t* src_row_y;
const uint8_t* src_row_u;
const uint8_t* src_row_v;
void (*YUVToARGBRow)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void (*YUVToARGBRow)(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
const struct YuvConstants* yuvconstants,
int width);
void (*MoveTo)(YUVBuferIter& iter, int y_index);
@ -202,21 +223,20 @@ static void YUVBuferIter_MoveToNextRowForI420(YUVBuferIter& iter) {
iter.y_index++;
}
static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8* argb_row) {
static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8_t* argb_row) {
iter.YUVToARGBRow(iter.src_row_y, iter.src_row_u, iter.src_row_v, argb_row, iter.yuvconstants, iter.src_width);
}
void YUVBuferIter_Init(YUVBuferIter& iter, uint32 src_fourcc, mozilla::YUVColorSpace yuv_color_space) {
void YUVBuferIter_Init(YUVBuferIter& iter,
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
iter.src_fourcc = src_fourcc;
iter.y_index = 0;
iter.src_row_y = iter.src_y;
iter.src_row_u = iter.src_u;
iter.src_row_v = iter.src_v;
if (yuv_color_space == mozilla::YUVColorSpace::BT709) {
iter.yuvconstants = &kYuvH709Constants;
} else {
iter.yuvconstants = &kYuvI601Constants;
}
iter.yuvconstants = GetYUVConstants(yuv_color_space, color_range);
if (src_fourcc == FOURCC_I444) {
YUVBuferIter_InitI444(iter);
@ -243,20 +263,21 @@ static void ScaleYUVToARGBDown2(int src_width, int src_height,
int src_stride_u,
int src_stride_v,
int dst_stride_argb,
const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* dst_argb,
const uint8_t* src_y,
const uint8_t* src_u,
const uint8_t* src_v,
uint8_t* dst_argb,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
int j;
// Allocate 2 rows of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row;
uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize;
YUVBuferIter iter;
@ -268,10 +289,10 @@ static void ScaleYUVToARGBDown2(int src_width, int src_height,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride,
uint8* dst_argb, int dst_width) =
void (*ScaleARGBRowDown2)(const uint8_t* src_argb, ptrdiff_t src_stride,
uint8_t* dst_argb, int dst_width) =
filtering == kFilterNone ? ScaleARGBRowDown2_C :
(filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C :
ScaleARGBRowDown2Box_C);
@ -380,24 +401,25 @@ static void ScaleYUVToARGBDownEven(int src_width, int src_height,
int src_stride_u,
int src_stride_v,
int dst_stride_argb,
const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* dst_argb,
const uint8_t* src_y,
const uint8_t* src_u,
const uint8_t* src_v,
uint8_t* dst_argb,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
int j;
// Allocate 2 rows of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row;
uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize;
int col_step = dx >> 16;
void (*ScaleARGBRowDownEven)(const uint8* src_argb, ptrdiff_t src_stride,
int src_step, uint8* dst_argb, int dst_width) =
void (*ScaleARGBRowDownEven)(const uint8_t* src_argb, ptrdiff_t src_stride,
int src_step, uint8_t* dst_argb, int dst_width) =
filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C;
assert(IS_ALIGNED(src_width, 2));
assert(IS_ALIGNED(src_height, 2));
@ -434,7 +456,7 @@ static void ScaleYUVToARGBDownEven(int src_width, int src_height,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
const int dyi = dy >> 16;
int lastyi = yi;
@ -501,24 +523,25 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
int src_stride_u,
int src_stride_v,
int dst_stride_argb,
const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* dst_argb,
const uint8_t* src_y,
const uint8_t* src_u,
const uint8_t* src_v,
uint8_t* dst_argb,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
void (*InterpolateRow)(uint8_t* dst_argb, const uint8_t* src_argb,
ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
InterpolateRow_C;
void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb,
void (*ScaleARGBFilterCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) =
(src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C;
int64 xlast = x + (int64)(dst_width - 1) * dx;
int64 xl = (dx >= 0) ? x : xlast;
int64 xr = (dx >= 0) ? xlast : x;
int64_t xlast = x + (int64_t)(dst_width - 1) * dx;
int64_t xl = (dx >= 0) ? x : xlast;
int64_t xr = (dx >= 0) ? xlast : x;
int clip_src_width;
xl = (xl >> 16) & ~3; // Left edge aligned.
xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels.
@ -533,7 +556,7 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
// Allocate 2 row of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15;
align_buffer_64(argb_cnv_row, kRowSize * 2);
uint8* argb_cnv_rowptr = argb_cnv_row;
uint8_t* argb_cnv_rowptr = argb_cnv_row;
int argb_cnv_rowstride = kRowSize;
#if defined(HAS_INTERPOLATEROW_SSSE3)
@ -594,7 +617,7 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
iter.MoveTo(iter, yi);
// TODO(fbarchard): Consider not allocating row buffer for kFilterLinear.
@ -670,19 +693,20 @@ static void ScaleYUVToARGBBilinearUp(int src_width, int src_height,
int src_stride_u,
int src_stride_v,
int dst_stride_argb,
const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* dst_argb,
const uint8_t* src_y,
const uint8_t* src_u,
const uint8_t* src_v,
uint8_t* dst_argb,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
void (*InterpolateRow)(uint8_t* dst_argb, const uint8_t* src_argb,
ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
InterpolateRow_C;
void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb,
void (*ScaleARGBFilterCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) =
filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C;
const int max_y = (src_height - 1) << 16;
@ -774,14 +798,14 @@ static void ScaleYUVToARGBBilinearUp(int src_width, int src_height,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
iter.MoveTo(iter, yi);
// Allocate 2 rows of ARGB.
const int kRowSize = (dst_width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
uint8* rowptr = row;
uint8_t* rowptr = row;
int rowstride = kRowSize;
int lastyi = yi;
@ -855,15 +879,16 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
int src_stride_u,
int src_stride_v,
int dst_stride_argb,
const uint8* src_y,
const uint8* src_u,
const uint8* src_v,
uint8* dst_argb,
const uint8_t* src_y,
const uint8_t* src_u,
const uint8_t* src_v,
uint8_t* dst_argb,
int x, int dx, int y, int dy,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range) {
int j;
void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb,
void (*ScaleARGBCols)(uint8_t* dst_argb, const uint8_t* src_argb,
int dst_width, int x, int dx) =
(src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C;
@ -903,7 +928,7 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
iter.MoveTo(iter, yi);
int lasty = yi;
@ -923,14 +948,15 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
free_aligned_buffer_64(argb_cnv_row);
}
static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
static void YUVToARGBCopy(const uint8_t* src_y, int src_stride_y,
const uint8_t* src_u, int src_stride_u,
const uint8_t* src_v, int src_stride_v,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space)
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range)
{
YUVBuferIter iter;
iter.src_width = src_width;
@ -941,7 +967,7 @@ static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
iter.src_y = src_y;
iter.src_u = src_u;
iter.src_v = src_v;
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space);
YUVBuferIter_Init(iter, src_fourcc, yuv_color_space, color_range);
for (int j = 0; j < dst_height; ++j) {
YUVBuferIter_ConvertToARGBRow(iter, dst_argb);
@ -950,15 +976,16 @@ static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
}
}
static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
static void ScaleYUVToARGB(const uint8_t* src_y, int src_stride_y,
const uint8_t* src_u, int src_stride_u,
const uint8_t* src_v, int src_stride_v,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space)
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range)
{
// Initial source x/y coordinate and step values as 16.16 fixed point.
int x = 0;
@ -995,7 +1022,8 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
x, dx, y, dy,
filtering,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return;
}
ScaleYUVToARGBDownEven(src_width, src_height,
@ -1011,7 +1039,8 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
x, dx, y, dy,
filtering,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return;
}
// Optimized odd scale down. ie 3, 5, 7, 9x.
@ -1026,7 +1055,8 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
dst_argb, dst_stride_argb,
dst_width, dst_height,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return;
}
}
@ -1046,7 +1076,8 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
x, dx, y, dy,
filtering,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return;
}
if (filtering) {
@ -1063,7 +1094,8 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
x, dx, y, dy,
filtering,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return;
}
ScaleYUVToARGBSimple(src_width, src_height,
@ -1078,10 +1110,11 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
dst_argb,
x, dx, y, dy,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
}
bool IsConvertSupported(uint32 src_fourcc)
bool IsConvertSupported(uint32_t src_fourcc)
{
if (src_fourcc == FOURCC_I444 ||
src_fourcc == FOURCC_I422 ||
@ -1092,13 +1125,14 @@ bool IsConvertSupported(uint32 src_fourcc)
}
LIBYUV_API
int YUVToARGBScale(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint32 src_fourcc,
int YUVToARGBScale(const uint8_t* src_y, int src_stride_y,
const uint8_t* src_u, int src_stride_u,
const uint8_t* src_v, int src_stride_v,
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,
enum FilterMode filtering)
{
@ -1118,7 +1152,8 @@ int YUVToARGBScale(const uint8* src_y, int src_stride_y,
dst_width, dst_height,
filtering,
src_fourcc,
yuv_color_space);
yuv_color_space,
color_range);
return 0;
}

View file

@ -12,6 +12,7 @@
#define INCLUDE_LIBYUV_SCALE_YUV_ARGB_H_
#include "libyuv/basic_types.h"
#include "libyuv/row.h" // For YuvConstants
#include "libyuv/scale.h" // For FilterMode
#include "ImageTypes.h" // For YUVColorSpace
@ -21,13 +22,18 @@ namespace libyuv {
extern "C" {
#endif
int YUVToARGBScale(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint32 src_fourcc,
const YuvConstants* GetYUVConstants(mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range);
int YUVToARGBScale(const uint8_t* src_y, int src_stride_y,
const uint8_t* src_u, int src_stride_u,
const uint8_t* src_v, int src_stride_v,
uint32_t src_fourcc,
mozilla::YUVColorSpace yuv_color_space,
mozilla::ColorRange color_range,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
uint8_t* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,
enum FilterMode filtering);

View file

@ -71,10 +71,10 @@ typedef void (*yuv2rgb565_row_scale_nearest_func)(
extern "C" void ScaleYCbCr42xToRGB565_BilinearY_Row_NEON(
const yuv2rgb565_row_scale_bilinear_ctx *ctx, int dither);
void __attribute((noinline)) yuv42x_to_rgb565_row_neon(uint16 *dst,
const uint8 *y,
const uint8 *u,
const uint8 *v,
void __attribute((noinline)) yuv42x_to_rgb565_row_neon(uint16_t *dst,
const uint8_t *y,
const uint8_t *u,
const uint8_t *v,
int n,
int oddflag);
@ -581,10 +581,10 @@ bool IsScaleYCbCrToRGB565Fast(int source_x0,
void yuv_to_rgb565_row_c(uint16 *dst,
const uint8 *y,
const uint8 *u,
const uint8 *v,
void yuv_to_rgb565_row_c(uint16_t *dst,
const uint8_t *y,
const uint8_t *u,
const uint8_t *v,
int x_shift,
int pic_x,
int pic_width)
@ -599,10 +599,10 @@ void yuv_to_rgb565_row_c(uint16 *dst,
}
}
void ConvertYCbCrToRGB565(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ConvertYCbCrToRGB565(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int pic_x,
int pic_y,
int pic_width,
@ -625,7 +625,7 @@ void ConvertYCbCrToRGB565(const uint8* y_buf,
int uvoffs;
yoffs = y_pitch * (pic_y+i) + pic_x;
uvoffs = uv_pitch * ((pic_y+i)>>y_shift) + (pic_x>>x_shift);
yuv42x_to_rgb565_row_neon((uint16*)(rgb_buf + rgb_pitch * i),
yuv42x_to_rgb565_row_neon((uint16_t*)(rgb_buf + rgb_pitch * i),
y_buf + yoffs,
u_buf + uvoffs,
v_buf + uvoffs,
@ -641,7 +641,7 @@ void ConvertYCbCrToRGB565(const uint8* y_buf,
int uvoffs;
yoffs = y_pitch * (pic_y+i);
uvoffs = uv_pitch * ((pic_y+i)>>y_shift);
yuv_to_rgb565_row_c((uint16*)(rgb_buf + rgb_pitch * i),
yuv_to_rgb565_row_c((uint16_t*)(rgb_buf + rgb_pitch * i),
y_buf + yoffs,
u_buf + uvoffs,
v_buf + uvoffs,

View file

@ -17,10 +17,10 @@ namespace gfx {
#ifdef HAVE_YCBCR_TO_RGB565
// Convert a frame of YUV to 16 bit RGB565.
void ConvertYCbCrToRGB565(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
void ConvertYCbCrToRGB565(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
uint8_t* rgbframe,
int pic_x,
int pic_y,
int pic_width,

View file

@ -82,10 +82,10 @@ void GBRPlanarToARGB(const uint8_t* src_y, int y_pitch,
}
// Convert a frame of YUV to 32 bit ARGB.
void ConvertYCbCrToRGB32(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ConvertYCbCrToRGB32(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int pic_x,
int pic_y,
int pic_width,
@ -94,7 +94,8 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
int uv_pitch,
int rgb_pitch,
YUVType yuv_type,
YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space,
ColorRange color_range) {
// Deprecated function's conversion is accurate.
@ -107,7 +108,8 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
// See Bug 1256475.
bool use_deprecated = gfxPrefs::YCbCrAccurateConversion() ||
(supports_mmx() && supports_sse() && !supports_sse3() &&
yuv_color_space == YUVColorSpace::BT601);
yuv_color_space == YUVColorSpace::BT601 &&
color_range == ColorRange::LIMITED);
// The deprecated function only support BT601.
// See Bug 1210357.
if (yuv_color_space != YUVColorSpace::BT601) {
@ -119,63 +121,61 @@ void ConvertYCbCrToRGB32(const uint8* y_buf,
y_pitch, uv_pitch, rgb_pitch, yuv_type);
return;
}
if (yuv_type == YV24) {
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x;
const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x;
if (yuv_color_space == YUVColorSpace::IDENTITY) {
// Special case for RGB image
GBRPlanarToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
rgb_buf, rgb_pitch, pic_width, pic_height);
return;
} else {
DebugOnly<int> err = libyuv::I444ToARGB(src_y, y_pitch,
src_u, uv_pitch,
src_v, uv_pitch,
rgb_buf, rgb_pitch,
pic_width, pic_height);
MOZ_ASSERT(!err);
decltype(libyuv::I420ToARGBMatrix)* fConvertYUVToARGB = nullptr;
const uint8_t* src_y = nullptr;
const uint8_t* src_u = nullptr;
const uint8_t* src_v = nullptr;
switch (yuv_type) {
case YV24: {
src_y = y_buf + y_pitch * pic_y + pic_x;
src_u = u_buf + uv_pitch * pic_y + pic_x;
src_v = v_buf + uv_pitch * pic_y + pic_x;
if (yuv_color_space == YUVColorSpace::IDENTITY) {
// Special case for RGB image.
GBRPlanarToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
rgb_buf, rgb_pitch, pic_width, pic_height);
return;
}
fConvertYUVToARGB = libyuv::I444ToARGBMatrix;
break;
}
} else if (yuv_type == YV16) {
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x / 2;
const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x / 2;
DebugOnly<int> err = libyuv::I422ToARGB(src_y, y_pitch,
src_u, uv_pitch,
src_v, uv_pitch,
rgb_buf, rgb_pitch,
pic_width, pic_height);
MOZ_ASSERT(!err);
} else {
MOZ_ASSERT(yuv_type == YV12);
const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
const uint8* src_u = u_buf + (uv_pitch * pic_y + pic_x) / 2;
const uint8* src_v = v_buf + (uv_pitch * pic_y + pic_x) / 2;
if (yuv_color_space == YUVColorSpace::BT709) {
DebugOnly<int> err = libyuv::H420ToARGB(src_y, y_pitch,
src_u, uv_pitch,
src_v, uv_pitch,
rgb_buf, rgb_pitch,
pic_width, pic_height);
MOZ_ASSERT(!err);
} else {
MOZ_ASSERT(yuv_color_space == YUVColorSpace::BT601);
DebugOnly<int> err = libyuv::I420ToARGB(src_y, y_pitch,
src_u, uv_pitch,
src_v, uv_pitch,
rgb_buf, rgb_pitch,
pic_width, pic_height);
MOZ_ASSERT(!err);
case YV16: {
src_y = y_buf + y_pitch * pic_y + pic_x;
src_u = u_buf + uv_pitch * pic_y + pic_x / 2;
src_v = v_buf + uv_pitch * pic_y + pic_x / 2;
fConvertYUVToARGB = libyuv::I422ToARGBMatrix;
break;
}
case YV12: {
src_y = y_buf + y_pitch * pic_y + pic_x;
src_u = u_buf + (uv_pitch * pic_y + pic_x) / 2;
src_v = v_buf + (uv_pitch * pic_y + pic_x) / 2;
fConvertYUVToARGB = libyuv::I420ToARGBMatrix;
break;
}
default:
MOZ_ASSERT_UNREACHABLE("Unsupported YUV type");
}
auto yuv_constant = libyuv::GetYUVConstants(yuv_color_space, color_range);
DebugOnly<int> err =
fConvertYUVToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
rgb_buf, rgb_pitch, yuv_constant, pic_width, pic_height);
MOZ_ASSERT(!err);
}
// Convert a frame of YUV to 32 bit ARGB.
void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ConvertYCbCrToRGB32_deprecated(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int pic_x,
int pic_y,
int pic_width,
@ -195,10 +195,10 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf,
int x_width = odd_pic_x ? pic_width - 1 : pic_width;
for (int y = pic_y; y < pic_height + pic_y; ++y) {
uint8* rgb_row = rgb_buf + (y - pic_y) * rgb_pitch;
const uint8* y_ptr = y_buf + y * y_pitch + pic_x;
const uint8* u_ptr = u_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
const uint8* v_ptr = v_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
uint8_t* rgb_row = rgb_buf + (y - pic_y) * rgb_pitch;
const uint8_t* y_ptr = y_buf + y * y_pitch + pic_x;
const uint8_t* u_ptr = u_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
const uint8_t* v_ptr = v_buf + (y >> y_shift) * uv_pitch + (pic_x >> x_shift);
if (odd_pic_x) {
// Handle the single odd pixel manually and use the
@ -235,11 +235,11 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* y_buf,
}
// C version does 8 at a time to mimic MMX code
static void FilterRows_C(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
static void FilterRows_C(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) {
int y1_fraction = source_y_fraction;
int y0_fraction = 256 - y1_fraction;
uint8* end = ybuf + source_width;
uint8_t* end = ybuf + source_width;
do {
ybuf[0] = (y0_ptr[0] * y0_fraction + y1_ptr[0] * y1_fraction) >> 8;
ybuf[1] = (y0_ptr[1] * y0_fraction + y1_ptr[1] * y1_fraction) >> 8;
@ -256,17 +256,17 @@ static void FilterRows_C(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
}
#ifdef MOZILLA_MAY_SUPPORT_MMX
void FilterRows_MMX(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
void FilterRows_MMX(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction);
#endif
#ifdef MOZILLA_MAY_SUPPORT_SSE2
void FilterRows_SSE2(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
void FilterRows_SSE2(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction);
#endif
static inline void FilterRows(uint8* ybuf, const uint8* y0_ptr,
const uint8* y1_ptr, int source_width,
static inline void FilterRows(uint8_t* ybuf, const uint8_t* y0_ptr,
const uint8_t* y1_ptr, int source_width,
int source_y_fraction) {
#ifdef MOZILLA_MAY_SUPPORT_SSE2
if (mozilla::supports_sse2()) {
@ -287,10 +287,10 @@ static inline void FilterRows(uint8* ybuf, const uint8* y0_ptr,
// Scale a frame of YUV to 32 bit ARGB.
void ScaleYCbCrToRGB32(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYCbCrToRGB32(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int source_width,
int source_height,
int width,
@ -300,6 +300,7 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
int rgb_pitch,
YUVType yuv_type,
YUVColorSpace yuv_color_space,
ColorRange color_range,
ScaleFilter filter) {
bool use_deprecated = gfxPrefs::YCbCrAccurateConversion() ||
@ -307,7 +308,8 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
// libyuv does not support SIMD scaling on win 64bit. See Bug 1295927.
supports_sse3() ||
#endif
(supports_mmx() && supports_sse() && !supports_sse3());
(supports_mmx() && supports_sse() && !supports_sse3() &&
color_range == ColorRange::LIMITED);
// The deprecated function only support BT601.
// See Bug 1210357.
if (yuv_color_space != YUVColorSpace::BT601) {
@ -327,7 +329,9 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
}
if (yuv_type == YV24 && yuv_color_space == YUVColorSpace::IDENTITY) {
auto buffer = MakeUnique<uint8[]>(source_width * source_height * 4);
MOZ_ASSERT(color_range == ColorRange::LIMITED,
"Identity (aka RGB) with limited color range is unsupporeted");
auto buffer = MakeUnique<uint8_t[]>(source_width * source_height * 4);
auto buffer_pitch = source_width * 4;
GBRPlanarToARGB(y_buf, y_pitch, u_buf, uv_pitch, v_buf, uv_pitch,
buffer.get(), buffer_pitch, source_width, source_height);
@ -347,6 +351,7 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
v_buf, uv_pitch,
FourCCFromYUVType(yuv_type),
yuv_color_space,
color_range,
source_width, source_height,
rgb_buf, rgb_pitch,
width, height,
@ -356,10 +361,10 @@ void ScaleYCbCrToRGB32(const uint8* y_buf,
}
// Scale a frame of YUV to 32 bit ARGB.
void ScaleYCbCrToRGB32_deprecated(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYCbCrToRGB32_deprecated(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int source_width,
int source_height,
int width,
@ -443,39 +448,39 @@ void ScaleYCbCrToRGB32_deprecated(const uint8* y_buf,
// Need padding because FilterRows() will write 1 to 16 extra pixels
// after the end for SSE2 version.
uint8 yuvbuf[16 + kFilterBufferSize * 3 + 16];
uint8* ybuf =
reinterpret_cast<uint8*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
uint8* ubuf = ybuf + kFilterBufferSize;
uint8* vbuf = ubuf + kFilterBufferSize;
uint8_t yuvbuf[16 + kFilterBufferSize * 3 + 16];
uint8_t* ybuf =
reinterpret_cast<uint8_t*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
uint8_t* ubuf = ybuf + kFilterBufferSize;
uint8_t* vbuf = ubuf + kFilterBufferSize;
// TODO(fbarchard): Fixed point math is off by 1 on negatives.
int yscale_fixed = (source_height << kFractionBits) / height;
// TODO(fbarchard): Split this into separate function for better efficiency.
for (int y = 0; y < height; ++y) {
uint8* dest_pixel = rgb_buf + y * rgb_pitch;
uint8_t* dest_pixel = rgb_buf + y * rgb_pitch;
int source_y_subpixel = (y * yscale_fixed);
if (yscale_fixed >= (kFractionMax * 2)) {
source_y_subpixel += kFractionMax / 2; // For 1/2 or less, center filter.
}
int source_y = source_y_subpixel >> kFractionBits;
const uint8* y0_ptr = y_buf + source_y * y_pitch;
const uint8* y1_ptr = y0_ptr + y_pitch;
const uint8_t* y0_ptr = y_buf + source_y * y_pitch;
const uint8_t* y1_ptr = y0_ptr + y_pitch;
const uint8* u0_ptr = u_buf + (source_y >> y_shift) * uv_pitch;
const uint8* u1_ptr = u0_ptr + uv_pitch;
const uint8* v0_ptr = v_buf + (source_y >> y_shift) * uv_pitch;
const uint8* v1_ptr = v0_ptr + uv_pitch;
const uint8_t* u0_ptr = u_buf + (source_y >> y_shift) * uv_pitch;
const uint8_t* u1_ptr = u0_ptr + uv_pitch;
const uint8_t* v0_ptr = v_buf + (source_y >> y_shift) * uv_pitch;
const uint8_t* v1_ptr = v0_ptr + uv_pitch;
// vertical scaler uses 16.8 fixed point
int source_y_fraction = (source_y_subpixel & kFractionMask) >> 8;
int source_uv_fraction =
((source_y_subpixel >> y_shift) & kFractionMask) >> 8;
const uint8* y_ptr = y0_ptr;
const uint8* u_ptr = u0_ptr;
const uint8* v_ptr = v0_ptr;
const uint8_t* y_ptr = y0_ptr;
const uint8_t* u_ptr = u0_ptr;
const uint8_t* v_ptr = v0_ptr;
// Apply vertical filtering if necessary.
// TODO(fbarchard): Remove memcpy when not necessary.
if (filter & mozilla::gfx::FILTER_BILINEAR_V) {

View file

@ -45,10 +45,10 @@ YUVType TypeFromSize(int ywidth, int yheight, int cbcrwidth, int cbcrheight);
// Convert a frame of YUV to 32 bit ARGB.
// Pass in YV16/YV12 depending on source format
void ConvertYCbCrToRGB32(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
void ConvertYCbCrToRGB32(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
uint8_t* rgbframe,
int pic_x,
int pic_y,
int pic_width,
@ -57,12 +57,13 @@ void ConvertYCbCrToRGB32(const uint8* yplane,
int uvstride,
int rgbstride,
YUVType yuv_type,
YUVColorSpace yuv_color_space);
YUVColorSpace yuv_color_space,
ColorRange color_range);
void ConvertYCbCrToRGB32_deprecated(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
void ConvertYCbCrToRGB32_deprecated(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
uint8_t* rgbframe,
int pic_x,
int pic_y,
int pic_width,
@ -74,10 +75,10 @@ void ConvertYCbCrToRGB32_deprecated(const uint8* yplane,
// Scale a frame of YUV to 32 bit ARGB.
// Supports rotation and mirroring.
void ScaleYCbCrToRGB32(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
void ScaleYCbCrToRGB32(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
uint8_t* rgbframe,
int source_width,
int source_height,
int width,
@ -87,12 +88,13 @@ void ScaleYCbCrToRGB32(const uint8* yplane,
int rgbstride,
YUVType yuv_type,
YUVColorSpace yuv_color_space,
ColorRange color_range,
ScaleFilter filter);
void ScaleYCbCrToRGB32_deprecated(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
void ScaleYCbCrToRGB32_deprecated(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
uint8_t* rgbframe,
int source_width,
int source_height,
int width,

View file

@ -21,20 +21,20 @@ void __attribute((noinline))
# else
void __attribute((noinline,optimize("-fomit-frame-pointer")))
# endif
yuv42x_to_rgb565_row_neon(uint16 *dst,
const uint8 *y,
const uint8 *u,
const uint8 *v,
yuv42x_to_rgb565_row_neon(uint16_t *dst,
const uint8_t *y,
const uint8_t *u,
const uint8_t *v,
int n,
int oddflag)
{
static __attribute__((aligned(16))) uint16 acc_r[8] = {
static __attribute__((aligned(16))) uint16_t acc_r[8] = {
22840, 22840, 22840, 22840, 22840, 22840, 22840, 22840,
};
static __attribute__((aligned(16))) uint16 acc_g[8] = {
static __attribute__((aligned(16))) uint16_t acc_g[8] = {
17312, 17312, 17312, 17312, 17312, 17312, 17312, 17312,
};
static __attribute__((aligned(16))) uint16 acc_b[8] = {
static __attribute__((aligned(16))) uint16_t acc_b[8] = {
28832, 28832, 28832, 28832, 28832, 28832, 28832, 28832,
};
/*

View file

@ -10,7 +10,7 @@ namespace gfx {
// FilterRows combines two rows of the image using linear interpolation.
// MMX version does 8 pixels at a time.
void FilterRows_MMX(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
void FilterRows_MMX(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) {
__m64 zero = _mm_setzero_si64();
__m64 y1_fraction = _mm_set1_pi16(source_y_fraction);

View file

@ -10,7 +10,7 @@ namespace gfx {
// FilterRows combines two rows of the image using linear interpolation.
// SSE2 version does 16 pixels at a time.
void FilterRows_SSE2(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr,
void FilterRows_SSE2(uint8_t* ybuf, const uint8_t* y0_ptr, const uint8_t* y1_ptr,
int source_width, int source_y_fraction) {
__m128i zero = _mm_setzero_si128();
__m128i y1_fraction = _mm_set1_epi16(source_y_fraction);

View file

@ -15,33 +15,27 @@
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,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width);
void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
unsigned int x_shift);
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
// 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.
// Only defined on Windows x86-32.
void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int step);
@ -49,10 +43,10 @@ void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
// This allows rotation by 90 or 270, by stepping by stride.
// This is the forth fastest of the scalers.
// Only defined on Windows x86-32.
void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void RotateConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int ystep,
int uvstep);
@ -60,33 +54,26 @@ void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
// Doubler does 4 pixels at a time. Each pixel is replicated.
// This is the fastest of the scalers.
// Only defined on Windows x86-32.
void DoubleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void DoubleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width);
// 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,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
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);
void ScaleYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx);
@ -94,24 +81,17 @@ void ScaleYUVToRGB32Row_C(const uint8* y_buf,
// 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,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* 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,
void LinearScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx);
@ -121,7 +101,7 @@ void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
#else
#define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
#endif
extern SIMD_ALIGNED(const int16 kCoefficientsRgbY[768][4]);
extern SIMD_ALIGNED(const int16_t kCoefficientsRgbY[768][4]);
// x64 uses MMX2 (SSE) so emms is not required.
// Warning C4799: function has no EMMS instruction.

View file

@ -13,10 +13,10 @@ extern "C" {
#define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \
(((x) + (y)) > 32767 ? 32767 : ((x) + (y))))
static inline void YuvPixel(uint8 y,
uint8 u,
uint8 v,
uint8* rgb_buf) {
static inline void YuvPixel(uint8_t y,
uint8_t u,
uint8_t v,
uint8_t* rgb_buf) {
int b = kCoefficientsRgbY[256+u][0];
int g = kCoefficientsRgbY[256+u][1];
@ -38,25 +38,25 @@ static inline void YuvPixel(uint8 y,
r >>= 6;
a >>= 6;
*reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) |
(packuswb(g) << 8) |
(packuswb(r) << 16) |
(packuswb(a) << 24);
*reinterpret_cast<uint32_t*>(rgb_buf) = (packuswb(b)) |
(packuswb(g) << 8) |
(packuswb(r) << 16) |
(packuswb(a) << 24);
}
void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
unsigned int x_shift) {
for (int x = 0; x < width; x += 2) {
uint8 u = u_buf[x >> x_shift];
uint8 v = v_buf[x >> x_shift];
uint8 y0 = y_buf[x];
uint8_t u = u_buf[x >> x_shift];
uint8_t v = v_buf[x >> x_shift];
uint8_t y0 = y_buf[x];
YuvPixel(y0, u, v, rgb_buf);
if ((x + 1) < width) {
uint8 y1 = y_buf[x + 1];
uint8_t y1 = y_buf[x + 1];
if (x_shift == 0) {
u = u_buf[x + 1];
v = v_buf[x + 1];
@ -71,10 +71,10 @@ void FastConvertYUVToRGB32Row_C(const uint8* y_buf,
// A shift by 17 is used to further subsample the chrominence channels.
// & 0xffff isolates the fixed point fraction. >> 2 to get the upper 2 bits,
// for 1/65536 pixel accurate interpolation.
void ScaleYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
int x = 0;
@ -93,10 +93,10 @@ void ScaleYUVToRGB32Row_C(const uint8* y_buf,
}
}
void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row_C(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
int x = 0;

View file

@ -5,27 +5,27 @@
#include "yuv_row.h"
extern "C" {
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
}
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);

View file

@ -14,11 +14,11 @@ extern "C" {
// We don't need CPUID guards here, since x86-64 implies SSE2.
// AMD64 ABI uses register paremters.
void FastConvertYUVToRGB32Row(const uint8* y_buf, // rdi
const uint8* u_buf, // rsi
const uint8* v_buf, // rdx
uint8* rgb_buf, // rcx
int width) { // r8
void FastConvertYUVToRGB32Row(const uint8_t* y_buf, // rdi
const uint8_t* u_buf, // rsi
const uint8_t* v_buf, // rdx
uint8_t* rgb_buf, // rcx
int width) { // r8
asm(
"jmp 1f\n"
"0:"
@ -72,12 +72,12 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf, // rdi
);
}
void ScaleYUVToRGB32Row(const uint8* y_buf, // rdi
const uint8* u_buf, // rsi
const uint8* v_buf, // rdx
uint8* rgb_buf, // rcx
int width, // r8
int source_dx) { // r9
void ScaleYUVToRGB32Row(const uint8_t* y_buf, // rdi
const uint8_t* u_buf, // rsi
const uint8_t* v_buf, // rdx
uint8_t* rgb_buf, // rcx
int width, // r8
int source_dx) { // r9
asm(
"xor %%r11,%%r11\n"
"sub $0x2,%4\n"
@ -141,10 +141,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf, // rdi
);
}
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
asm(
@ -262,10 +262,10 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
// PIC version is slower because less registers are available, so
// non-PIC is used on platforms where it is possible.
void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width);
asm(
".text\n"
@ -324,10 +324,10 @@ void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
#endif
);
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width)
{
if (mozilla::supports_sse()) {
@ -339,10 +339,10 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
}
void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx);
asm(
@ -417,10 +417,10 @@ void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif
);
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx)
{
@ -434,10 +434,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
width, source_dx);
}
void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx);
asm(
@ -549,10 +549,10 @@ void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif
);
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx)
{
@ -568,12 +568,12 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
#elif defined(MOZILLA_MAY_SUPPORT_SSE) && defined(ARCH_CPU_X86_32) && defined(__PIC__)
void PICConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void PICConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
const int16 *kCoefficientsRgbY);
const int16_t *kCoefficientsRgbY);
asm(
".text\n"
@ -635,10 +635,10 @@ void PICConvertYUVToRGB32Row_SSE(const uint8* y_buf,
#endif
);
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width)
{
if (mozilla::supports_sse()) {
@ -650,13 +650,13 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
}
void PICScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void PICScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx,
const int16 *kCoefficientsRgbY);
const int16_t *kCoefficientsRgbY);
asm(
".text\n"
@ -732,10 +732,10 @@ void PICScaleYUVToRGB32Row_SSE(const uint8* y_buf,
#endif
);
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx)
{
@ -748,13 +748,13 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
void PICLinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void PICLinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx,
const int16 *kCoefficientsRgbY);
const int16_t *kCoefficientsRgbY);
asm(
".text\n"
@ -871,10 +871,10 @@ void PICLinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
);
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx)
{
@ -887,27 +887,27 @@ void LinearScaleYUVToRGB32Row(const uint8* y_buf,
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
#else
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
}
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
LinearScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);

View file

@ -7,27 +7,27 @@
extern "C" {
#define RGBY(i) { \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
static_cast<int16_t>(1.164 * 64 * (i - 16) + 0.5), \
0 \
}
#define RGBU(i) { \
static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \
static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \
static_cast<int16_t>(2.018 * 64 * (i - 128) + 0.5), \
static_cast<int16_t>(-0.391 * 64 * (i - 128) + 0.5), \
0, \
static_cast<int16>(256 * 64 - 1) \
static_cast<int16_t>(256 * 64 - 1) \
}
#define RGBV(i) { \
0, \
static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \
static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \
static_cast<int16_t>(-0.813 * 64 * (i - 128) + 0.5), \
static_cast<int16_t>(1.596 * 64 * (i - 128) + 0.5), \
0 \
}
SIMD_ALIGNED(const int16 kCoefficientsRgbY[256 * 3][4]) = {
SIMD_ALIGNED(const int16_t kCoefficientsRgbY[256 * 3][4]) = {
RGBY(0x00), RGBY(0x01), RGBY(0x02), RGBY(0x03),
RGBY(0x04), RGBY(0x05), RGBY(0x06), RGBY(0x07),
RGBY(0x08), RGBY(0x09), RGBY(0x0A), RGBY(0x0B),

View file

@ -12,10 +12,10 @@ extern "C" {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
__declspec(naked)
void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
__asm {
pushad
@ -70,10 +70,10 @@ void FastConvertYUVToRGB32Row_SSE(const uint8* y_buf,
}
__declspec(naked)
void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int step) {
__asm {
@ -131,10 +131,10 @@ void ConvertYUVToRGB32Row_SSE(const uint8* y_buf,
}
__declspec(naked)
void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void RotateConvertYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int ystep,
int uvstep) {
@ -194,10 +194,10 @@ void RotateConvertYUVToRGB32Row_SSE(const uint8* y_buf,
}
__declspec(naked)
void DoubleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void DoubleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
__asm {
pushad
@ -266,10 +266,10 @@ void DoubleYUVToRGB32Row_SSE(const uint8* y_buf,
// For performance the chroma is under-sampled, reducing cost of a 3x
// 1080p scale from 8.4 ms to 5.4 ms.
__declspec(naked)
void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
__asm {
@ -339,10 +339,10 @@ void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
}
__declspec(naked)
void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row_SSE(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
__asm {
@ -446,10 +446,10 @@ lscalelastpixel:
}
#endif // if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)
if (mozilla::supports_sse()) {
@ -461,10 +461,10 @@ void FastConvertYUVToRGB32Row(const uint8* y_buf,
FastConvertYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, 1);
}
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
@ -478,10 +478,10 @@ void ScaleYUVToRGB32Row(const uint8* y_buf,
ScaleYUVToRGB32Row_C(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
#if defined(MOZILLA_MAY_SUPPORT_SSE) && defined(_M_IX86)

View file

@ -8,15 +8,15 @@ extern "C" {
// x64 compiler doesn't support MMX and inline assembler. Use SSE2 intrinsics.
#define kCoefficientsRgbU (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 2048)
#define kCoefficientsRgbV (reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 4096)
#define kCoefficientsRgbU (reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 2048)
#define kCoefficientsRgbV (reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 4096)
#include <emmintrin.h>
static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
static void FastConvertYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
__m128i xmm0, xmmY1, xmmY2;
__m128 xmmY;
@ -25,10 +25,10 @@ static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf++)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf++)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf++));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -44,23 +44,23 @@ static void FastConvertYUVToRGB32Row_SSE2(const uint8* y_buf,
if (width) {
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * *u_buf)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * *v_buf)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * *y_buf));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * *y_buf));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
*reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
}
}
static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
static void ScaleYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
__m128i xmm0, xmmY1, xmmY2;
__m128 xmmY;
uint8 u, v, y;
uint8_t u, v, y;
int x = 0;
while (width >= 2) {
@ -71,13 +71,13 @@ static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
y = y_buf[x >> 16];
x += source_dx;
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -97,24 +97,24 @@ static void ScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
*reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
}
}
static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
static void LinearScaleYUVToRGB32Row_SSE2(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
__m128i xmm0, xmmY1, xmmY2;
__m128 xmmY;
uint8 u0, u1, v0, v1, y0, y1;
uint32 uv_frac, y_frac, u, v, y;
uint8_t u0, u1, v0, v1, y0, y1;
uint32_t uv_frac, y_frac, u, v, y;
int x = 0;
if (source_dx >= 0x20000) {
@ -137,7 +137,7 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
y0 = y_buf[x >> 16];
@ -146,7 +146,7 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
y = (y_frac * y1 + (y_frac ^ 0xffff) * y0) >> 16;
x += source_dx;
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY2 = _mm_adds_epi16(xmmY2, xmm0);
xmmY = _mm_shuffle_ps(_mm_castsi128_ps(xmmY1), _mm_castsi128_ps(xmmY2),
@ -166,36 +166,36 @@ static void LinearScaleYUVToRGB32Row_SSE2(const uint8* y_buf,
xmm0 = _mm_adds_epi16(_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbU + 8 * u)),
_mm_loadl_epi64(reinterpret_cast<const __m128i*>(kCoefficientsRgbV + 8 * v)));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(reinterpret_cast<const uint8_t*>(kCoefficientsRgbY) + 8 * y));
xmmY1 = _mm_adds_epi16(xmmY1, xmm0);
xmmY1 = _mm_srai_epi16(xmmY1, 6);
xmmY1 = _mm_packus_epi16(xmmY1, xmmY1);
*reinterpret_cast<uint32*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
*reinterpret_cast<uint32_t*>(rgb_buf) = _mm_cvtsi128_si32(xmmY1);
}
}
void FastConvertYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void FastConvertYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width) {
FastConvertYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width);
}
void ScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void ScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
ScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width, source_dx);
}
void LinearScaleYUVToRGB32Row(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
void LinearScaleYUVToRGB32Row(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
uint8_t* rgb_buf,
int width,
int source_dx) {
LinearScaleYUVToRGB32Row_SSE2(y_buf, u_buf, v_buf, rgb_buf, width,

View file

@ -0,0 +1,6 @@
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
---
Language: Java
BasedOnStyle: Google

38
media/libyuv/.gn Normal file
View file

@ -0,0 +1,38 @@
# Copyright 2015 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import("//build/dotfile_settings.gni")
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
# The python interpreter to use by default. On Windows, this will look
# for python3.exe and python3.bat.
script_executable = "python3"
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
secondary_source = "//build/secondary/"
# These are the targets to check headers for by default. The files in targets
# matching these patterns (see "gn help label_pattern" for format) will have
# their includes checked for proper dependencies when you run either
# "gn check" or "gn gen --check".
check_targets = [ "//libyuv/*" ]
# These are the list of GN files that run exec_script. This whitelist exists
# to force additional review for new uses of exec_script, which is strongly
# discouraged except for gypi_to_gn calls.
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
[ "//build_overrides/build.gni" ]
default_args = {
mac_sdk_min = "10.12"
ios_deployment_target = "12.0"
}

52
media/libyuv/.vpython Normal file
View file

@ -0,0 +1,52 @@
# This is a vpython "spec" file.
#
# It describes patterns for python wheel dependencies of the python scripts in
# the chromium repo, particularly for dependencies that have compiled components
# (since pure-python dependencies can be easily vendored into third_party).
#
# When vpython is invoked, it finds this file and builds a python VirtualEnv,
# containing all of the dependencies described in this file, fetching them from
# CIPD (the "Chrome Infrastructure Package Deployer" service). Unlike `pip`,
# this never requires the end-user machine to have a working python extension
# compilation environment. All of these packages are built using:
# https://chromium.googlesource.com/infra/infra/+/master/infra/tools/dockerbuild/
#
# All python scripts in the repo share this same spec, to avoid dependency
# fragmentation.
#
# If you have depot_tools installed in your $PATH, you can invoke python scripts
# in this repo by running them as you normally would run them, except
# substituting `vpython` instead of `python` on the command line, e.g.:
# vpython path/to/script.py some --arguments
#
# Read more about `vpython` and how to modify this file here:
# https://chromium.googlesource.com/infra/infra/+/master/doc/users/vpython.md
python_version: "2.7"
# Used by:
# third_party/catapult
wheel: <
name: "infra/python/wheels/psutil/${platform}_${py_python}_${py_abi}"
version: "version:5.2.2"
>
# Used by:
# third_party/catapult
wheel: <
name: "infra/python/wheels/pypiwin32/${vpython_platform}"
version: "version:219"
match_tag: <
platform: "win32"
>
match_tag: <
platform: "win_amd64"
>
>
# Used by:
# build/android
wheel: <
name: "infra/python/wheels/requests-py2_py3"
version: "version:2.13.0"
>

405
media/libyuv/.vpython3 Normal file
View file

@ -0,0 +1,405 @@
# This is a vpython "spec" file.
#
# It describes patterns for python wheel dependencies of the python scripts in
# the chromium repo, particularly for dependencies that have compiled components
# (since pure-python dependencies can be easily vendored into third_party).
#
# When vpython is invoked, it finds this file and builds a python VirtualEnv,
# containing all of the dependencies described in this file, fetching them from
# CIPD (the "Chrome Infrastructure Package Deployer" service). Unlike `pip`,
# this never requires the end-user machine to have a working python extension
# compilation environment. All of these packages are built using:
# https://chromium.googlesource.com/infra/infra/+/main/infra/tools/dockerbuild/
#
# All python scripts in the repo share this same spec, to avoid dependency
# fragmentation.
#
# If you have depot_tools installed in your $PATH, you can invoke python scripts
# in this repo by running them as you normally would run them, except
# substituting `vpython` instead of `python` on the command line, e.g.:
# vpython path/to/script.py some --arguments
#
# Read more about `vpython` and how to modify this file here:
# https://chromium.googlesource.com/infra/infra/+/main/doc/users/vpython.md
python_version: "3.8"
# The default set of platforms vpython checks does not yet include mac-arm64.
# Setting `verify_pep425_tag` to the list of platforms we explicitly must support
# allows us to ensure that vpython specs stay mac-arm64-friendly
verify_pep425_tag: [
{python: "cp38", abi: "cp38", platform: "manylinux1_x86_64"},
{python: "cp38", abi: "cp38", platform: "linux_arm64"},
{python: "cp38", abi: "cp38", platform: "macosx_10_10_intel"},
{python: "cp38", abi: "cp38", platform: "macosx_11_0_arm64"},
{python: "cp38", abi: "cp38", platform: "win32"},
{python: "cp38", abi: "cp38", platform: "win_amd64"}
]
# Used by:
# build/android/pylib/local/emulator/avd.py
# components/policy/test_support/policy_testserver.py
wheel: <
name: "infra/python/wheels/protobuf-py2_py3"
version: "version:3.15.8"
>
# TODO(https://crbug.com/898348): Add in necessary wheels as Python3 versions
# become available.
wheel: <
name: "infra/python/wheels/six-py2_py3"
version: "version:1.15.0"
>
# Common utilities.
# Use the same versions specified by //third_party/catapult/.vpython3 so that
# Chromium tests using Telemetry function properly.
wheel: <
name: "infra/python/wheels/numpy/${vpython_platform}"
version: "version:1.20.3"
# A newer version of numpy is required on ARM64, but it breaks older OS versions.
not_match_tag <
platform: "macosx_11_0_arm64"
>
>
wheel: <
name: "infra/python/wheels/numpy/mac-arm64_cp38_cp38"
version: "version:1.21.1"
match_tag <
platform: "macosx_11_0_arm64"
>
>
wheel: <
name: "infra/python/wheels/psutil/${vpython_platform}"
version: "version:5.8.0.chromium.2"
>
wheel: <
name: "infra/python/wheels/requests-py2_py3"
version: "version:2.26.0"
>
# Used by various python unit tests.
wheel: <
name: "infra/python/wheels/mock-py2_py3"
version: "version:2.0.0"
>
wheel: <
name: "infra/python/wheels/parameterized-py2_py3"
version: "version:0.7.1"
>
wheel: <
name: "infra/python/wheels/pbr-py2_py3"
version: "version:3.0.0"
>
wheel: <
name: "infra/python/wheels/pyfakefs-py2_py3"
version: "version:3.7.2"
>
# Used by:
# build/chromeos/test_runner.py
wheel: <
name: "infra/python/wheels/jsonlines-py2_py3"
version: "version:1.2.0"
>
wheel: <
name: "infra/python/wheels/python-dateutil-py2_py3"
version: "version:2.7.3"
>
# Used by WPT importer
wheel: <
name: "infra/python/wheels/charset_normalizer-py3"
version: "version:2.0.4"
>
wheel: <
name: "infra/python/wheels/pyasn1-py2_py3"
version: "version:0.4.5"
>
wheel: <
name: "infra/python/wheels/pyasn1_modules-py2_py3"
version: "version:0.2.4"
>
wheel: <
name: "infra/python/wheels/rsa-py2_py3"
version: "version:3.4.2"
>
wheel: <
name: "infra/python/wheels/cachetools-py2_py3"
version: "version:2.0.1"
>
wheel: <
name: "infra/python/wheels/uritemplate-py2_py3"
version: "version:3.0.0"
>
wheel: <
name: "infra/python/wheels/google-auth-py2_py3"
version: "version:1.25.0"
>
wheel: <
name: "infra/python/wheels/googleapis-common-protos-py2_py3"
version: "version:1.52.0"
>
wheel: <
name: "infra/python/wheels/google-api-core-py2_py3"
version: "version:1.25.1"
>
wheel: <
name: "infra/python/wheels/google-auth-httplib2-py2_py3"
version: "version:0.1.0"
>
wheel: <
name: "infra/python/wheels/google-api-python-client-py3"
version: "version:2.2.0"
>
wheel: <
name: "infra/python/wheels/oauth2client-py2_py3"
version: "version:3.0.0"
>
# Used by Web Platform Tests (WPT) codebase in
# //third_party/blink/web_tests/external/wpt/tools/
wheel: <
name: "infra/python/wheels/html5lib-py2_py3"
version: "version:1.0.1"
>
wheel: <
name: "infra/python/wheels/mozdebug-py2_py3"
version: "version:0.2"
>
wheel: <
name: "infra/python/wheels/mozinfo-py2_py3"
version: "version:1.2.2"
>
wheel: <
name: "infra/python/wheels/mozlog-py2_py3"
version: "version:7.1.0"
>
wheel: <
name: "infra/python/wheels/mozprocess-py2_py3"
version: "version:1.2.1"
>
wheel: <
name: "infra/python/wheels/urllib3-py2_py3"
version: "version:1.24.3"
>
wheel: <
name: "infra/python/wheels/blessings-py2_py3"
version: "version:1.7"
>
wheel: <
name: "infra/python/wheels/mozfile-py2_py3"
version: "version:2.0.0"
>
wheel: <
name: "infra/python/wheels/mozterm-py2_py3"
version: "version:1.0.0"
>
wheel: <
name: "infra/python/wheels/webencodings-py2_py3"
version: "version:0.5.1"
>
wheel: <
name: "infra/python/wheels/certifi-py2_py3"
version: "version:2020.11.8"
>
wheel: <
name: "infra/python/wheels/chardet-py2_py3"
version: "version:3.0.4"
>
wheel: <
name: "infra/python/wheels/idna-py2_py3"
version: "version:2.8"
>
wheel: <
name: "infra/python/wheels/distro-py2_py3"
version: "version:1.4.0"
>
wheel: <
name: "infra/python/wheels/pillow/linux-amd64_cp38_cp38"
version: "version:8.1.2"
>
wheel: <
name: "infra/python/wheels/aioquic/${vpython_platform}"
version: "version:0.9.15"
>
wheel: <
name: "infra/python/wheels/pylsqpack/${vpython_platform}"
version: "version:0.3.12"
>
wheel: <
name: "infra/python/wheels/cryptography/${vpython_platform}"
version: "version:3.3.1.chromium.1"
>
wheel: <
name: "infra/python/wheels/cffi/${vpython_platform}"
version: "version:1.14.5"
>
wheel: <
name: "infra/python/wheels/pycparser-py2_py3"
version: "version:2.19"
>
# Used by:
# chrome/test/chromedriver/test/run_webdriver_tests.py
wheel: <
name: "infra/python/wheels/iniconfig-py3"
version: "version:1.1.1"
>
wheel: <
name: "infra/python/wheels/packaging-py2_py3"
version: "version:16.8"
>
wheel: <
name: "infra/python/wheels/pyparsing-py2_py3"
version: "version:2.4.7"
>
wheel: <
name: "infra/python/wheels/toml-py3"
version: "version:0.10.1"
>
wheel <
name: "infra/python/wheels/pytest-py3"
version: "version:6.2.2"
>
wheel <
name: "infra/python/wheels/pytest-asyncio-py3"
version: "version:0.14.0"
>
wheel <
name: "infra/python/wheels/attrs-py2_py3"
version: "version:20.3.0"
>
wheel <
name: "infra/python/wheels/six-py2_py3"
version: "version:1.15.0"
>
wheel <
name: "infra/python/wheels/more-itertools-py2_py3"
version: "version:4.1.0"
>
wheel <
name: "infra/python/wheels/pluggy-py3"
version: "version:0.13.1"
>
wheel <
name: "infra/python/wheels/py-py2_py3"
version: "version:1.10.0"
>
wheel <
name: "infra/python/wheels/funcsigs-py2_py3"
version: "version:1.0.2"
>
wheel: <
name: "infra/python/wheels/atomicwrites-py2_py3"
version: "version:1.3.0"
>
wheel: <
name: "infra/python/wheels/colorama-py2_py3"
version: "version:0.4.1"
>
# Used by:
# testing/buildbot/generate_buildbot_json_coveragetest.py
wheel: <
name: "infra/python/wheels/coverage/${vpython_platform}"
version: "version:5.5.chromium.2"
>
# Used by:
# //content/test/gpu
wheel: <
name: "infra/python/wheels/pathos/${vpython_platform}"
version: "version:0.2.7.chromium.4"
not_match_tag <
abi: "cp27mu"
platform: "manylinux1_i686"
>
not_match_tag <
abi: "cp27mu"
platform: "linux_mips64"
>
not_match_tag <
abi: "cp27mu"
platform: "linux_armv6l"
>
not_match_tag <
abi: "cp27mu"
platform: "linux_armv7l"
>
>
# Used by:
# //tools/infra/find_bad_builds.py
wheel: <
name: "infra/python/wheels/pytz-py2_py3"
version: "version:2018.4"
>
# Used by:
# //third_party/blink/tools/blinkpy/web_tests/port/server_process.py
wheel: <
name: "infra/python/wheels/pywin32/${vpython_platform}"
version: "version:300"
match_tag: <
platform: "win32"
>
match_tag: <
platform: "win_amd64"
>
>
# Used by:
# //content/test/gpu/gpu_tests/color_profile_manager_mac.py
wheel: <
name: "infra/python/wheels/pyobjc/${vpython_platform}"
version: "version:7.3.chromium.1"
match_tag: <
platform: "macosx_10_10_intel"
>
>
# Used by:
# tools/perf/core/results_dashboard.py
wheel: <
name: "infra/python/wheels/httplib2-py3"
version: "version:0.19.1"
>
# Used by:
# tools/perf/flakiness_cli
wheel: <
name: "infra/python/wheels/pandas/${vpython_platform}"
version: "version:1.3.2.chromium.1"
match_tag: <
platform: "win32"
>
match_tag: <
platform: "win_amd64"
>
match_tag: <
platform: "manylinux1_i686"
>
match_tag: <
platform: "manylinux1_x86_64"
>
match_tag: <
platform: "macosx_10_6_intel"
>
>

View file

@ -2,3 +2,5 @@
# Name or Organization <email address>
Google Inc.
Ivan Pavlotskiy <ivan.pavlotskiy@lgepartner.com>

196
media/libyuv/Android.bp Normal file
View file

@ -0,0 +1,196 @@
package {
default_applicable_licenses: ["external_libyuv_files_license"],
}
// Added automatically by a large-scale-change
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
// See: http://go/android-license-faq
license {
name: "external_libyuv_files_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-BSD",
],
license_text: [
"LICENSE",
"PATENTS",
],
}
cc_library {
name: "libyuv",
vendor_available: true,
product_available: true,
host_supported: true,
vndk: {
enabled: true,
},
srcs: [
"source/compare.cc",
"source/compare_common.cc",
"source/compare_gcc.cc",
"source/compare_msa.cc",
"source/compare_neon.cc",
"source/compare_neon64.cc",
"source/convert.cc",
"source/convert_argb.cc",
"source/convert_from.cc",
"source/convert_from_argb.cc",
"source/convert_jpeg.cc",
"source/convert_to_argb.cc",
"source/convert_to_i420.cc",
"source/cpu_id.cc",
"source/mjpeg_decoder.cc",
"source/mjpeg_validate.cc",
"source/planar_functions.cc",
"source/rotate.cc",
"source/rotate_any.cc",
"source/rotate_argb.cc",
"source/rotate_common.cc",
"source/rotate_gcc.cc",
"source/rotate_msa.cc",
"source/rotate_neon.cc",
"source/rotate_neon64.cc",
"source/row_any.cc",
"source/row_common.cc",
"source/row_gcc.cc",
"source/row_msa.cc",
"source/row_neon.cc",
"source/row_neon64.cc",
"source/scale.cc",
"source/scale_any.cc",
"source/scale_argb.cc",
"source/scale_common.cc",
"source/scale_gcc.cc",
"source/scale_msa.cc",
"source/scale_neon.cc",
"source/scale_neon64.cc",
"source/scale_rgb.cc",
"source/scale_uv.cc",
"source/video_common.cc",
],
cflags: [
"-Wall",
"-Werror",
"-Wno-unused-parameter",
"-fexceptions",
"-DHAVE_JPEG",
],
arch: {
arm: {
cflags: ["-mfpu=neon"],
},
},
shared_libs: ["libjpeg"],
export_include_dirs: ["include"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
}
// compatibilty static library until all uses of libyuv_static are replaced
// with libyuv (b/37646797)
cc_library_static {
name: "libyuv_static",
vendor_available: true,
whole_static_libs: ["libyuv"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
}
cc_test {
name: "libyuv_unittest",
static_libs: ["libyuv"],
shared_libs: ["libjpeg"],
cflags: ["-Wall", "-Werror"],
srcs: [
"unit_test/basictypes_test.cc",
"unit_test/color_test.cc",
"unit_test/compare_test.cc",
"unit_test/convert_test.cc",
"unit_test/cpu_test.cc",
"unit_test/cpu_thread_test.cc",
"unit_test/math_test.cc",
"unit_test/planar_test.cc",
"unit_test/rotate_argb_test.cc",
"unit_test/rotate_test.cc",
"unit_test/scale_argb_test.cc",
"unit_test/scale_rgb_test.cc",
"unit_test/scale_test.cc",
"unit_test/scale_uv_test.cc",
"unit_test/unit_test.cc",
"unit_test/video_common_test.cc",
],
}
cc_test {
name: "compare",
gtest: false,
srcs: [
"util/compare.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "cpuid",
gtest: false,
srcs: [
"util/cpuid.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "i444tonv12_eg",
gtest: false,
srcs: [
"util/i444tonv12_eg.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "psnr",
gtest: false,
srcs: [
"util/psnr_main.cc",
"util/psnr.cc",
"util/ssim.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconstants",
gtest: false,
srcs: [
"util/yuvconstants.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconvert",
gtest: false,
srcs: [
"util/yuvconvert.cc",
],
static_libs: ["libyuv"],
shared_libs: ["libjpeg"],
}

View file

@ -1,4 +1,4 @@
# This is the Android makefile for libyuv for both platform and NDK.
# This is the Android makefile for libyuv for NDK.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@ -8,8 +8,11 @@ LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES := \
source/compare.cc \
source/compare_common.cc \
source/compare_neon64.cc \
source/compare_gcc.cc \
source/compare_msa.cc \
source/compare_neon.cc \
source/compare_neon64.cc \
source/compare_win.cc \
source/convert.cc \
source/convert_argb.cc \
source/convert_from.cc \
@ -22,42 +25,84 @@ LOCAL_SRC_FILES := \
source/rotate_any.cc \
source/rotate_argb.cc \
source/rotate_common.cc \
source/rotate_mips.cc \
source/rotate_neon64.cc \
source/rotate_gcc.cc \
source/rotate_msa.cc \
source/rotate_neon.cc \
source/rotate_neon64.cc \
source/rotate_win.cc \
source/row_any.cc \
source/row_common.cc \
source/row_mips.cc \
source/row_gcc.cc \
source/row_msa.cc \
source/row_neon.cc \
source/row_neon64.cc \
source/row_gcc.cc \
source/row_win.cc \
source/scale.cc \
source/scale_any.cc \
source/scale_argb.cc \
source/scale_common.cc \
source/scale_mips.cc \
source/scale_neon64.cc \
source/scale_gcc.cc \
source/scale_msa.cc \
source/scale_neon.cc \
source/scale_neon64.cc \
source/scale_rgb.cc \
source/scale_uv.cc \
source/scale_win.cc \
source/video_common.cc
# TODO(fbarchard): Enable mjpeg encoder.
# source/mjpeg_decoder.cc
# source/convert_jpeg.cc
# source/mjpeg_validate.cc
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -DLIBYUV_NEON
LOCAL_SRC_FILES += \
source/compare_neon.cc.neon \
source/rotate_neon.cc.neon \
source/row_neon.cc.neon \
source/scale_neon.cc.neon
common_CFLAGS := -Wall -fexceptions
ifneq ($(LIBYUV_DISABLE_JPEG), "yes")
LOCAL_SRC_FILES += \
source/convert_jpeg.cc \
source/mjpeg_decoder.cc \
source/mjpeg_validate.cc
common_CFLAGS += -DHAVE_JPEG
LOCAL_SHARED_LIBRARIES := libjpeg
endif
LOCAL_CFLAGS += $(common_CFLAGS)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_MODULE := libyuv_static
LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_WHOLE_STATIC_LIBRARIES := libyuv_static
LOCAL_MODULE := libyuv
ifneq ($(LIBYUV_DISABLE_JPEG), "yes")
LOCAL_SHARED_LIBRARIES := libjpeg
endif
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_STATIC_LIBRARIES := libyuv_static
LOCAL_SHARED_LIBRARIES := libjpeg
LOCAL_MODULE_TAGS := tests
LOCAL_CPP_EXTENSION := .cc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
unit_test/basictypes_test.cc \
unit_test/color_test.cc \
unit_test/compare_test.cc \
unit_test/convert_test.cc \
unit_test/cpu_test.cc \
unit_test/cpu_thread_test.cc \
unit_test/math_test.cc \
unit_test/planar_test.cc \
unit_test/rotate_argb_test.cc \
unit_test/rotate_test.cc \
unit_test/scale_argb_test.cc \
unit_test/scale_rgb_test.cc \
unit_test/scale_test.cc \
unit_test/scale_uv_test.cc \
unit_test/unit_test.cc \
unit_test/video_common_test.cc
LOCAL_MODULE := libyuv_unittest
include $(BUILD_NATIVE_TEST)

View file

@ -6,19 +6,80 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/arm.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//testing/test.gni")
import("libyuv.gni")
config("libyuv_config") {
include_dirs = [
".",
"include",
]
declare_args() {
# Set to false to disable building with absl flags.
libyuv_use_absl_flags = true
# When building a shared library using a target in WebRTC or
# Chromium projects that depends on libyuv, setting this flag
# to true makes libyuv symbols visible inside that library.
libyuv_symbols_visible = false
}
use_neon = current_cpu == "arm64" || (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon))
config("libyuv_config") {
include_dirs = [ "include" ]
if (is_android && current_cpu == "arm64") {
ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64" ]
}
if (is_android && current_cpu != "arm64") {
ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker" ]
}
if (!libyuv_use_neon) {
defines = [ "LIBYUV_DISABLE_NEON" ]
}
}
# This target is built when no specific target is specified on the command line.
group("default") {
testonly = true
deps = [ ":libyuv" ]
if (libyuv_include_tests) {
deps += [
":compare",
":cpuid",
":i444tonv12_eg",
":libyuv_unittest",
":psnr",
":yuvconstants",
":yuvconvert",
]
}
}
group("libyuv") {
all_dependent_configs = [ ":libyuv_config" ]
deps = []
if (is_win && target_cpu == "x64") {
# Compile with clang in order to get inline assembly
public_deps = [ ":libyuv_internal(//build/toolchain/win:win_clang_x64)" ]
} else {
public_deps = [ ":libyuv_internal" ]
}
if (libyuv_use_neon) {
deps += [ ":libyuv_neon" ]
}
if (libyuv_use_msa) {
deps += [ ":libyuv_msa" ]
}
if (!is_ios && !libyuv_disable_jpeg) {
# Make sure that clients of libyuv link with libjpeg. This can't go in
# libyuv_internal because in Windows x64 builds that will generate a clang
# build of libjpeg, and we don't want two copies.
deps += [ "//third_party:jpeg" ]
}
}
static_library("libyuv_internal") {
visibility = [ ":*" ]
source_set("libyuv") {
sources = [
# Headers
"include/libyuv.h",
@ -37,7 +98,9 @@ source_set("libyuv") {
"include/libyuv/row.h",
"include/libyuv/scale.h",
"include/libyuv/scale_argb.h",
"include/libyuv/scale_rgb.h",
"include/libyuv/scale_row.h",
"include/libyuv/scale_uv.h",
"include/libyuv/version.h",
"include/libyuv/video_common.h",
@ -61,57 +124,61 @@ source_set("libyuv") {
"source/rotate_any.cc",
"source/rotate_argb.cc",
"source/rotate_common.cc",
"source/rotate_mips.cc",
"source/rotate_gcc.cc",
"source/rotate_win.cc",
"source/row_any.cc",
"source/row_common.cc",
"source/row_mips.cc",
"source/row_gcc.cc",
"source/row_win.cc",
"source/scale.cc",
"source/scale_any.cc",
"source/scale_argb.cc",
"source/scale_common.cc",
"source/scale_mips.cc",
"source/scale_gcc.cc",
"source/scale_rgb.cc",
"source/scale_uv.cc",
"source/scale_win.cc",
"source/video_common.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":libyuv_config" ]
configs += [ ":libyuv_config" ]
defines = []
deps = []
if (!is_ios) {
if (libyuv_symbols_visible) {
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [ "//build/config/gcc:symbol_visibility_default" ]
}
if (!is_ios && !libyuv_disable_jpeg) {
defines += [ "HAVE_JPEG" ]
# Needed to pull in libjpeg headers. Can't add //third_party:jpeg to deps
# because in Windows x64 build it will get compiled with clang.
deps += [ "//third_party:jpeg_includes" ]
}
if (is_msan) {
# MemorySanitizer does not support assembly code yet.
# http://crbug.com/344505
defines += [ "LIBYUV_DISABLE_X86" ]
}
deps = [
"//third_party:jpeg",
]
if (use_neon) {
deps += [ ":libyuv_neon" ]
}
if (is_nacl) {
# Always enable optimization under NaCl to workaround crbug.com/538243 .
# Always enable optimization for Release and NaCl builds (to workaround
# crbug.com/538243).
if (!is_debug || is_nacl) {
configs -= [ "//build/config/compiler:default_optimization" ]
# Enable optimize for speed (-O2) over size (-Os).
configs += [ "//build/config/compiler:optimize_max" ]
}
# To enable AVX2 or other cpu optimization, pass flag here
if (!is_win) {
cflags = [
# "-mpopcnt",
# "-mavx2",
# "-mfma",
"-ffp-contract=fast", # Enable fma vectorization for NEON.
]
}
}
if (use_neon) {
if (libyuv_use_neon) {
static_library("libyuv_neon") {
sources = [
# ARM Source Files
@ -125,11 +192,197 @@ if (use_neon) {
"source/scale_neon64.cc",
]
deps = [ ":libyuv_internal" ]
public_configs = [ ":libyuv_config" ]
# Always enable optimization for Release and NaCl builds (to workaround
# crbug.com/538243).
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
# Enable optimize for speed (-O2) over size (-Os).
# TODO(fbarchard): Consider optimize_speed which is O3.
configs += [ "//build/config/compiler:optimize_max" ]
}
if (current_cpu != "arm64") {
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
}
}
if (libyuv_use_msa) {
static_library("libyuv_msa") {
sources = [
# MSA Source Files
"source/compare_msa.cc",
"source/rotate_msa.cc",
"source/row_msa.cc",
"source/scale_msa.cc",
]
deps = [ ":libyuv_internal" ]
public_configs = [ ":libyuv_config" ]
}
}
if (libyuv_include_tests) {
config("libyuv_unittest_warnings_config") {
if (!is_win) {
cflags = [
# TODO(fbarchard): Fix sign and unused variable warnings.
"-Wno-sign-compare",
"-Wno-unused-variable",
]
}
if (is_win) {
cflags = [
"/wd4245", # signed/unsigned mismatch
"/wd4189", # local variable is initialized but not referenced
]
}
}
config("libyuv_unittest_config") {
defines = [ "GTEST_RELATIVE_PATH" ]
}
test("libyuv_unittest") {
testonly = true
sources = [
"unit_test/basictypes_test.cc",
"unit_test/color_test.cc",
"unit_test/compare_test.cc",
"unit_test/convert_test.cc",
"unit_test/cpu_test.cc",
"unit_test/cpu_thread_test.cc",
"unit_test/math_test.cc",
"unit_test/planar_test.cc",
"unit_test/rotate_argb_test.cc",
"unit_test/rotate_test.cc",
"unit_test/scale_argb_test.cc",
"unit_test/scale_rgb_test.cc",
"unit_test/scale_test.cc",
"unit_test/scale_uv_test.cc",
"unit_test/unit_test.cc",
"unit_test/unit_test.h",
"unit_test/video_common_test.cc",
]
deps = [
":libyuv",
"//testing/gtest",
]
defines = []
if (libyuv_use_absl_flags) {
defines += [ "LIBYUV_USE_ABSL_FLAGS" ]
deps += [
"//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse",
]
}
configs += [ ":libyuv_unittest_warnings_config" ]
public_deps = [ "//testing/gtest" ]
public_configs = [ ":libyuv_unittest_config" ]
if (is_linux || is_chromeos) {
cflags = [ "-fexceptions" ]
}
if (is_ios) {
configs -= [ "//build/config/compiler:default_symbols" ]
configs += [ "//build/config/compiler:symbols" ]
cflags = [ "-Wno-sometimes-uninitialized" ]
}
if (!is_ios && !libyuv_disable_jpeg) {
defines += [ "HAVE_JPEG" ]
}
if (is_android) {
deps += [ "//testing/android/native_test:native_test_native_code" ]
}
# TODO(YangZhang): These lines can be removed when high accuracy
# YUV to RGB to Neon is ported.
if ((target_cpu == "armv7" || target_cpu == "armv7s" ||
(target_cpu == "arm" && arm_version >= 7) || target_cpu == "arm64") &&
(arm_use_neon || arm_optionally_use_neon)) {
defines += [ "LIBYUV_NEON" ]
}
defines += [
# Enable the following 3 macros to turn off assembly for specified CPU.
# "LIBYUV_DISABLE_X86",
# "LIBYUV_DISABLE_NEON",
# Enable the following macro to build libyuv as a shared library (dll).
# "LIBYUV_USING_SHARED_LIBRARY"
]
}
executable("compare") {
sources = [
# sources
"util/compare.cc",
]
deps = [ ":libyuv" ]
if (is_linux || is_chromeos) {
cflags = [ "-fexceptions" ]
}
}
executable("yuvconvert") {
sources = [
# sources
"util/yuvconvert.cc",
]
deps = [ ":libyuv" ]
if (is_linux || is_chromeos) {
cflags = [ "-fexceptions" ]
}
}
executable("yuvconstants") {
sources = [
# sources
"util/yuvconstants.c",
]
deps = [ ":libyuv" ]
if (is_linux || is_chromeos) {
cflags = [ "-fexceptions" ]
}
}
executable("psnr") {
sources = [
# sources
"util/psnr.cc",
"util/psnr_main.cc",
"util/ssim.cc",
]
deps = [ ":libyuv" ]
if (!is_ios && !libyuv_disable_jpeg) {
defines = [ "HAVE_JPEG" ]
}
}
executable("i444tonv12_eg") {
sources = [
# sources
"util/i444tonv12_eg.cc",
]
deps = [ ":libyuv" ]
}
executable("cpuid") {
sources = [
# sources
"util/cpuid.c",
]
deps = [ ":libyuv" ]
}
}

View file

@ -0,0 +1,69 @@
# determine the version number from the #define in libyuv/version.h
EXECUTE_PROCESS (
COMMAND grep --perl-regex --only-matching "(?<=LIBYUV_VERSION )[0-9]+" include/libyuv/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE YUV_VERSION_NUMBER
OUTPUT_STRIP_TRAILING_WHITESPACE )
SET ( YUV_VER_MAJOR 0 )
SET ( YUV_VER_MINOR 0 )
SET ( YUV_VER_PATCH ${YUV_VERSION_NUMBER} )
SET ( YUV_VERSION ${YUV_VER_MAJOR}.${YUV_VER_MINOR}.${YUV_VER_PATCH} )
MESSAGE ( VERBOSE "Building ver.: ${YUV_VERSION}" )
# is this a 32-bit or 64-bit build?
IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET ( YUV_BIT_SIZE 64 )
ELSEIF ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
SET ( YUV_BIT_SIZE 32 )
ELSE ()
MESSAGE ( FATAL_ERROR "CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" )
ENDIF ()
# detect if this is a ARM build
STRING (FIND "${CMAKE_CXX_COMPILER}" "arm-linux-gnueabihf-g++" pos)
IF ( ${pos} EQUAL -1 )
SET ( YUV_CROSS_COMPILE_FOR_ARM7 FALSE )
ELSE ()
MESSAGE ( "Cross compiling for ARM7" )
SET ( YUV_CROSS_COMPILE_FOR_ARM7 TRUE )
ENDIF ()
STRING (FIND "${CMAKE_SYSTEM_PROCESSOR}" "arm" pos)
IF ( ${pos} EQUAL -1 )
SET ( YUV_COMPILE_FOR_ARM7 FALSE )
ELSE ()
MESSAGE ( "Compiling for ARM" )
SET ( YUV_COMPILE_FOR_ARM7 TRUE )
ENDIF ()
# setup the sytem name, such as "x86-32", "amd-64", and "arm-32
IF ( ${YUV_CROSS_COMPILE_FOR_ARM7} OR ${YUV_COMPILE_FOR_ARM7} )
SET ( YUV_SYSTEM_NAME "armhf-${YUV_BIT_SIZE}" )
ELSE ()
IF ( YUV_BIT_SIZE EQUAL 32 )
SET ( YUV_SYSTEM_NAME "x86-${YUV_BIT_SIZE}" )
ELSE ()
SET ( YUV_SYSTEM_NAME "amd-${YUV_BIT_SIZE}" )
ENDIF ()
ENDIF ()
MESSAGE ( VERBOSE "Packaging for: ${YUV_SYSTEM_NAME}" )
# define all the variables needed by CPack to create .deb and .rpm packages
SET ( CPACK_PACKAGE_VENDOR "Frank Barchard" )
SET ( CPACK_PACKAGE_CONTACT "fbarchard@chromium.org" )
SET ( CPACK_PACKAGE_VERSION ${YUV_VERSION} )
SET ( CPACK_PACKAGE_VERSION_MAJOR ${YUV_VER_MAJOR} )
SET ( CPACK_PACKAGE_VERSION_MINOR ${YUV_VER_MINOR} )
SET ( CPACK_PACKAGE_VERSION_PATCH ${YUV_VER_PATCH} )
SET ( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE )
SET ( CPACK_SYSTEM_NAME "linux-${YUV_SYSTEM_NAME}" )
SET ( CPACK_PACKAGE_NAME "libyuv" )
SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "YUV library" )
SET ( CPACK_PACKAGE_DESCRIPTION "YUV library and YUV conversion tool" )
SET ( CPACK_DEBIAN_PACKAGE_SECTION "other" )
SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Frank Barchard <fbarchard@chromium.org>" )
SET ( CPACK_GENERATOR "DEB;RPM" )
# create the .deb and .rpm files (you'll need build-essential and rpm tools)
INCLUDE( CPack )

View file

@ -1,110 +1,55 @@
cmake_minimum_required(VERSION 2.8)
# CMakeLists for libyuv
# Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
option(TEST "Built unit tests" OFF)
set(ly_base_dir ${CMAKE_CURRENT_LIST_DIR})
set(ly_src_dir ${ly_base_dir}/source/)
set(ly_inc_dir ${ly_base_dir}/include)
set(ly_lib_name "yuv")
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
OPTION( TEST "Built unit tests" OFF )
set(ly_source_files
${ly_src_dir}/compare.cc
${ly_src_dir}/compare_common.cc
${ly_src_dir}/compare_neon.cc
${ly_src_dir}/compare_neon64.cc
${ly_src_dir}/compare_gcc.cc
${ly_src_dir}/compare_win.cc
${ly_src_dir}/convert.cc
${ly_src_dir}/convert_argb.cc
${ly_src_dir}/convert_from.cc
${ly_src_dir}/convert_from_argb.cc
${ly_src_dir}/convert_jpeg.cc
${ly_src_dir}/convert_to_argb.cc
${ly_src_dir}/convert_to_i420.cc
${ly_src_dir}/cpu_id.cc
${ly_src_dir}/mjpeg_decoder.cc
${ly_src_dir}/mjpeg_validate.cc
${ly_src_dir}/planar_functions.cc
${ly_src_dir}/rotate.cc
${ly_src_dir}/rotate_any.cc
${ly_src_dir}/rotate_argb.cc
${ly_src_dir}/rotate_common.cc
${ly_src_dir}/rotate_mips.cc
${ly_src_dir}/rotate_neon.cc
${ly_src_dir}/rotate_neon64.cc
${ly_src_dir}/rotate_gcc.cc
${ly_src_dir}/rotate_win.cc
${ly_src_dir}/row_any.cc
${ly_src_dir}/row_common.cc
${ly_src_dir}/row_mips.cc
${ly_src_dir}/row_neon.cc
${ly_src_dir}/row_neon64.cc
${ly_src_dir}/row_gcc.cc
${ly_src_dir}/row_win.cc
${ly_src_dir}/scale.cc
${ly_src_dir}/scale_any.cc
${ly_src_dir}/scale_argb.cc
${ly_src_dir}/scale_common.cc
${ly_src_dir}/scale_mips.cc
${ly_src_dir}/scale_neon.cc
${ly_src_dir}/scale_neon64.cc
${ly_src_dir}/scale_gcc.cc
${ly_src_dir}/scale_win.cc
${ly_src_dir}/video_common.cc
)
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
SET ( ly_src_dir ${ly_base_dir}/source )
SET ( ly_inc_dir ${ly_base_dir}/include )
SET ( ly_tst_dir ${ly_base_dir}/unit_test )
SET ( ly_lib_name yuv )
SET ( ly_lib_static ${ly_lib_name} )
SET ( ly_lib_shared ${ly_lib_name}_shared )
set(ly_unittest_sources
${ly_base_dir}/unit_test/basictypes_test.cc
${ly_base_dir}/unit_test/color_test.cc
${ly_base_dir}/unit_test/compare_test.cc
${ly_base_dir}/unit_test/convert_test.cc
${ly_base_dir}/unit_test/cpu_test.cc
${ly_base_dir}/unit_test/math_test.cc
${ly_base_dir}/unit_test/planar_test.cc
${ly_base_dir}/unit_test/rotate_argb_test.cc
${ly_base_dir}/unit_test/rotate_test.cc
${ly_base_dir}/unit_test/scale_argb_test.cc
${ly_base_dir}/unit_test/scale_test.cc
${ly_base_dir}/unit_test/unit_test.cc
${ly_base_dir}/unit_test/video_common_test.cc
)
FILE ( GLOB_RECURSE ly_source_files ${ly_src_dir}/*.cc )
LIST ( SORT ly_source_files )
set(ly_header_files
${ly_inc_dir}/libyuv/basic_types.h
${ly_inc_dir}/libyuv/compare.h
${ly_inc_dir}/libyuv/convert.h
${ly_inc_dir}/libyuv/convert_argb.h
${ly_inc_dir}/libyuv/convert_from.h
${ly_inc_dir}/libyuv/convert_from_argb.h
${ly_inc_dir}/libyuv/cpu_id.h
${ly_inc_dir}/libyuv/planar_functions.h
${ly_inc_dir}/libyuv/rotate.h
${ly_inc_dir}/libyuv/rotate_argb.h
${ly_inc_dir}/libyuv/rotate_row.h
${ly_inc_dir}/libyuv/row.h
${ly_inc_dir}/libyuv/scale.h
${ly_inc_dir}/libyuv/scale_argb.h
${ly_inc_dir}/libyuv/scale_row.h
${ly_inc_dir}/libyuv/version.h
${ly_inc_dir}/libyuv/video_common.h
${ly_inc_dir}/libyuv/mjpeg_decoder.h
)
FILE ( GLOB_RECURSE ly_unittest_sources ${ly_tst_dir}/*.cc )
LIST ( SORT ly_unittest_sources )
include_directories(${ly_inc_dir})
INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} )
add_library(${ly_lib_name} STATIC ${ly_source_files})
if(MSVC)
ADD_DEFINITIONS ( -D_CRT_SECURE_NO_WARNINGS )
endif()
add_executable(convert ${ly_base_dir}/util/convert.cc)
target_link_libraries(convert ${ly_lib_name})
# this creates the static library (.a)
ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
include(FindJPEG)
# this creates the shared library (.so)
ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
if(WIN32)
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
endif()
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
# this creates the yuvconstants tool
ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
find_package ( JPEG )
if (JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIR})
target_link_libraries(convert ${JPEG_LIBRARY})
add_definitions(-DHAVE_JPEG)
include_directories( ${JPEG_INCLUDE_DIR} )
target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
add_definitions( -DHAVE_JPEG )
endif()
if(TEST)
@ -124,19 +69,33 @@ if(TEST)
endif()
add_executable(libyuv_unittest ${ly_unittest_sources})
target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread)
target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY})
find_library(PTHREAD_LIBRARY pthread)
if(NOT PTHREAD_LIBRARY STREQUAL "PTHREAD_LIBRARY-NOTFOUND")
target_link_libraries(libyuv_unittest pthread)
endif()
if (JPEG_FOUND)
target_link_libraries(libyuv_unittest ${JPEG_LIBRARY})
endif()
if(NACL AND NACL_LIBC STREQUAL "newlib")
target_link_libraries(libyuv_unittest glibc-compat)
endif()
target_link_libraries(libyuv_unittest gflags)
find_library(GFLAGS_LIBRARY gflags)
if(NOT GFLAGS_LIBRARY STREQUAL "GFLAGS_LIBRARY-NOTFOUND")
target_link_libraries(libyuv_unittest gflags)
add_definitions(-DLIBYUV_USE_GFLAGS)
endif()
endif()
install(TARGETS ${ly_lib_name} DESTINATION lib)
install(FILES ${ly_header_files} DESTINATION include/libyuv)
install(FILES ${ly_inc_dir}/libyuv.h DESTINATION include/)
# install the conversion tool, .so, .a, and all the header files
INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
INCLUDE ( CM_linux_packages.cmake )

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,3 @@
monorail {
component: "Internals>Images>Codecs"
}

View file

@ -1,8 +0,0 @@
This source tree contains third party source code which is governed by third
party licenses. This file contains references to files which are under other
licenses than the one provided in the LICENSE file in the root of the source
tree.
Files governed by third party licenses:
source/x86inc.asm

View file

@ -1,13 +1,11 @@
mbonadei@chromium.org
fbarchard@chromium.org
magjed@chromium.org
torbjorng@chromium.org
wtc@google.com
jansson@google.com
per-file *.gyp=kjellander@chromium.org
per-file *.gn=kjellander@chromium.org
per-file *.gn=mbonadei@chromium.org,jansson@google.com
per-file .gitignore=*
per-file AUTHORS=*
per-file DEPS=*
per-file PRESUBMIT.py=kjellander@chromium.org
per-file gyp_libyuv.py=kjellander@chromium.org
per-file setup_links.py=*
per-file sync_chromium.py=kjellander@chromium.org
per-file PRESUBMIT.py=mbonadei@chromium.org,jansson@google.com

View file

@ -1,4 +1,4 @@
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
# Copyright 2017 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
@ -6,60 +6,47 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import re
import sys
# Runs PRESUBMIT.py in py3 mode by git cl presubmit.
USE_PYTHON3 = True
def GetDefaultTryConfigs(bots=None):
"""Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
files_to_skip=(r'^base[\\\/].*\.py$',
r'^build[\\\/].*\.py$',
r'^buildtools[\\\/].*\.py$',
r'^ios[\\\/].*\.py$',
r'^out.*[\\\/].*\.py$',
r'^testing[\\\/].*\.py$',
r'^third_party[\\\/].*\.py$',
r'^tools[\\\/].*\.py$',
# TODO(kjellander): should arguably be checked.
r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$',
r'^xcodebuild.*[\\\/].*\.py$',),
disabled_warnings=['F0401', # Failed to import x
'E0611', # No package y in x
'W0232', # Class has no __init__ method
],
pylintrc='pylintrc',
version='2.7'))
return results
For WebRTC purposes, we always return an empty list of tests, since we want
to run all tests by default on all our trybots.
"""
return { 'tryserver.libyuv': dict((bot, []) for bot in bots)}
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
return results
# pylint: disable=W0613
def GetPreferredTryMasters(project, change):
files = change.LocalPaths()
bots = [
'win',
'win_rel',
'win_x64_rel',
'win_x64_gn',
'win_x64_gn_rel',
'win_clang',
'win_clang_rel',
'win_x64_clang_rel',
'mac',
'mac_rel',
'mac_gn',
'mac_gn_rel',
'mac_asan',
'ios',
'ios_rel',
'ios_arm64',
'ios_arm64_rel',
'linux',
'linux_rel',
'linux_gn',
'linux_gn_rel',
'linux_memcheck',
'linux_tsan2',
'linux_asan',
'linux_msan',
'linux_ubsan',
'linux_ubsan_vptr',
'android',
'android_rel',
'android_clang',
'android_arm64',
'android_mips',
'android_x64',
'android_x86',
'android_gn',
'android_gn_rel',
]
if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files):
return {}
return GetDefaultTryConfigs(bots)
def CheckChangeOnCommit(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
return results

View file

@ -1,8 +1,9 @@
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1602
Version: 1861
License: BSD
License File: LICENSE
Description:
libyuv is an open source project that includes YUV conversion and scaling functionality.

View file

@ -1,18 +1,18 @@
**libyuv** is an open source project that includes YUV scaling and conversion functionality.
* Scale YUV to prepare content for compression, with point, bilinear or box filter.
* Convert to YUV from webcam formats.
* Convert from YUV to formats for rendering/effects.
* Convert to YUV from webcam formats for compression.
* Convert to RGB formats for rendering/effects.
* Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode.
* Optimized for SSE2/SSSE3/AVX2 on x86/x64.
* Optimized for SSSE3/AVX2 on x86/x64.
* Optimized for Neon on Arm.
* Optimized for DSP R2 on Mips.
* Optimized for MSA on Mips.
### Development
See [Getting started] [1] for instructions on how to get started developing.
See [Getting started][1] for instructions on how to get started developing.
You can also browse the [docs directory] [2] for more documentation.
You can also browse the [docs directory][2] for more documentation.
[1]: https://chromium.googlesource.com/libyuv/libyuv/+/master/docs/getting_started.md
[2]: https://chromium.googlesource.com/libyuv/libyuv/+/master/docs/
[1]: ./docs/getting_started.md
[2]: ./docs/

View file

@ -1,21 +0,0 @@
# Copyright 2013 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# all.gyp and All target are for benefit of android gyp build.
{
'targets': [
{
'target_name': 'All',
'type': 'none',
'dependencies': [
'libyuv.gyp:*',
'libyuv_test.gyp:*',
],
},
],
}

View file

@ -6,10 +6,55 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# Using same overrides as WebRTC
# See https://bugs.chromium.org/p/webrtc/issues/detail?id=5453.
# Some WebRTC targets require the 10.7 deployment version of the Mac SDK and a
# 10.11 min SDK but those targets are only used in non-Chromium builds. We can
# remove this when Chromium drops 10.6 support and also requires 10.7.
mac_sdk_min_build_override = "10.11"
mac_deployment_target_build_override = "10.7"
# Variable that can be used to support multiple build scenarios, like having
# Chromium specific targets in a client project's GN file etc.
build_with_chromium = false
# Some non-Chromium builds don't support building java targets.
enable_java_templates = true
# Allow using custom suppressions files (currently not used by libyuv).
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
msan_blacklist_path =
rebase_path("//tools_libyuv/msan/blacklist.txt", root_build_dir)
ubsan_blacklist_path =
rebase_path("//tools_libyuv/ubsan/blacklist.txt", root_build_dir)
ubsan_vptr_blacklist_path =
rebase_path("//tools_libyuv/ubsan/vptr_blacklist.txt", root_build_dir)
# For Chromium, Android 32-bit non-component, non-clang builds hit a 4GiB size
# limit, making them requiring symbol_level=2. WebRTC doesn't hit that problem
# so we just ignore that assert. See https://crbug.com/648948 for more info.
ignore_elf32_limitations = true
# Use bundled hermetic Xcode installation maintained by Chromium,
# except for local iOS builds where it is unsupported.
if (host_os == "mac") {
_result = exec_script("//build/mac/should_use_hermetic_xcode.py",
[ target_os ],
"value")
assert(_result != 2,
"Do not allow building targets with the default" +
"hermetic toolchain if the minimum OS version is not met.")
use_system_xcode = _result == 0
}
declare_args() {
# Tracing support requires //third_party/perfetto.
enable_base_tracing = false
use_perfetto_client_library = false
# Limits the defined //third_party/android_deps targets to only "buildCompile"
# and "buildCompileNoDeps" targets. This is useful for third-party
# repositories which do not use JUnit tests. For instance,
# limit_android_deps == true removes "gn gen" requirement for
# //third_party/robolectric .
limit_android_deps = false
# Allows googletest to pretty-print various absl types.
# Defined here rather than in gtest.gni to match chromium.
gtest_enable_absl_printers = true
}

View file

@ -0,0 +1,19 @@
# Copyright (c) 2016 The LibYuv project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# Include support for registering main function in multi-process tests.
gtest_include_multiprocess = true
# Include support for platform-specific operations across unit tests.
gtest_include_platform_test = true
# Exclude support for testing Objective C code on OS X and iOS.
gtest_include_objc_support = true
# Exclude support for flushing coverage files on iOS.
gtest_include_ios_coverage = true

View file

@ -0,0 +1,17 @@
# Copyright 2022 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# Use default values for PartitionAlloc as standalone library from
# base/allocator/partition_allocator/build_overrides/partition_alloc.gni
use_partition_alloc_as_malloc_default = false
use_allocator_shim_default = false
enable_backup_ref_ptr_support_default = false
enable_mte_checked_ptr_support_default = false
put_ref_count_in_previous_slot_default = false
enable_backup_ref_ptr_slow_checks_default = false
enable_dangling_raw_ptr_checks_default = false

View file

@ -1,5 +0,0 @@
This .gclient file is used to do download a copy of Chromium.
Libyuv uses the Chromium build toolchain and a number of shared
dependencies by creating symlinks to folders in this checkout,
using the ../setup_links.py script.

View file

@ -0,0 +1,108 @@
#!/usr/bin/env vpython3
# Copyright 2017 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# This is a copy of the file from WebRTC in:
# https://chromium.googlesource.com/external/webrtc/+/master/cleanup_links.py
"""Script to cleanup symlinks created from setup_links.py.
Before 177567c518b121731e507e9b9c4049c4dc96e4c8 (#15754) we had a Chromium
checkout which we created symlinks into. In order to do clean syncs after
landing that change, this script cleans up any old symlinks, avoiding annoying
manual cleanup needed in order to complete gclient sync.
"""
import argparse
import logging
import os
import shelve
import subprocess
import sys
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
LINKS_DB = 'links'
# Version management to make future upgrades/downgrades easier to support.
SCHEMA_VERSION = 1
class WebRTCLinkSetup():
def __init__(self, links_db, dry_run=False):
self._dry_run = dry_run
self._links_db = links_db
def CleanupLinks(self):
logging.debug('CleanupLinks')
for source, link_path in self._links_db.tems():
if source == 'SCHEMA_VERSION':
continue
if os.path.islink(link_path) or sys.platform.startswith('win'):
# os.path.islink() always returns false on Windows
# See http://bugs.python.org/issue13143.
logging.debug('Removing link to %s at %s', source, link_path)
if not self._dry_run:
if os.path.exists(link_path):
if sys.platform.startswith('win') and os.path.isdir(link_path):
subprocess.check_call(['rmdir', '/q', '/s', link_path],
shell=True)
else:
os.remove(link_path)
del self._links_db[source]
def _initialize_database(filename):
links_database = shelve.open(filename)
# Wipe the database if this version of the script ends up looking at a
# newer (future) version of the links db, just to be sure.
version = links_database.get('SCHEMA_VERSION')
if version and version != SCHEMA_VERSION:
logging.info('Found database with schema version %s while this script only '
'supports %s. Wiping previous database contents.', version,
SCHEMA_VERSION)
links_database.clear()
links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
return links_database
def main():
p = argparse.ArgumentParser()
p.add_argument('-d', '--dry-run', action='store_true', default=False,
help='Print what would be done, but don\'t perform any '
'operations. This will automatically set logging to '
'verbose.')
p.add_argument('-v', '--verbose', action='store_const',
const=logging.DEBUG, default=logging.INFO,
help='Print verbose output for debugging.')
options = p.parse_args()
if options.dry_run:
options.verbose = logging.DEBUG
logging.basicConfig(format='%(message)s', level=options.verbose)
# Work from the root directory of the checkout.
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)
# The database file gets .db appended on some platforms.
db_filenames = [LINKS_DB, LINKS_DB + '.db']
if any(os.path.isfile(f) for f in db_filenames):
links_database = _initialize_database(LINKS_DB)
try:
symlink_creator = WebRTCLinkSetup(links_database, options.dry_run)
symlink_creator.CleanupLinks()
finally:
for f in db_filenames:
if os.path.isfile(f):
os.remove(f)
return 0
if __name__ == '__main__':
sys.exit(main())

View file

@ -1,12 +1,5 @@
# This file is used by gcl to get repository specific information.
# This file is used by `git cl` to get repository specific information.
CODE_REVIEW_SERVER: codereview.chromium.org
#CC_LIST:
VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/
#STATUS:
FORCE_HTTPS_COMMIT_URL: True
GERRIT_HOST: True
PROJECT: libyuv
TRY_ON_UPLOAD: False
TRYSERVER_ROOT: src
TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-libyuv
#GITCL_PREUPLOAD:
#GITCL_PREDCOMMIT:
VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/

View file

@ -0,0 +1,441 @@
# Deprecated Builds
Older documentation on build configs which are no longer supported.
## Pre-requisites
You'll need to have depot tools installed: https://www.chromium.org/developers/how-tos/install-depot-tools
Refer to chromium instructions for each platform for other prerequisites.
## Getting the Code
Create a working directory, enter it, and run:
gclient config https://chromium.googlesource.com/libyuv/libyuv
gclient sync
Then you'll get a .gclient file like:
solutions = [
{ "name" : "libyuv",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
},
"safesync_url": "",
},
];
For iOS add `;target_os=['ios'];` to your OSX .gclient and run `GYP_DEFINES="OS=ios" gclient sync.`
Browse the Git reprository: https://chromium.googlesource.com/libyuv/libyuv/+/master
### Android
For Android add `;target_os=['android'];` to your Linux .gclient
solutions = [
{ "name" : "libyuv",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
},
"safesync_url": "",
},
];
target_os = ["android", "unix"];
Then run:
export GYP_DEFINES="OS=android"
gclient sync
Caveat: Theres an error with Google Play services updates. If you get the error "Your version of the Google Play services library is not up to date", run the following:
cd chromium/src
./build/android/play_services/update.py download
cd ../..
For Windows the gclient sync must be done from an Administrator command prompt.
The sync will generate native build files for your environment using gyp (Windows: Visual Studio, OSX: XCode, Linux: make). This generation can also be forced manually: `gclient runhooks`
To get just the source (not buildable):
git clone https://chromium.googlesource.com/libyuv/libyuv
## Building the Library and Unittests
### Windows
set GYP_DEFINES=target_arch=ia32
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -j7 -C out\Release
ninja -j7 -C out\Debug
set GYP_DEFINES=target_arch=x64
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -C out\Debug_x64
ninja -C out\Release_x64
#### Building with clangcl
set GYP_DEFINES=clang=1 target_arch=ia32
call python tools\clang\scripts\update.py
call python gyp_libyuv -fninja libyuv_test.gyp
ninja -C out\Debug
ninja -C out\Release
### OSX
Clang 64 bit shown. Remove `clang=1` for GCC and change x64 to ia32 for 32 bit.
GYP_DEFINES="clang=1 target_arch=x64" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
GYP_DEFINES="clang=1 target_arch=ia32" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
### iOS
http://www.chromium.org/developers/how-tos/build-instructions-ios
Add to .gclient last line: `target_os=['ios'];`
armv7
GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
arm64
GYP_DEFINES="OS=ios target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
both armv7 and arm64 (fat)
GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=both" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
simulator
GYP_DEFINES="OS=ios target_arch=ia32 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_sim" ./gyp_libyuv
ninja -j7 -C out_sim/Debug-iphonesimulator libyuv_unittest
ninja -j7 -C out_sim/Release-iphonesimulator libyuv_unittest
### Android
https://code.google.com/p/chromium/wiki/AndroidBuildInstructions
Add to .gclient last line: `target_os=['android'];`
armv7
GYP_DEFINES="OS=android" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug yuv_unittest_apk
ninja -j7 -C out/Release yuv_unittest_apk
arm64
GYP_DEFINES="OS=android target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug yuv_unittest_apk
ninja -j7 -C out/Release yuv_unittest_apk
ia32
GYP_DEFINES="OS=android target_arch=ia32" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug yuv_unittest_apk
ninja -j7 -C out/Release yuv_unittest_apk
GYP_DEFINES="OS=android target_arch=ia32 android_full_debug=1" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug yuv_unittest_apk
mipsel
GYP_DEFINES="OS=android target_arch=mipsel" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug yuv_unittest_apk
ninja -j7 -C out/Release yuv_unittest_apk
arm32 disassembly:
third_party/android_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump -d out/Release/obj/source/libyuv.row_neon.o
arm64 disassembly:
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d out/Release/obj/source/libyuv.row_neon64.o
Running tests:
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
Running test as benchmark:
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1"
Running test with C code:
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
#### Building with GN
gn gen out/Release "--args=is_debug=false target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_cpu=\"x86\""
ninja -C out/Release
ninja -C out/Debug
### Building Offical with GN
gn gen out/Official "--args=is_debug=false is_official_build=true is_chrome_branded=true"
ninja -C out/Official
#### Building mips with GN
mipsel
gn gen out/Default "--args=is_debug=false target_cpu=\"mipsel\" target_os = \"android\" mips_arch_variant = \"r6\" mips_use_msa = true is_component_build = true is_clang = false"
ninja -C out/Default
mips64el
gn gen out/Default "--args=is_debug=false target_cpu=\"mips64el\" target_os = \"android\" mips_arch_variant = \"r6\" mips_use_msa = true is_component_build = true is_clang = false"
ninja -C out/Default
### Linux
GYP_DEFINES="target_arch=x64" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
GYP_DEFINES="target_arch=ia32" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
#### CentOS
On CentOS 32 bit the following work around allows a sync:
export GYP_DEFINES="host_arch=ia32"
gclient sync
### Windows Shared Library
Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUILDING_SHARED_LIBRARY' to 'defines'.
gclient runhooks
After this command follow the building the library instructions above.
If you get a compile error for atlthunk.lib on Windows, read http://www.chromium.org/developers/how-tos/build-instructions-windows
### Build targets
ninja -C out/Debug libyuv
ninja -C out/Debug libyuv_unittest
ninja -C out/Debug compare
ninja -C out/Debug yuvconvert
ninja -C out/Debug yuvconstants
ninja -C out/Debug psnr
ninja -C out/Debug cpuid
## Building the Library with make
### Linux
make -j7 V=1 -f linux.mk
make -j7 V=1 -f linux.mk clean
make -j7 V=1 -f linux.mk CXX=clang++
## Building the Library with cmake
Install cmake: http://www.cmake.org/
Default debug build:
mkdir out
cd out
cmake ..
cmake --build .
Release build/install
mkdir out
cd out
cmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" ..
cmake --build . --config Release
sudo cmake --build . --target install --config Release
### Windows 8 Phone
Pre-requisite:
* Install Visual Studio 2012 and Arm to your environment.<br>
Then:
call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
or with Visual Studio 2013:
call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
nmake /f winarm.mk clean
nmake /f winarm.mk
### Windows Shared Library
Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUILDING_SHARED_LIBRARY' to 'defines'. Then run this.
gclient runhooks
After this command follow the building the library instructions above.
If you get a compile error for atlthunk.lib on Windows, read http://www.chromium.org/developers/how-tos/build-instructions-windows
### 64 bit Windows
set GYP_DEFINES=target_arch=x64
gclient runhooks V=1
### ARM Linux
export GYP_DEFINES="target_arch=arm"
export CROSSTOOL=`<path>`/arm-none-linux-gnueabi
export CXX=$CROSSTOOL-g++
export CC=$CROSSTOOL-gcc
export AR=$CROSSTOOL-ar
export AS=$CROSSTOOL-as
export RANLIB=$CROSSTOOL-ranlib
gclient runhooks
## Running Unittests
### Windows
out\Release\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter="*"
### OSX
out/Release/libyuv_unittest --gtest_filter="*"
### Linux
out/Release/libyuv_unittest --gtest_filter="*"
Replace --gtest_filter="*" with specific unittest to run. May include wildcards. e.g.
out/Release/libyuv_unittest --gtest_filter=libyuvTest.I420ToARGB_Opt
## CPU Emulator tools
### Intel SDE (Software Development Emulator)
Pre-requisite: Install IntelSDE for Windows: http://software.intel.com/en-us/articles/intel-software-development-emulator
Then run:
c:\intelsde\sde -hsw -- out\release\libyuv_unittest.exe --gtest_filter=*
## Memory tools
### Running Dr Memory memcheck for Windows
Pre-requisite: Install Dr Memory for Windows and add it to your path: http://www.drmemory.org/docs/page_install_windows.html
set GYP_DEFINES=build_for_tool=drmemory target_arch=ia32
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -C out\Debug
drmemory out\Debug\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter=*
### Running UBSan
See Chromium instructions for sanitizers: https://www.chromium.org/developers/testing/undefinedbehaviorsanitizer
Sanitizers available: TSan, MSan, ASan, UBSan, LSan
GYP_DEFINES='ubsan=1' gclient runhooks
ninja -C out/Release
### Running Valgrind memcheck
Memory errors and race conditions can be found by running tests under special memory tools. [Valgrind] [1] is an instrumentation framework for building dynamic analysis tools. Various tests and profilers are built upon it to find memory handling errors and memory leaks, for instance.
[1]: http://valgrind.org
solutions = [
{ "name" : "libyuv",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
"libyuv/chromium/src/third_party/valgrind": "https://chromium.googlesource.com/chromium/deps/valgrind/binaries",
},
"safesync_url": "",
},
]
Then run:
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=memcheck" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more information, see http://www.chromium.org/developers/how-tos/using-valgrind
### Running Thread Sanitizer (TSan)
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=tsan" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more info, see http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer
### Running Address Sanitizer (ASan)
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=asan" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more info, see http://dev.chromium.org/developers/testing/addresssanitizer
## Benchmarking
The unittests can be used to benchmark.
### Windows
set LIBYUV_WIDTH=1280
set LIBYUV_HEIGHT=720
set LIBYUV_REPEAT=999
set LIBYUV_FLAGS=-1
out\Release\libyuv_unittest.exe --gtest_filter=*I420ToARGB_Opt
### Linux and Mac
LIBYUV_WIDTH=1280 LIBYUV_HEIGHT=720 LIBYUV_REPEAT=1000 out/Release/libyuv_unittest --gtest_filter=*I420ToARGB_Opt
libyuvTest.I420ToARGB_Opt (547 ms)
Indicates 0.547 ms/frame for 1280 x 720.
## Making a change
gclient sync
git checkout -b mycl -t origin/master
git pull
<edit files>
git add -u
git commit -m "my change"
git cl lint
git cl try
git cl upload -r a-reviewer@chomium.org -s
<once approved..>
git cl land

View file

@ -6,7 +6,10 @@ For test purposes, environment variables can be set to control libyuv behavior.
By default the cpu is detected and the most advanced form of SIMD is used. But you can disable instruction sets selectively, or completely, falling back on C code. Set the variable to 1 to disable the specified instruction set.
## All CPUs
LIBYUV_DISABLE_ASM
## Intel CPUs
LIBYUV_DISABLE_X86
LIBYUV_DISABLE_SSE2
LIBYUV_DISABLE_SSSE3
@ -14,12 +17,29 @@ By default the cpu is detected and the most advanced form of SIMD is used. But
LIBYUV_DISABLE_SSE42
LIBYUV_DISABLE_AVX
LIBYUV_DISABLE_AVX2
LIBYUV_DISABLE_AVX3
LIBYUV_DISABLE_ERMS
LIBYUV_DISABLE_FMA3
LIBYUV_DISABLE_DSPR2
LIBYUV_DISABLE_F16C
LIBYUV_DISABLE_AVX512BW
LIBYUV_DISABLE_AVX512VL
LIBYUV_DISABLE_AVX512VNNI
LIBYUV_DISABLE_AVX512VBMI
LIBYUV_DISABLE_AVX512VBMI2
LIBYUV_DISABLE_AVX512VBITALG
LIBYUV_DISABLE_AVX512VPOPCNTDQ
LIBYUV_DISABLE_GFNI
## ARM CPUs
LIBYUV_DISABLE_NEON
## MIPS CPUs
LIBYUV_DISABLE_MSA
## LOONGARCH CPUs
LIBYUV_DISABLE_LSX
LIBYUV_DISABLE_LASX
# Test Width/Height/Repeat
The unittests default to a small image (128x72) to run fast. This can be set by environment variable to test a specific resolutions.

View file

@ -4,7 +4,9 @@ Formats (FOURCC) supported by libyuv are detailed here.
# Core Formats
There are 2 core formats supported by libyuv - I420 and ARGB. All YUV formats can be converted to/from I420. All RGB formats can be converted to/from ARGB.
There are 2 core formats supported by libyuv - I420 and ARGB.
All YUV formats can be converted to/from I420.
All RGB formats can be converted to/from ARGB.
Filtering functions such as scaling and planar functions work on I420 and/or ARGB.
@ -35,50 +37,53 @@ This is how OSX formats map to libyuv
# FOURCC (Four Charactacter Code) List
The following is extracted from video_common.h as a complete list of formats supported by libyuv.
enum FourCC {
// 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
// 10 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
FOURCC_I420 = FOURCC('I', '4', '2', '0'),
FOURCC_I422 = FOURCC('I', '4', '2', '2'),
FOURCC_I444 = FOURCC('I', '4', '4', '4'),
FOURCC_I411 = FOURCC('I', '4', '1', '1'),
FOURCC_I400 = FOURCC('I', '4', '0', '0'),
FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
FOURCC_H010 = FOURCC('H', '0', '1', '0'), // unofficial fourcc. 10 bit lsb
FOURCC_U010 = FOURCC('U', '0', '1', '0'), // bt.2020, unofficial fourcc.
// 10 bit lsb
// 2 Secondary YUV formats: row biplanar.
FOURCC_M420 = FOURCC('M', '4', '2', '0'),
FOURCC_Q420 = FOURCC('Q', '4', '2', '0'),
// 1 Secondary YUV format: row biplanar.
FOURCC_M420 = FOURCC('M', '4', '2', '0'), // deprecated.
// 9 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp.
// 13 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc, 2 64 bpp
FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010.
FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit
FOURCC_AR64 = FOURCC('A', 'R', '6', '4'), // 16 bit per channel.
FOURCC_AB64 = FOURCC('A', 'B', '6', '4'), // ABGR version of 16 bit
FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE.
FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE.
// 4 Secondary RGB formats: 4 Bayer Patterns.
FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'),
FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'),
FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'),
// 1 Primary Compressed YUV format.
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
// 5 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
// 11 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
FOURCC_J420 = FOURCC('J', '4', '2', '0'),
FOURCC_J400 = FOURCC('J', '4', '0', '0'),
FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc
FOURCC_U420 = FOURCC('U', '4', '2', '0'), // bt.2020, unofficial fourcc
FOURCC_U422 = FOURCC('U', '4', '2', '2'), // bt.2020, unofficial fourcc
FOURCC_U444 = FOURCC('U', '4', '4', '4'), // bt.2020, unofficial fourcc
// 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
@ -99,8 +104,35 @@ The following is extracted from video_common.h as a complete list of formats sup
FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP.
FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO.
// 1 Auxiliary compressed YUV format set aside for capturer.
FOURCC_H264 = FOURCC('H', '2', '6', '4'),
# Planar YUV
The following formats contains a full size Y plane followed by 1 or 2
planes for UV: I420, I422, I444, I400, NV21, NV12, I400
The size (subsampling) of the UV varies.
I420, NV12 and NV21 are half width, half height
I422, NV16 and NV61 are half width, full height
I444, NV24 and NV42 are full width, full height
I400 and J400 have no chroma channel.
# Color space
The YUV formats start with a letter to specify the color space. e.g. I420
I = BT.601 limited range
J = BT.601 full range (J = JPEG that uses this)
H = BT.709 limited range (H for HD)
F = BT.709 full range (F for Full range)
U = BT.2020 limited range (U for UHD)
V = BT.2020 full range
For YUV to RGB conversions, a matrix can be passed. See also convert_argh.h
# HDR formats
Planar formats with 10 or 12 bits use the following fourcc:
I010, I012, P010, P012 are half width, half height
I210, I212, P210, P212 are half width, full height
I410, I412, P410, P412 are full width, full height
where
I is the color space (see above) and 3 planes: Y, U and V.
P is a biplanar format, similar to NV12 but 16 bits, with the valid bits in the high bits. There is a Y plane and a UV plane.
0, 2 or 4 is the last digit of subsampling: 4:2:0, 4:2:2, or 4:4:4
10 or 12 is the bits per channel. The bits are in the low bits of a 16 bit channel.
# The ARGB FOURCC
@ -131,3 +163,46 @@ Some are channel order agnostic (e.g. ARGBScale).
Some functions are symmetric (e.g. ARGBToBGRA is the same as BGRAToARGB, so its a macro).
ARGBBlend expects preattenuated ARGB. The R,G,B are premultiplied by alpha. Other functions don't care.
# RGB24 and RAW
There are 2 RGB layouts - RGB24 (aka 24BG) and RAW
RGB24 is B,G,R in memory
RAW is R,G,B in memory
# AR30 and XR30
AR30 is 2 10 10 10 ARGB stored in little endian order.
The 2 bit alpha has 4 values. Here are the comparable 8 bit alpha values.
0 - 0. 00000000b = 0x00 = 0
1 - 33%. 01010101b = 0x55 = 85
2 - 66%. 10101010b = 0xaa = 170
3 - 100%. 11111111b = 0xff = 255
The 10 bit RGB values range from 0 to 1023.
XR30 is the same as AR30 but with no alpha channel.
# AB64 and AR64
AB64 is similar to ABGR, with 16 bit (2 bytes) per channel. Each channel stores an unsigned short.
In memory R is the lowest and A is the highest.
Each channel has value ranges from 0 to 65535.
AR64 is similar to ARGB.
# NV12 and NV21
NV12 is a biplanar format with a full sized Y plane followed by a single
chroma plane with weaved U and V values.
NV21 is the same but with weaved V and U values.
The 12 in NV12 refers to 12 bits per pixel. NV12 has a half width and half
height chroma channel, and therefore is a 420 subsampling.
NV16 is 16 bits per pixel, with half width and full height. aka 422.
NV24 is 24 bits per pixel with full sized chroma channel. aka 444.
Most NV12 functions allow the destination Y pointer to be NULL.
# YUY2 and UYVY
YUY2 is a packed YUV format with half width, full height.
YUY2 is YUYV in memory
UYVY is UYVY in memory

View file

@ -11,14 +11,13 @@ Refer to chromium instructions for each platform for other prerequisites.
Create a working directory, enter it, and run:
gclient config https://chromium.googlesource.com/libyuv/libyuv
gclient config --name src https://chromium.googlesource.com/libyuv/libyuv
gclient sync
Then you'll get a .gclient file like:
solutions = [
{ "name" : "libyuv",
{ "name" : "src",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
@ -28,17 +27,15 @@ Then you'll get a .gclient file like:
},
];
For iOS add `;target_os=['ios'];` to your OSX .gclient and run `GYP_DEFINES="OS=ios" gclient sync.`
For iOS add `;target_os=['ios'];` to your OSX .gclient and run `gclient sync.`
Browse the Git reprository: https://chromium.googlesource.com/libyuv/libyuv/+/master
### Android
For Android add `;target_os=['android'];` to your Linux .gclient
solutions = [
{ "name" : "libyuv",
{ "name" : "src",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
@ -47,23 +44,14 @@ For Android add `;target_os=['android'];` to your Linux .gclient
"safesync_url": "",
},
];
target_os = ["android", "unix"];
target_os = ["android", "linux"];
Then run:
export GYP_DEFINES="OS=android"
gclient sync
Caveat: Theres an error with Google Play services updates. If you get the error "Your version of the Google Play services library is not up to date", run the following:
cd chromium/src
./build/android/play_services/update.py download
cd ../..
For Windows the gclient sync must be done from an Administrator command prompt.
The sync will generate native build files for your environment using gyp (Windows: Visual Studio, OSX: XCode, Linux: make). This generation can also be forced manually: `gclient runhooks`
To get just the source (not buildable):
git clone https://chromium.googlesource.com/libyuv/libyuv
@ -71,187 +59,152 @@ To get just the source (not buildable):
### Windows
set GYP_DEFINES=target_arch=ia32
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -j7 -C out\Release
ninja -j7 -C out\Debug
call gn gen out\Release "--args=is_debug=false target_cpu=\"x64\""
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x64\""
ninja -v -C out\Release
ninja -v -C out\Debug
set GYP_DEFINES=target_arch=x64
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -C out\Debug_x64
ninja -C out\Release_x64
call gn gen out\Release "--args=is_debug=false target_cpu=\"x86\""
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x86\""
ninja -v -C out\Release
ninja -v -C out\Debug
#### Building with clangcl
set GYP_DEFINES=clang=1 target_arch=ia32 libyuv_enable_svn=1
set LLVM_REPO_URL=svn://svn.chromium.org/llvm-project
call python tools\clang\scripts\update.py
call python gyp_libyuv -fninja libyuv_test.gyp
ninja -C out\Debug
ninja -C out\Release
### macOS and Linux
### OSX
Clang 64 bit shown. Remove `clang=1` for GCC and change x64 to ia32 for 32 bit.
GYP_DEFINES="clang=1 target_arch=x64" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
GYP_DEFINES="clang=1 target_arch=ia32" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
### iOS
http://www.chromium.org/developers/how-tos/build-instructions-ios
Add to .gclient last line: `target_os=['ios'];`
armv7
GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
arm64
GYP_DEFINES="OS=ios target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
both armv7 and arm64 (fat)
GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=both" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv
ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest
ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest
simulator
GYP_DEFINES="OS=ios target_arch=ia32 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_sim" ./gyp_libyuv
ninja -j7 -C out_sim/Debug-iphonesimulator libyuv_unittest
ninja -j7 -C out_sim/Release-iphonesimulator libyuv_unittest
### Android
https://code.google.com/p/chromium/wiki/AndroidBuildInstructions
Add to .gclient last line: `target_os=['android'];`
armv7
GYP_DEFINES="OS=android" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug libyuv_unittest_apk
ninja -j7 -C out/Release libyuv_unittest_apk
arm64
GYP_DEFINES="OS=android target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug libyuv_unittest_apk
ninja -j7 -C out/Release libyuv_unittest_apk
ia32
GYP_DEFINES="OS=android target_arch=ia32" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug libyuv_unittest_apk
ninja -j7 -C out/Release libyuv_unittest_apk
GYP_DEFINES="OS=android target_arch=ia32 android_full_debug=1" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug libyuv_unittest_apk
mipsel
GYP_DEFINES="OS=android target_arch=mipsel" GYP_CROSSCOMPILE=1 ./gyp_libyuv
ninja -j7 -C out/Debug libyuv_unittest_apk
ninja -j7 -C out/Release libyuv_unittest_apk
arm32 disassembly:
third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump -d out/Release/obj/source/libyuv.row_neon.o
arm64 disassembly:
third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d out/Release/obj/source/libyuv.row_neon64.o
Running tests:
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
Running test as benchmark:
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1"
Running test with C code:
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
#### Building with GN
gn gen out/Release "--args=is_debug=false target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_cpu=\"x86\""
ninja -C out/Release
ninja -C out/Debug
gn gen out/Release "--args=is_debug=false"
gn gen out/Debug "--args=is_debug=true"
ninja -v -C out/Release
ninja -v -C out/Debug
### Building Offical with GN
gn gen out/Official "--args=is_debug=false is_official_build=true is_chrome_branded=true"
ninja -C out/Official
### Linux
### iOS
http://www.chromium.org/developers/how-tos/build-instructions-ios
GYP_DEFINES="target_arch=x64" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
Add to .gclient last line: `target_os=['ios'];`
GYP_DEFINES="target_arch=ia32" ./gyp_libyuv
ninja -j7 -C out/Debug
ninja -j7 -C out/Release
arm64
#### CentOS
gn gen out/Release "--args=is_debug=false target_os=\"ios\" ios_enable_code_signing=false target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_os=\"ios\" ios_enable_code_signing=false target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
On CentOS 32 bit the following work around allows a sync:
ios simulator
export GYP_DEFINES="host_arch=ia32"
gclient sync
gn gen out/Release "--args=is_debug=false target_os=\"ios\" ios_enable_code_signing=false use_xcode_clang=true target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_os=\"ios\" ios_enable_code_signing=false use_xcode_clang=true target_cpu=\"x86\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
### Windows Shared Library
ios disassembly
Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUILDING_SHARED_LIBRARY' to 'defines'.
otool -tV ./out/Release/obj/libyuv_neon/row_neon64.o >row_neon64.txt
gclient runhooks
### Android
https://code.google.com/p/chromium/wiki/AndroidBuildInstructions
After this command follow the building the library instructions above.
Add to .gclient last line: `target_os=['android'];`
If you get a compile error for atlthunk.lib on Windows, read http://www.chromium.org/developers/how-tos/build-instructions-windows
arm64
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
armv7
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"arm\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"arm\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
ia32
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"x86\""
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"x86\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
mips
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
arm disassembly:
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv/row_common.o >row_common.txt
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv_neon/row_neon.o >row_neon.txt
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv_neon/row_neon64.o >row_neon64.txt
Caveat: Disassembly may require optimize_max be disabled in BUILD.gn
Running tests:
out/Release/bin/run_libyuv_unittest -vv --gtest_filter=*
Running test as benchmark:
out/Release/bin/run_libyuv_unittest -vv --gtest_filter=* --libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1 --libyuv_cpu_info=-1
Running test with C code:
out/Release/bin/run_libyuv_unittest -vv --gtest_filter=* --libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1
### Build targets
ninja -C out/Debug libyuv
ninja -C out/Debug libyuv_unittest
ninja -C out/Debug compare
ninja -C out/Debug convert
ninja -C out/Debug yuvconvert
ninja -C out/Debug yuvconstants
ninja -C out/Debug psnr
ninja -C out/Debug cpuid
### ARM Linux
gn gen out/Release "--args=is_debug=false target_cpu=\"arm64\""
gn gen out/Debug "--args=is_debug=true target_cpu=\"arm64\""
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
### MIPS Linux
mips
gn gen out/Release "--args=is_debug=false target_os=\"linux\" target_cpu=\"mips64el\" mips_arch_variant=\"loongson3\" is_component_build=false use_sysroot=false use_gold=false"
gn gen out/Debug "--args=is_debug=true target_os=\"linux\" target_cpu=\"mips64el\" mips_arch_variant=\"loongson3\" is_component_build=false use_sysroot=false use_gold=false"
ninja -v -C out/Debug libyuv_unittest
ninja -v -C out/Release libyuv_unittest
## Building the Library with make
### Linux
make -j7 V=1 -f linux.mk
make -j7 V=1 -f linux.mk clean
make -j7 V=1 -f linux.mk CXX=clang++
make V=1 -f linux.mk
make V=1 -f linux.mk clean
make V=1 -f linux.mk CXX=clang++ CC=clang
## Building the Library with cmake
## Building the library with cmake
Install cmake: http://www.cmake.org/
Default debug build:
### Default debug build:
mkdir out
cd out
cmake ..
cmake --build .
Release build/install
### Release build/install
mkdir out
cd out
@ -259,47 +212,31 @@ Release build/install
cmake --build . --config Release
sudo cmake --build . --target install --config Release
### Windows 8 Phone
### Build RPM/DEB packages
Pre-requisite:
mkdir out
cd out
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
make package
* Install Visual Studio 2012 and Arm to your environment.<br>
## Setup for Arm Cross compile
Then:
See also https://www.ccoderun.ca/programming/2015-12-20_CrossCompiling/index.html
call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
sudo apt-get install ssh dkms build-essential linux-headers-generic
sudo apt-get install kdevelop cmake git subversion
sudo apt-get install graphviz doxygen doxygen-gui
sudo apt-get install manpages manpages-dev manpages-posix manpages-posix-dev
sudo apt-get install libboost-all-dev libboost-dev libssl-dev
sudo apt-get install rpm terminator fish
sudo apt-get install g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
or with Visual Studio 2013:
### Build psnr tool
call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_arm\vcvarsx86_arm.bat"
nmake /f winarm.mk clean
nmake /f winarm.mk
### Windows Shared Library
Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUILDING_SHARED_LIBRARY' to 'defines'. Then run this.
gclient runhooks
After this command follow the building the library instructions above.
If you get a compile error for atlthunk.lib on Windows, read http://www.chromium.org/developers/how-tos/build-instructions-windows
### 64 bit Windows
set GYP_DEFINES=target_arch=x64
gclient runhooks V=1
### ARM Linux
export GYP_DEFINES="target_arch=arm"
export CROSSTOOL=`<path>`/arm-none-linux-gnueabi
export CXX=$CROSSTOOL-g++
export CC=$CROSSTOOL-gcc
export AR=$CROSSTOOL-ar
export AS=$CROSSTOOL-as
export RANLIB=$CROSSTOOL-ranlib
gclient runhooks
cd util
arm-linux-gnueabihf-g++ psnr_main.cc psnr.cc ssim.cc -o psnr
arm-linux-gnueabihf-objdump -d psnr
## Running Unittests
@ -307,123 +244,42 @@ If you get a compile error for atlthunk.lib on Windows, read http://www.chromium
out\Release\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter="*"
### OSX
### macOS and Linux
out/Release/libyuv_unittest --gtest_filter="*"
### Linux
out/Release/libyuv_unittest --gtest_filter="*"
Replace --gtest_filter="*" with specific unittest to run. May include wildcards. e.g.
out/Release/libyuv_unittest --gtest_filter=libyuvTest.I420ToARGB_Opt
Replace --gtest_filter="*" with specific unittest to run. May include wildcards.
out/Release/libyuv_unittest --gtest_filter=*I420ToARGB_Opt
## CPU Emulator tools
### Intel SDE (Software Development Emulator)
Pre-requisite: Install IntelSDE for Windows: http://software.intel.com/en-us/articles/intel-software-development-emulator
Pre-requisite: Install IntelSDE: http://software.intel.com/en-us/articles/intel-software-development-emulator
Then run:
c:\intelsde\sde -hsw -- out\release\libyuv_unittest.exe --gtest_filter=*
c:\intelsde\sde -hsw -- out\Release\libyuv_unittest.exe --gtest_filter=*
~/intelsde/sde -skx -- out/Release/libyuv_unittest --gtest_filter=**I420ToARGB_Opt
## Memory tools
### Intel Architecture Code Analyzer
Inset these 2 macros into assembly code to be analyzed:
IACA_ASM_START
IACA_ASM_END
Build the code as usual, then run iaca on the object file.
~/iaca-lin64/bin/iaca.sh -reduceout -arch HSW out/Release/obj/libyuv_internal/compare_gcc.o
## Sanitizers
gn gen out/Release "--args=is_debug=false is_msan=true"
ninja -v -C out/Release
Sanitizers available: asan, msan, tsan, ubsan, lsan, ubsan_vptr
### Running Dr Memory memcheck for Windows
Pre-requisite: Install Dr Memory for Windows and add it to your path: http://www.drmemory.org/docs/page_install_windows.html
set GYP_DEFINES=build_for_tool=drmemory target_arch=ia32
call python gyp_libyuv -fninja -G msvs_version=2013
ninja -C out\Debug
drmemory out\Debug\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter=*
### Running UBSan
See Chromium instructions for sanitizers: https://www.chromium.org/developers/testing/undefinedbehaviorsanitizer
Sanitizers available: TSan, MSan, ASan, UBSan, LSan
GYP_DEFINES='ubsan=1' gclient runhooks
ninja -C out/Release
### Running Valgrind memcheck
Memory errors and race conditions can be found by running tests under special memory tools. [Valgrind] [1] is an instrumentation framework for building dynamic analysis tools. Various tests and profilers are built upon it to find memory handling errors and memory leaks, for instance.
[1]: http://valgrind.org
solutions = [
{ "name" : "libyuv",
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
"libyuv/chromium/src/third_party/valgrind": "https://chromium.googlesource.com/chromium/deps/valgrind/binaries",
},
"safesync_url": "",
},
]
Then run:
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=memcheck" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more information, see http://www.chromium.org/developers/how-tos/using-valgrind
### Running Thread Sanitizer (TSan)
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=tsan" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more info, see http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer
### Running Address Sanitizer (ASan)
GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=asan" python gyp_libyuv
ninja -C out/Debug
valgrind out/Debug/libyuv_unittest
For more info, see http://dev.chromium.org/developers/testing/addresssanitizer
## Benchmarking
The unittests can be used to benchmark.
### Windows
set LIBYUV_WIDTH=1280
set LIBYUV_HEIGHT=720
set LIBYUV_REPEAT=999
set LIBYUV_FLAGS=-1
out\Release\libyuv_unittest.exe --gtest_filter=*I420ToARGB_Opt
### Linux and Mac
LIBYUV_WIDTH=1280 LIBYUV_HEIGHT=720 LIBYUV_REPEAT=1000 out/Release/libyuv_unittest --gtest_filter=*I420ToARGB_Opt
libyuvTest.I420ToARGB_Opt (547 ms)
Indicates 0.547 ms/frame for 1280 x 720.
## Making a change
gclient sync
git checkout -b mycl -t origin/master
git pull
<edit files>
git add -u
git commit -m "my change"
git cl lint
git cl try
git cl upload -r a-reviewer@chomium.org -s
<once approved..>
git cl land

View file

@ -100,4 +100,8 @@ Inverting can be achieved with almost any libyuv function by passing a negative
I420Mirror and ARGBMirror can also be used to rotate by 180 degrees by passing a negative height.
# Cropping - Vertical Flip
When cropping from a subsampled format like NV21, the method of setting the start pointers wont work for odd crop start y on the UV plane.
If the height after cropping will be odd, invert the source - point to the last row, negate the strides, and pass negative height, which
will re-invert the image as the conversion outputs.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python
#
#!/usr/bin/env vpython3
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
@ -22,7 +22,7 @@ sys.path.insert(0, os.path.join(checkout_root, 'build'))
sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools'))
import vs_toolchain
import vs_toolchain # pylint: disable=wrong-import-position
if __name__ == '__main__':

View file

@ -1,101 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# This script is used to run GYP for libyuv. It contains selected parts of the
# main function from the src/build/gyp_chromium file.
import glob
import os
import shlex
import sys
checkout_root = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(checkout_root, 'build'))
import gyp_chromium
import gyp_helper
import vs_toolchain
sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib'))
import gyp
def GetSupplementalFiles():
"""Returns a list of the supplemental files that are included in all GYP
sources."""
# Can't use the one in gyp_chromium since the directory location of the root
# is different.
return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi'))
if __name__ == '__main__':
args = sys.argv[1:]
if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
print 'Skipping gyp_libyuv due to GYP_CHROMIUM_NO_ACTION env var.'
sys.exit(0)
# This could give false positives since it doesn't actually do real option
# parsing. Oh well.
gyp_file_specified = False
for arg in args:
if arg.endswith('.gyp'):
gyp_file_specified = True
break
# If we didn't get a file, assume 'all.gyp' in the root of the checkout.
if not gyp_file_specified:
# Because of a bug in gyp, simply adding the abspath to all.gyp doesn't
# work, but chdir'ing and adding the relative path does. Spooky :/
os.chdir(checkout_root)
args.append('all.gyp')
# There shouldn't be a circular dependency relationship between .gyp files,
args.append('--no-circular-check')
# Default to ninja unless GYP_GENERATORS is set.
if not os.environ.get('GYP_GENERATORS'):
os.environ['GYP_GENERATORS'] = 'ninja'
vs2013_runtime_dll_dirs = None
if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')):
vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
# Enforce gyp syntax checking. This adds about 20% execution time.
args.append('--check')
supplemental_includes = gyp_chromium.GetSupplementalFiles()
gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes)
# Automatically turn on crosscompile support for platforms that need it.
if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
gyp_vars_dict.get('OS') in ['android', 'ios'],
'GYP_CROSSCOMPILE' not in os.environ)):
os.environ['GYP_CROSSCOMPILE'] = '1'
args.extend(['-I' + i for i in
gyp_chromium.additional_include_files(supplemental_includes,
args)])
# Set the gyp depth variable to the root of the checkout.
args.append('--depth=' + os.path.relpath(checkout_root))
print 'Updating projects from gyp files...'
sys.stdout.flush()
# Off we go...
gyp_rc = gyp.main(args)
if vs2013_runtime_dll_dirs:
x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
vs_toolchain.CopyVsRuntimeDlls(
os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
(x86_runtime, x64_runtime))
sys.exit(gyp_rc)

View file

@ -1,28 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# This script is a modified copy of the src/build/gyp_chromium.py file.
# It is needed for parallel processing.
# This file is (possibly, depending on python version) imported by
# gyp_libyuv when GYP_PARALLEL=1 and it creates sub-processes
# through the multiprocessing library.
# Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for
# imports that don't end in .py (and aren't directories with an
# __init__.py). This wrapper makes "import gyp_libyuv" work with
# those old versions and makes it possible to execute gyp_libyuv.py
# directly on Windows where the extension is useful.
import os
path = os.path.abspath(os.path.split(__file__)[0])
execfile(os.path.join(path, 'gyp_libyuv'))

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_H_
#define INCLUDE_LIBYUV_H_
#include "libyuv/basic_types.h"
@ -26,7 +26,8 @@
#include "libyuv/scale.h"
#include "libyuv/scale_argb.h"
#include "libyuv/scale_row.h"
#include "libyuv/scale_uv.h"
#include "libyuv/version.h"
#include "libyuv/video_common.h"
#endif // INCLUDE_LIBYUV_H_ NOLINT
#endif // INCLUDE_LIBYUV_H_

View file

@ -8,96 +8,39 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_
#define INCLUDE_LIBYUV_BASIC_TYPES_H_
#include <stddef.h> // for NULL, size_t
#include <stddef.h> // For size_t and NULL
#if !(defined(_MSC_VER) && (_MSC_VER < 1600))
#include <stdint.h> // for uintptr_t
#endif
typedef uint64_t uint64;
typedef int64_t int64;
#if defined(_MSC_VER)
// nsprpub/pr/include/obsolete/protypes.h defines these weirdly
typedef long int32;
typedef unsigned long uint32;
#else
typedef uint32_t uint32;
typedef int32_t int32;
#endif
typedef uint16_t uint16;
typedef int16_t int16;
typedef uint8_t uint8;
typedef int8_t int8;
#define INT_TYPES_DEFINED 1
#ifndef GG_LONGLONG
#ifndef INT_TYPES_DEFINED
#if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG)
#define INT_TYPES_DEFINED
#ifdef COMPILER_MSVC
typedef unsigned __int64 uint64;
typedef __int64 int64;
#ifndef INT64_C
#define INT64_C(x) x ## I64
#endif
#ifndef UINT64_C
#define UINT64_C(x) x ## UI64
#endif
#define INT64_F "I64"
#else // COMPILER_MSVC
#if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
typedef unsigned long uint64; // NOLINT
typedef long int64; // NOLINT
#ifndef INT64_C
#define INT64_C(x) x ## L
#endif
#ifndef UINT64_C
#define UINT64_C(x) x ## UL
#endif
#define INT64_F "l"
#else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
typedef unsigned long long uint64; // NOLINT
typedef long long int64; // NOLINT
#ifndef INT64_C
#define INT64_C(x) x ## LL
#endif
#ifndef UINT64_C
#define UINT64_C(x) x ## ULL
#endif
#define INT64_F "ll"
#endif // __LP64__
#endif // COMPILER_MSVC
typedef unsigned int uint32;
typedef int int32;
typedef unsigned short uint16; // NOLINT
typedef short int16; // NOLINT
typedef unsigned char uint8;
typedef signed char int8;
#endif // INT_TYPES_DEFINED
#endif // GG_LONGLONG
// Detect compiler is for x86 or x64.
#if defined(__x86_64__) || defined(_M_X64) || \
defined(__i386__) || defined(_M_IX86)
#define CPU_X86 1
#endif
// Detect compiler is for ARM.
#if defined(__arm__) || defined(_M_ARM)
#define CPU_ARM 1
#endif
#ifndef ALIGNP
#ifdef __cplusplus
#define ALIGNP(p, t) \
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
((t) - 1)) & ~((t) - 1))))
#if defined(_MSC_VER) && (_MSC_VER < 1600)
#include <sys/types.h> // for uintptr_t on x86
typedef unsigned __int64 uint64_t;
typedef __int64 int64_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned char uint8_t;
typedef signed char int8_t;
#else
#define ALIGNP(p, t) \
((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */
#endif
#endif
#include <stdint.h> // for uintptr_t and C99 types
#endif // defined(_MSC_VER) && (_MSC_VER < 1600)
// Types are deprecated. Enable this macro for legacy types.
#ifdef LIBYUV_LEGACY_TYPES
typedef uint64_t uint64;
typedef int64_t int64;
typedef uint32_t uint32;
typedef int32_t int32;
typedef uint16_t uint16;
typedef int16_t int16;
typedef uint8_t uint8;
typedef int8_t int8;
#endif // LIBYUV_LEGACY_TYPES
#endif // INT_TYPES_DEFINED
#if !defined(LIBYUV_API)
#if defined(_WIN32) || defined(__CYGWIN__)
@ -109,24 +52,17 @@ typedef signed char int8;
#define LIBYUV_API
#endif // LIBYUV_BUILDING_SHARED_LIBRARY
#elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \
(defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
defined(LIBYUV_USING_SHARED_LIBRARY))
#define LIBYUV_API __attribute__ ((visibility ("default")))
(defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
defined(LIBYUV_USING_SHARED_LIBRARY))
#define LIBYUV_API __attribute__((visibility("default")))
#else
#define LIBYUV_API
#endif // __GNUC__
#endif // LIBYUV_API
// TODO(fbarchard): Remove bool macros.
#define LIBYUV_BOOL int
#define LIBYUV_FALSE 0
#define LIBYUV_TRUE 1
// Visual C x86 or GCC little endian.
#if defined(__x86_64__) || defined(_M_X64) || \
defined(__i386__) || defined(_M_IX86) || \
defined(__arm__) || defined(_M_ARM) || \
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define LIBYUV_LITTLE_ENDIAN
#endif
#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT
#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_COMPARE_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_COMPARE_H_
#define INCLUDE_LIBYUV_COMPARE_H_
#include "libyuv/basic_types.h"
@ -20,59 +20,92 @@ extern "C" {
// Compute a hash for specified memory. Seed of 5381 recommended.
LIBYUV_API
uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed);
uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed);
// Hamming Distance
LIBYUV_API
uint64_t ComputeHammingDistance(const uint8_t* src_a,
const uint8_t* src_b,
int count);
// Scan an opaque argb image and return fourcc based on alpha offset.
// Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown.
LIBYUV_API
uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height);
uint32_t ARGBDetect(const uint8_t* argb,
int stride_argb,
int width,
int height);
// Sum Square Error - used to compute Mean Square Error or PSNR.
LIBYUV_API
uint64 ComputeSumSquareError(const uint8* src_a,
const uint8* src_b, int count);
uint64_t ComputeSumSquareError(const uint8_t* src_a,
const uint8_t* src_b,
int count);
LIBYUV_API
uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a,
int stride_a,
const uint8_t* src_b,
int stride_b,
int width,
int height);
static const int kMaxPsnr = 128;
LIBYUV_API
double SumSquareErrorToPsnr(uint64 sse, uint64 count);
double SumSquareErrorToPsnr(uint64_t sse, uint64_t count);
LIBYUV_API
double CalcFramePsnr(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
double CalcFramePsnr(const uint8_t* src_a,
int stride_a,
const uint8_t* src_b,
int stride_b,
int width,
int height);
LIBYUV_API
double I420Psnr(const uint8* src_y_a, int stride_y_a,
const uint8* src_u_a, int stride_u_a,
const uint8* src_v_a, int stride_v_a,
const uint8* src_y_b, int stride_y_b,
const uint8* src_u_b, int stride_u_b,
const uint8* src_v_b, int stride_v_b,
int width, int height);
double I420Psnr(const uint8_t* src_y_a,
int stride_y_a,
const uint8_t* src_u_a,
int stride_u_a,
const uint8_t* src_v_a,
int stride_v_a,
const uint8_t* src_y_b,
int stride_y_b,
const uint8_t* src_u_b,
int stride_u_b,
const uint8_t* src_v_b,
int stride_v_b,
int width,
int height);
LIBYUV_API
double CalcFrameSsim(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
double CalcFrameSsim(const uint8_t* src_a,
int stride_a,
const uint8_t* src_b,
int stride_b,
int width,
int height);
LIBYUV_API
double I420Ssim(const uint8* src_y_a, int stride_y_a,
const uint8* src_u_a, int stride_u_a,
const uint8* src_v_a, int stride_v_a,
const uint8* src_y_b, int stride_y_b,
const uint8* src_u_b, int stride_u_b,
const uint8* src_v_b, int stride_v_b,
int width, int height);
double I420Ssim(const uint8_t* src_y_a,
int stride_y_a,
const uint8_t* src_u_a,
int stride_u_a,
const uint8_t* src_v_a,
int stride_v_a,
const uint8_t* src_y_b,
int stride_y_b,
const uint8_t* src_u_b,
int stride_u_b,
const uint8_t* src_v_b,
int stride_v_b,
int width,
int height);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
#endif
#endif // INCLUDE_LIBYUV_COMPARE_H_ NOLINT
#endif // INCLUDE_LIBYUV_COMPARE_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_
#define INCLUDE_LIBYUV_COMPARE_ROW_H_
#include "libyuv/basic_types.h"
@ -18,20 +18,23 @@ namespace libyuv {
extern "C" {
#endif
#if defined(__pnacl__) || defined(__CLR_VER) || \
(defined(__i386__) && !defined(__SSE2__))
#if defined(__pnacl__) || defined(__CLR_VER) || \
(defined(__native_client__) && defined(__x86_64__)) || \
(defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
#define LIBYUV_DISABLE_X86
#endif
#if defined(__native_client__)
#define LIBYUV_DISABLE_NEON
#endif
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define LIBYUV_DISABLE_X86
#endif
#endif
// Visual C 2012 required for AVX2.
#if defined(_M_IX86) && !defined(__clang__) && \
defined(_MSC_VER) && _MSC_VER >= 1700
#if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
_MSC_VER >= 1700
#define VISUALC_HAS_AVX2 1
#endif // VisualStudio >= 2012
@ -42,43 +45,86 @@ extern "C" {
#endif // clang >= 3.4
#endif // __clang__
#if !defined(LIBYUV_DISABLE_X86) && \
defined(_M_IX86) && (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
#define HAS_HASHDJB2_AVX2
#endif
// The following are available for Visual C and GCC:
#if !defined(LIBYUV_DISABLE_X86) && \
(defined(__x86_64__) || (defined(__i386__) || defined(_M_IX86)))
(defined(__x86_64__) || defined(__i386__) || defined(_M_IX86))
#define HAS_HASHDJB2_SSE41
#define HAS_SUMSQUAREERROR_SSE2
#define HAS_HAMMINGDISTANCE_SSE42
#endif
// The following are available for Visual C and clangcl 32 bit:
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \
!defined(__clang__) && \
(defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
#define HAS_HASHDJB2_AVX2
#define HAS_SUMSQUAREERROR_AVX2
#endif
// The following are available for GCC and clangcl:
#if !defined(LIBYUV_DISABLE_X86) && (defined(__x86_64__) || defined(__i386__))
#define HAS_HAMMINGDISTANCE_SSSE3
#endif
// The following are available for GCC and clangcl:
#if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
(defined(__x86_64__) || defined(__i386__))
#define HAS_HAMMINGDISTANCE_AVX2
#endif
// The following are available for Neon:
#if !defined(LIBYUV_DISABLE_NEON) && \
(defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
#define HAS_SUMSQUAREERROR_NEON
#define HAS_HAMMINGDISTANCE_NEON
#endif
uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count);
uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count);
uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count);
uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count);
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
#define HAS_HAMMINGDISTANCE_MSA
#define HAS_SUMSQUAREERROR_MSA
#endif
uint32 HashDjb2_C(const uint8* src, int count, uint32 seed);
uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed);
uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed);
uint32_t HammingDistance_C(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HammingDistance_SSE42(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HammingDistance_SSSE3(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HammingDistance_AVX2(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HammingDistance_NEON(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HammingDistance_MSA(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t SumSquareError_C(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t SumSquareError_SSE2(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t SumSquareError_AVX2(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t SumSquareError_NEON(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t SumSquareError_MSA(const uint8_t* src_a,
const uint8_t* src_b,
int count);
uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed);
uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed);
uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
#endif
#endif // INCLUDE_LIBYUV_COMPARE_ROW_H_ NOLINT
#endif // INCLUDE_LIBYUV_COMPARE_ROW_H_

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_
#define INCLUDE_LIBYUV_CONVERT_FROM_H_
#include "libyuv/basic_types.h"
@ -21,159 +21,183 @@ extern "C" {
// See Also convert.h for conversions from formats to I420.
// I420Copy in convert to I420ToI420.
// Convert 8 bit YUV to 10 bit.
#define H420ToH010 I420ToI010
LIBYUV_API
int I420ToI010(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint16_t* dst_y,
int dst_stride_y,
uint16_t* dst_u,
int dst_stride_u,
uint16_t* dst_v,
int dst_stride_v,
int width,
int height);
// Convert 8 bit YUV to 12 bit.
#define H420ToH012 I420ToI012
LIBYUV_API
int I420ToI012(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint16_t* dst_y,
int dst_stride_y,
uint16_t* dst_u,
int dst_stride_u,
uint16_t* dst_v,
int dst_stride_v,
int width,
int height);
LIBYUV_API
int I420ToI422(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int I420ToI422(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height);
LIBYUV_API
int I420ToI444(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
LIBYUV_API
int I420ToI411(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int I420ToI444(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height);
// Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21.
LIBYUV_API
int I400Copy(const uint8* src_y, int src_stride_y,
uint8* dst_y, int dst_stride_y,
int width, int height);
int I400Copy(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height);
LIBYUV_API
int I420ToNV12(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
uint8* dst_uv, int dst_stride_uv,
int width, int height);
int I420ToNV12(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height);
LIBYUV_API
int I420ToNV21(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
uint8* dst_vu, int dst_stride_vu,
int width, int height);
int I420ToNV21(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height);
LIBYUV_API
int I420ToYUY2(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToYUY2(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_yuy2,
int dst_stride_yuy2,
int width,
int height);
LIBYUV_API
int I420ToUYVY(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToUYVY(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_uyvy,
int dst_stride_uyvy,
int width,
int height);
// The following are from convert_argb.h
// DEPRECATED: The prototypes will be removed in future. Use convert_argb.h
// Convert I420 to ARGB.
LIBYUV_API
int I420ToARGB(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
int I420ToARGB(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height);
// Convert I420 to ABGR.
LIBYUV_API
int I420ToBGRA(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
LIBYUV_API
int I420ToABGR(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
LIBYUV_API
int I420ToRGBA(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_rgba, int dst_stride_rgba,
int width, int height);
LIBYUV_API
int I420ToRGB24(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
LIBYUV_API
int I420ToRAW(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
LIBYUV_API
int I420ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
// Convert I420 To RGB565 with 4x4 dither matrix (16 bytes).
// Values in dither matrix from 0 to 7 recommended.
// The order of the dither matrix is first byte is upper left.
LIBYUV_API
int I420ToRGB565Dither(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
const uint8* dither4x4, int width, int height);
LIBYUV_API
int I420ToARGB1555(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
LIBYUV_API
int I420ToARGB4444(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
int I420ToABGR(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_abgr,
int dst_stride_abgr,
int width,
int height);
// Convert I420 to specified format.
// "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the
// buffer has contiguous rows. Can be negative. A multiple of 16 is optimal.
LIBYUV_API
int ConvertFromI420(const uint8* y, int y_stride,
const uint8* u, int u_stride,
const uint8* v, int v_stride,
uint8* dst_sample, int dst_sample_stride,
int width, int height,
uint32 format);
int ConvertFromI420(const uint8_t* y,
int y_stride,
const uint8_t* u,
int u_stride,
const uint8_t* v,
int v_stride,
uint8_t* dst_sample,
int dst_sample_stride,
int width,
int height,
uint32_t fourcc);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
#endif
#endif // INCLUDE_LIBYUV_CONVERT_FROM_H_ NOLINT
#endif // INCLUDE_LIBYUV_CONVERT_FROM_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
#define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
#include "libyuv/basic_types.h"
@ -21,170 +21,361 @@ extern "C" {
// Copy ARGB to ARGB.
#define ARGBToARGB ARGBCopy
LIBYUV_API
int ARGBCopy(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
int ARGBCopy(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height);
// Convert ARGB To BGRA.
LIBYUV_API
int ARGBToBGRA(const uint8* src_argb, int src_stride_argb,
uint8* dst_bgra, int dst_stride_bgra,
int width, int height);
int ARGBToBGRA(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_bgra,
int dst_stride_bgra,
int width,
int height);
// Convert ARGB To ABGR.
LIBYUV_API
int ARGBToABGR(const uint8* src_argb, int src_stride_argb,
uint8* dst_abgr, int dst_stride_abgr,
int width, int height);
int ARGBToABGR(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_abgr,
int dst_stride_abgr,
int width,
int height);
// Convert ARGB To RGBA.
LIBYUV_API
int ARGBToRGBA(const uint8* src_argb, int src_stride_argb,
uint8* dst_rgba, int dst_stride_rgba,
int width, int height);
int ARGBToRGBA(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_rgba,
int dst_stride_rgba,
int width,
int height);
// Aliases
#define ARGBToAB30 ABGRToAR30
#define ABGRToAB30 ARGBToAR30
// Convert ABGR To AR30.
LIBYUV_API
int ABGRToAR30(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_ar30,
int dst_stride_ar30,
int width,
int height);
// Convert ARGB To AR30.
LIBYUV_API
int ARGBToAR30(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_ar30,
int dst_stride_ar30,
int width,
int height);
// Aliases
#define ABGRToRGB24 ARGBToRAW
#define ABGRToRAW ARGBToRGB24
// Convert ARGB To RGB24.
LIBYUV_API
int ARGBToRGB24(const uint8* src_argb, int src_stride_argb,
uint8* dst_rgb24, int dst_stride_rgb24,
int width, int height);
int ARGBToRGB24(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_rgb24,
int dst_stride_rgb24,
int width,
int height);
// Convert ARGB To RAW.
LIBYUV_API
int ARGBToRAW(const uint8* src_argb, int src_stride_argb,
uint8* dst_rgb, int dst_stride_rgb,
int width, int height);
int ARGBToRAW(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_raw,
int dst_stride_raw,
int width,
int height);
// Convert ARGB To RGB565.
LIBYUV_API
int ARGBToRGB565(const uint8* src_argb, int src_stride_argb,
uint8* dst_rgb565, int dst_stride_rgb565,
int width, int height);
int ARGBToRGB565(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_rgb565,
int dst_stride_rgb565,
int width,
int height);
// Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes).
// Values in dither matrix from 0 to 7 recommended.
// The order of the dither matrix is first byte is upper left.
// TODO(fbarchard): Consider pointer to 2d array for dither4x4.
// const uint8(*dither)[4][4];
// const uint8_t(*dither)[4][4];
LIBYUV_API
int ARGBToRGB565Dither(const uint8* src_argb, int src_stride_argb,
uint8* dst_rgb565, int dst_stride_rgb565,
const uint8* dither4x4, int width, int height);
int ARGBToRGB565Dither(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_rgb565,
int dst_stride_rgb565,
const uint8_t* dither4x4,
int width,
int height);
// Convert ARGB To ARGB1555.
LIBYUV_API
int ARGBToARGB1555(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb1555, int dst_stride_argb1555,
int width, int height);
int ARGBToARGB1555(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb1555,
int dst_stride_argb1555,
int width,
int height);
// Convert ARGB To ARGB4444.
LIBYUV_API
int ARGBToARGB4444(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb4444, int dst_stride_argb4444,
int width, int height);
int ARGBToARGB4444(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb4444,
int dst_stride_argb4444,
int width,
int height);
// Convert ARGB To I444.
LIBYUV_API
int ARGBToI444(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int ARGBToI444(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height);
// Convert ARGB to AR64.
LIBYUV_API
int ARGBToAR64(const uint8_t* src_argb,
int src_stride_argb,
uint16_t* dst_ar64,
int dst_stride_ar64,
int width,
int height);
// Convert ABGR to AB64.
#define ABGRToAB64 ARGBToAR64
// Convert ARGB to AB64.
LIBYUV_API
int ARGBToAB64(const uint8_t* src_argb,
int src_stride_argb,
uint16_t* dst_ab64,
int dst_stride_ab64,
int width,
int height);
// Convert ABGR to AR64.
#define ABGRToAR64 ARGBToAB64
// Convert ARGB To I422.
LIBYUV_API
int ARGBToI422(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int ARGBToI422(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height);
// Convert ARGB To I420. (also in convert.h)
LIBYUV_API
int ARGBToI420(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int ARGBToI420(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height);
// Convert ARGB to J420. (JPeg full range I420).
LIBYUV_API
int ARGBToJ420(const uint8* src_argb, int src_stride_argb,
uint8* dst_yj, int dst_stride_yj,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int ARGBToJ420(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_yj,
int dst_stride_yj,
uint8_t* dst_uj,
int dst_stride_uj,
uint8_t* dst_vj,
int dst_stride_vj,
int width,
int height);
// Convert ARGB to J422.
LIBYUV_API
int ARGBToJ422(const uint8* src_argb, int src_stride_argb,
uint8* dst_yj, int dst_stride_yj,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
// Convert ARGB To I411.
LIBYUV_API
int ARGBToI411(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
int ARGBToJ422(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_yj,
int dst_stride_yj,
uint8_t* dst_uj,
int dst_stride_uj,
uint8_t* dst_vj,
int dst_stride_vj,
int width,
int height);
// Convert ARGB to J400. (JPeg full range).
LIBYUV_API
int ARGBToJ400(const uint8* src_argb, int src_stride_argb,
uint8* dst_yj, int dst_stride_yj,
int width, int height);
int ARGBToJ400(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_yj,
int dst_stride_yj,
int width,
int height);
// Convert ABGR to J420. (JPeg full range I420).
LIBYUV_API
int ABGRToJ420(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_yj,
int dst_stride_yj,
uint8_t* dst_uj,
int dst_stride_uj,
uint8_t* dst_vj,
int dst_stride_vj,
int width,
int height);
// Convert ABGR to J422.
LIBYUV_API
int ABGRToJ422(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_yj,
int dst_stride_yj,
uint8_t* dst_uj,
int dst_stride_uj,
uint8_t* dst_vj,
int dst_stride_vj,
int width,
int height);
// Convert ABGR to J400. (JPeg full range).
LIBYUV_API
int ABGRToJ400(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_yj,
int dst_stride_yj,
int width,
int height);
// Convert RGBA to J400. (JPeg full range).
LIBYUV_API
int RGBAToJ400(const uint8_t* src_rgba,
int src_stride_rgba,
uint8_t* dst_yj,
int dst_stride_yj,
int width,
int height);
// Convert ARGB to I400.
LIBYUV_API
int ARGBToI400(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
int width, int height);
int ARGBToI400(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height);
// Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB)
LIBYUV_API
int ARGBToG(const uint8* src_argb, int src_stride_argb,
uint8* dst_g, int dst_stride_g,
int width, int height);
int ARGBToG(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_g,
int dst_stride_g,
int width,
int height);
// Convert ARGB To NV12.
LIBYUV_API
int ARGBToNV12(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_uv, int dst_stride_uv,
int width, int height);
int ARGBToNV12(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height);
// Convert ARGB To NV21.
LIBYUV_API
int ARGBToNV21(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_vu, int dst_stride_vu,
int width, int height);
int ARGBToNV21(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height);
// Convert ARGB To NV21.
// Convert ABGR To NV12.
LIBYUV_API
int ARGBToNV21(const uint8* src_argb, int src_stride_argb,
uint8* dst_y, int dst_stride_y,
uint8* dst_vu, int dst_stride_vu,
int width, int height);
int ABGRToNV12(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height);
// Convert ABGR To NV21.
LIBYUV_API
int ABGRToNV21(const uint8_t* src_abgr,
int src_stride_abgr,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height);
// Convert ARGB To YUY2.
LIBYUV_API
int ARGBToYUY2(const uint8* src_argb, int src_stride_argb,
uint8* dst_yuy2, int dst_stride_yuy2,
int width, int height);
int ARGBToYUY2(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_yuy2,
int dst_stride_yuy2,
int width,
int height);
// Convert ARGB To UYVY.
LIBYUV_API
int ARGBToUYVY(const uint8* src_argb, int src_stride_argb,
uint8* dst_uyvy, int dst_stride_uyvy,
int width, int height);
int ARGBToUYVY(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_uyvy,
int dst_stride_uyvy,
int width,
int height);
// RAW to JNV21 full range NV21
LIBYUV_API
int RAWToJNV21(const uint8_t* src_raw,
int src_stride_raw,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
#endif
#endif // INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ NOLINT
#endif // INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef INCLUDE_LIBYUV_CPU_ID_H_ // NOLINT
#ifndef INCLUDE_LIBYUV_CPU_ID_H_
#define INCLUDE_LIBYUV_CPU_ID_H_
#include "libyuv/basic_types.h"
@ -31,50 +31,97 @@ static const int kCpuHasX86 = 0x10;
static const int kCpuHasSSE2 = 0x20;
static const int kCpuHasSSSE3 = 0x40;
static const int kCpuHasSSE41 = 0x80;
static const int kCpuHasSSE42 = 0x100;
static const int kCpuHasSSE42 = 0x100; // unused at this time.
static const int kCpuHasAVX = 0x200;
static const int kCpuHasAVX2 = 0x400;
static const int kCpuHasERMS = 0x800;
static const int kCpuHasFMA3 = 0x1000;
static const int kCpuHasAVX3 = 0x2000;
// 0x2000, 0x4000, 0x8000 reserved for future X86 flags.
static const int kCpuHasF16C = 0x2000;
static const int kCpuHasGFNI = 0x4000;
static const int kCpuHasAVX512BW = 0x8000;
static const int kCpuHasAVX512VL = 0x10000;
static const int kCpuHasAVX512VNNI = 0x20000;
static const int kCpuHasAVX512VBMI = 0x40000;
static const int kCpuHasAVX512VBMI2 = 0x80000;
static const int kCpuHasAVX512VBITALG = 0x100000;
static const int kCpuHasAVX512VPOPCNTDQ = 0x200000;
// These flags are only valid on MIPS processors.
static const int kCpuHasMIPS = 0x10000;
static const int kCpuHasDSPR2 = 0x20000;
static const int kCpuHasMIPS = 0x400000;
static const int kCpuHasMSA = 0x800000;
// Internal function used to auto-init.
// These flags are only valid on LOONGARCH processors.
static const int kCpuHasLOONGARCH = 0x2000000;
static const int kCpuHasLSX = 0x4000000;
static const int kCpuHasLASX = 0x8000000;
// Optional init function. TestCpuFlag does an auto-init.
// Returns cpu_info flags.
LIBYUV_API
int InitCpuFlags(void);
// Detect CPU has SSE2 etc.
// Test_flag parameter should be one of kCpuHas constants above.
// Returns non-zero if instruction set is detected
static __inline int TestCpuFlag(int test_flag) {
LIBYUV_API extern int cpu_info_;
#ifdef __ATOMIC_RELAXED
int cpu_info = __atomic_load_n(&cpu_info_, __ATOMIC_RELAXED);
#else
int cpu_info = cpu_info_;
#endif
return (!cpu_info ? InitCpuFlags() : cpu_info) & test_flag;
}
// Internal function for parsing /proc/cpuinfo.
LIBYUV_API
int ArmCpuCaps(const char* cpuinfo_name);
// Detect CPU has SSE2 etc.
// Test_flag parameter should be one of kCpuHas constants above.
// returns non-zero if instruction set is detected
static __inline int TestCpuFlag(int test_flag) {
LIBYUV_API extern int cpu_info_;
return (!cpu_info_ ? InitCpuFlags() : cpu_info_) & test_flag;
}
LIBYUV_API
int MipsCpuCaps(const char* cpuinfo_name);
// For testing, allow CPU flags to be disabled.
// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3.
// MaskCpuFlags(-1) to enable all cpu specific optimizations.
// MaskCpuFlags(1) to disable all cpu specific optimizations.
// MaskCpuFlags(0) to reset state so next call will auto init.
// Returns cpu_info flags.
LIBYUV_API
void MaskCpuFlags(int enable_flags);
int MaskCpuFlags(int enable_flags);
// Sets the CPU flags to |cpu_flags|, bypassing the detection code. |cpu_flags|
// should be a valid combination of the kCpuHas constants above and include
// kCpuInitialized. Use this method when running in a sandboxed process where
// the detection code might fail (as it might access /proc/cpuinfo). In such
// cases the cpu_info can be obtained from a non sandboxed process by calling
// InitCpuFlags() and passed to the sandboxed process (via command line
// parameters, IPC...) which can then call this method to initialize the CPU
// flags.
// Notes:
// - when specifying 0 for |cpu_flags|, the auto initialization is enabled
// again.
// - enabling CPU features that are not supported by the CPU will result in
// undefined behavior.
// TODO(fbarchard): consider writing a helper function that translates from
// other library CPU info to libyuv CPU info and add a .md doc that explains
// CPU detection.
static __inline void SetCpuFlags(int cpu_flags) {
LIBYUV_API extern int cpu_info_;
#ifdef __ATOMIC_RELAXED
__atomic_store_n(&cpu_info_, cpu_flags, __ATOMIC_RELAXED);
#else
cpu_info_ = cpu_flags;
#endif
}
// Low level cpuid for X86. Returns zeros on other CPUs.
// eax is the info type that you want.
// ecx is typically the cpu number, and should normally be zero.
LIBYUV_API
void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info);
void CpuId(int info_eax, int info_ecx, int* cpu_info);
#ifdef __cplusplus
} // extern "C"
} // namespace libyuv
#endif
#endif // INCLUDE_LIBYUV_CPU_ID_H_ NOLINT
#endif // INCLUDE_LIBYUV_CPU_ID_H_

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more