Bug 1493898 - P6. Move YUVColorSpace definition in the gfx namespace. r=mattwoodrow.

YUVColorSpace is inseparable from the bit depth as the matrix coefficients to be calculated need the bit depth information.

So let's put the two types together. gfx namespace also makes more sense as that's where we find IntRect, IntSize and other.

The extent of the changes highlight how much similar data structures are duplicated across the code, to the point it's scary.

Differential Revision: https://phabricator.services.mozilla.com/D25347

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2019-04-11 12:41:33 +00:00
Родитель 14fac11637
Коммит 3ae43eb506
41 изменённых файлов: 111 добавлений и 108 удалений

Просмотреть файл

@ -412,6 +412,7 @@ class VideoData : public MediaData {
typedef gfx::IntRect IntRect;
typedef gfx::IntSize IntSize;
typedef gfx::ColorDepth ColorDepth;
typedef gfx::YUVColorSpace YUVColorSpace;
typedef layers::ImageContainer ImageContainer;
typedef layers::Image Image;
typedef layers::PlanarYCbCrImage PlanarYCbCrImage;

Просмотреть файл

@ -247,7 +247,7 @@ class VideoInfo : public TrackInfo {
// Should be 8, 10 or 12. Default value is 8.
gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8;
YUVColorSpace mColorSpace = YUVColorSpace::UNKNOWN;
gfx::YUVColorSpace mColorSpace = gfx::YUVColorSpace::UNKNOWN;
// True indicates no restriction on Y, U, V values (otherwise 16-235 for 8
// bits etc)

Просмотреть файл

@ -80,18 +80,18 @@ class VPXDecoder : public MediaDataDecoder,
*/
int mColorSpace = 1; // CS_BT_601
YUVColorSpace ColorSpace() const {
gfx::YUVColorSpace ColorSpace() const {
switch (mColorSpace) {
case 1:
case 3:
case 4:
return YUVColorSpace::BT601;
return gfx::YUVColorSpace::BT601;
case 2:
return YUVColorSpace::BT709;
return gfx::YUVColorSpace::BT709;
case 5:
return YUVColorSpace::BT2020;
return gfx::YUVColorSpace::BT2020;
default:
return YUVColorSpace::UNKNOWN;
return gfx::YUVColorSpace::UNKNOWN;
}
}

Просмотреть файл

@ -370,20 +370,20 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImage(
#if LIBAVCODEC_VERSION_MAJOR >= 55
case AVCOL_SPC_BT2020_NCL:
case AVCOL_SPC_BT2020_CL:
b.mYUVColorSpace = YUVColorSpace::BT2020;
b.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
break;
#endif
case AVCOL_SPC_BT709:
b.mYUVColorSpace = YUVColorSpace::BT709;
b.mYUVColorSpace = gfx::YUVColorSpace::BT709;
break;
case AVCOL_SPC_SMPTE170M:
case AVCOL_SPC_BT470BG:
b.mYUVColorSpace = YUVColorSpace::BT601;
b.mYUVColorSpace = gfx::YUVColorSpace::BT601;
break;
case AVCOL_SPC_UNSPECIFIED:
#if LIBAVCODEC_VERSION_MAJOR >= 55
if (mCodecContext->codec_id == AV_CODEC_ID_VP9) {
b.mYUVColorSpace = YUVColorSpace::BT709;
b.mYUVColorSpace = gfx::YUVColorSpace::BT709;
}
#endif
break;

Просмотреть файл

@ -65,20 +65,20 @@ GetDefaultStride(IMFMediaType* aType, uint32_t aWidth, uint32_t* aOutStride) {
return hr;
}
YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) {
gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) {
UINT32 yuvColorMatrix;
HRESULT hr = aType->GetUINT32(MF_MT_YUV_MATRIX, &yuvColorMatrix);
NS_ENSURE_TRUE(SUCCEEDED(hr), YUVColorSpace::BT601);
NS_ENSURE_TRUE(SUCCEEDED(hr), gfx::YUVColorSpace::BT601);
switch (yuvColorMatrix) {
case MFVideoTransferMatrix_BT2020_10:
case MFVideoTransferMatrix_BT2020_12:
return YUVColorSpace::BT2020;
return gfx::YUVColorSpace::BT2020;
case MFVideoTransferMatrix_BT709:
return YUVColorSpace::BT709;
return gfx::YUVColorSpace::BT709;
case MFVideoTransferMatrix_BT601:
default:
return YUVColorSpace::BT601;
return gfx::YUVColorSpace::BT601;
}
}

Просмотреть файл

@ -33,7 +33,7 @@ HRESULT HNsToFrames(int64_t aHNs, uint32_t aRate, int64_t* aOutFrames);
HRESULT
GetDefaultStride(IMFMediaType* aType, uint32_t aWidth, uint32_t* aOutStride);
YUVColorSpace GetYUVColorSpace(IMFMediaType* aType);
gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType);
int32_t MFOffsetToInt32(const MFOffset& aOffset);

Просмотреть файл

@ -71,7 +71,7 @@ class WMFVideoMFTManager : public MFTManager {
const gfx::IntSize mImageSize;
gfx::IntSize mDecodedImageSize;
uint32_t mVideoStride;
YUVColorSpace mYUVColorSpace;
gfx::YUVColorSpace mYUVColorSpace;
RefPtr<layers::ImageContainer> mImageContainer;
RefPtr<layers::KnowsCompositor> mKnowsCompositor;

Просмотреть файл

@ -138,6 +138,14 @@ inline bool IsOpaque(SurfaceFormat aFormat) {
}
}
enum class YUVColorSpace : uint8_t {
BT601,
BT709,
BT2020,
// This represents the unknown format.
UNKNOWN,
};
enum class ColorDepth : uint8_t {
COLOR_8,
COLOR_10,

Просмотреть файл

@ -927,7 +927,7 @@ bool GLBlitHelper::BlitImage(layers::MacIOSurfaceImage* const srcImage,
baseArgs.destSize = destSize;
DrawBlitProg::YUVArgs yuvArgs;
yuvArgs.colorSpace = YUVColorSpace::BT601;
yuvArgs.colorSpace = gfx::YUVColorSpace::BT601;
const DrawBlitProg::YUVArgs* pYuvArgs = nullptr;

Просмотреть файл

@ -91,7 +91,7 @@ class DrawBlitProg final {
};
struct YUVArgs final {
Mat3 texMatrix1;
YUVColorSpace colorSpace;
gfx::YUVColorSpace colorSpace;
};
void Draw(const BaseArgs& args, const YUVArgs* argsYUV = nullptr) const;
@ -198,7 +198,7 @@ class GLBlitHelper final {
bool BlitAngleYCbCr(const WindowsHandle (&handleList)[3],
const gfx::IntRect& clipRect, const gfx::IntSize& ySize,
const gfx::IntSize& uvSize,
const YUVColorSpace colorSpace,
const gfx::YUVColorSpace colorSpace,
const gfx::IntSize& destSize, OriginPos destOrigin) const;
bool BlitAnglePlanes(uint8_t numPlanes,

Просмотреть файл

@ -229,7 +229,7 @@ bool GLBlitHelper::BlitDescriptor(const layers::SurfaceDescriptorD3D10& desc,
const auto srcOrigin = OriginPos::BottomLeft;
const gfx::IntRect clipRect(0, 0, clipSize.width, clipSize.height);
const auto colorSpace = YUVColorSpace::BT601;
const auto colorSpace = gfx::YUVColorSpace::BT601;
if (format != gfx::SurfaceFormat::NV12 &&
format != gfx::SurfaceFormat::P010 &&
@ -286,7 +286,7 @@ bool GLBlitHelper::BlitAngleYCbCr(const WindowsHandle (&handleList)[3],
const gfx::IntRect& clipRect,
const gfx::IntSize& ySize,
const gfx::IntSize& uvSize,
const YUVColorSpace colorSpace,
const gfx::YUVColorSpace colorSpace,
const gfx::IntSize& destSize,
const OriginPos destOrigin) const {
const auto& d3d = GetD3D11();

Просмотреть файл

@ -651,18 +651,18 @@ struct ParamTraits<mozilla::gfx::ColorDepth>
mozilla::gfx::ColorDepth::COLOR_8,
mozilla::gfx::ColorDepth::UNKNOWN> {};
template <>
struct ParamTraits<mozilla::gfx::YUVColorSpace>
: public ContiguousEnumSerializer<mozilla::gfx::YUVColorSpace,
mozilla::gfx::YUVColorSpace::BT601,
mozilla::gfx::YUVColorSpace::UNKNOWN> {};
template <>
struct ParamTraits<mozilla::StereoMode>
: public ContiguousEnumSerializer<mozilla::StereoMode,
mozilla::StereoMode::MONO,
mozilla::StereoMode::MAX> {};
template <>
struct ParamTraits<mozilla::YUVColorSpace>
: public ContiguousEnumSerializer<mozilla::YUVColorSpace,
mozilla::YUVColorSpace::BT601,
mozilla::YUVColorSpace::UNKNOWN> {};
template <>
struct ParamTraits<mozilla::gfx::ImplicitlyCopyableFloatArray>
: public ParamTraits<nsTArray<float>> {

Просмотреть файл

@ -154,7 +154,7 @@ BufferTextureData* BufferTextureData::CreateInternal(
BufferTextureData* BufferTextureData::CreateForYCbCr(
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
TextureFlags aTextureFlags) {
uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(
aYSize, aYStride, aCbCrSize, aCbCrStride);
@ -224,7 +224,7 @@ Maybe<gfx::IntSize> BufferTextureData::GetCbCrSize() const {
return ImageDataSerializer::CbCrSizeFromBufferDescriptor(mDescriptor);
}
Maybe<YUVColorSpace> BufferTextureData::GetYUVColorSpace() const {
Maybe<gfx::YUVColorSpace> BufferTextureData::GetYUVColorSpace() const {
return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor);
}

Просмотреть файл

@ -33,7 +33,7 @@ class BufferTextureData : public TextureData {
static BufferTextureData* CreateForYCbCr(
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
TextureFlags aTextureFlags);
virtual bool Lock(OpenMode aMode) override { return true; }
@ -58,7 +58,7 @@ class BufferTextureData : public TextureData {
Maybe<gfx::IntSize> GetCbCrSize() const;
Maybe<YUVColorSpace> GetYUVColorSpace() const;
Maybe<gfx::YUVColorSpace> GetYUVColorSpace() const;
Maybe<gfx::ColorDepth> GetColorDepth() const;

Просмотреть файл

@ -78,7 +78,7 @@ class D3D11YCbCrImage : public Image {
gfx::IntSize mCbCrSize;
gfx::IntRect mPictureRect;
gfx::ColorDepth mColorDepth;
YUVColorSpace mColorSpace;
gfx::YUVColorSpace mColorSpace;
RefPtr<TextureClient> mTextureClient;
};

Просмотреть файл

@ -145,7 +145,7 @@ struct EffectRGB : public TexturedEffect {
};
struct EffectYCbCr : public TexturedEffect {
EffectYCbCr(TextureSource* aSource, YUVColorSpace aYUVColorSpace,
EffectYCbCr(TextureSource* aSource, gfx::YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::SamplingFilter aSamplingFilter)
: TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter),
mYUVColorSpace(aYUVColorSpace),
@ -153,7 +153,7 @@ struct EffectYCbCr : public TexturedEffect {
virtual const char* Name() override { return "EffectYCbCr"; }
YUVColorSpace mYUVColorSpace;
gfx::YUVColorSpace mYUVColorSpace;
gfx::ColorDepth mColorDepth;
};
@ -244,7 +244,7 @@ inline already_AddRefed<TexturedEffect> CreateTexturedEffect(
RefPtr<TexturedEffect> result;
if (aHost->GetReadFormat() == gfx::SurfaceFormat::YUV) {
MOZ_ASSERT(aHost->GetYUVColorSpace() != YUVColorSpace::UNKNOWN);
MOZ_ASSERT(aHost->GetYUVColorSpace() != gfx::YUVColorSpace::UNKNOWN);
result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(),
aHost->GetColorDepth(), aSamplingFilter);
} else {

Просмотреть файл

@ -734,7 +734,7 @@ struct PlanarYCbCrData {
uint32_t mPicY;
gfx::IntSize mPicSize;
StereoMode mStereoMode;
YUVColorSpace mYUVColorSpace;
gfx::YUVColorSpace mYUVColorSpace;
gfx::ColorDepth mColorDepth;
gfx::IntRect GetPictureRect() const {
@ -756,7 +756,7 @@ struct PlanarYCbCrData {
mPicY(0),
mPicSize(0, 0),
mStereoMode(StereoMode::MONO),
mYUVColorSpace(YUVColorSpace::BT601),
mYUVColorSpace(gfx::YUVColorSpace::BT601),
mColorDepth(gfx::ColorDepth::COLOR_8) {}
};

Просмотреть файл

@ -158,7 +158,7 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
}
}
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
const BufferDescriptor& aDescriptor) {
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:

Просмотреть файл

@ -60,7 +60,7 @@ gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
const BufferDescriptor& aDescriptor);
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
const BufferDescriptor& aDescriptor);
Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(

Просмотреть файл

@ -101,14 +101,6 @@ enum class StereoMode {
MAX,
};
enum class YUVColorSpace {
BT601,
BT709,
BT2020,
// This represents the unknown format.
UNKNOWN,
};
namespace layers {
typedef uint32_t ContainerFrameID;

Просмотреть файл

@ -1231,7 +1231,7 @@ already_AddRefed<TextureClient> TextureClient::CreateForRawBufferAccess(
already_AddRefed<TextureClient> TextureClient::CreateForYCbCr(
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
TextureFlags aTextureFlags) {
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
return nullptr;

Просмотреть файл

@ -352,7 +352,7 @@ class TextureClient : public AtomicRefCountedWithFinalize<TextureClient> {
static already_AddRefed<TextureClient> CreateForYCbCr(
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
TextureFlags aTextureFlags);
// Creates and allocates a TextureClient (can be accessed through raw

Просмотреть файл

@ -69,11 +69,11 @@ void GPUVideoTextureHost::SetTextureSourceProvider(
}
}
YUVColorSpace GPUVideoTextureHost::GetYUVColorSpace() const {
gfx::YUVColorSpace GPUVideoTextureHost::GetYUVColorSpace() const {
if (mWrappedTextureHost) {
return mWrappedTextureHost->GetYUVColorSpace();
}
return YUVColorSpace::UNKNOWN;
return gfx::YUVColorSpace::UNKNOWN;
}
gfx::IntSize GPUVideoTextureHost::GetSize() const {

Просмотреть файл

@ -39,7 +39,7 @@ class GPUVideoTextureHost : public TextureHost {
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
}
virtual YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::IntSize GetSize() const override;

Просмотреть файл

@ -867,12 +867,12 @@ gfx::SurfaceFormat BufferTextureHost::GetFormat() const {
return mFormat;
}
YUVColorSpace BufferTextureHost::GetYUVColorSpace() const {
gfx::YUVColorSpace BufferTextureHost::GetYUVColorSpace() const {
if (mFormat == gfx::SurfaceFormat::YUV) {
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
return desc.yUVColorSpace();
}
return YUVColorSpace::UNKNOWN;
return gfx::YUVColorSpace::UNKNOWN;
}
gfx::ColorDepth BufferTextureHost::GetColorDepth() const {

Просмотреть файл

@ -436,8 +436,8 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {
*/
virtual gfx::SurfaceFormat GetReadFormat() const { return GetFormat(); }
virtual YUVColorSpace GetYUVColorSpace() const {
return YUVColorSpace::UNKNOWN;
virtual gfx::YUVColorSpace GetYUVColorSpace() const {
return gfx::YUVColorSpace::UNKNOWN;
}
/**
@ -754,7 +754,7 @@ class BufferTextureHost : public TextureHost {
*/
virtual gfx::SurfaceFormat GetFormat() const override;
virtual YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::ColorDepth GetColorDepth() const override;

Просмотреть файл

@ -134,13 +134,13 @@ class DXGIYCbCrTextureData : public TextureData {
IDirect3DTexture9* aTextureCr, HANDLE aHandleY, HANDLE aHandleCb,
HANDLE aHandleCr, const gfx::IntSize& aSize, const gfx::IntSize& aSizeY,
const gfx::IntSize& aSizeCbCr, gfx::ColorDepth aColorDepth,
YUVColorSpace aYUVColorSpace);
gfx::YUVColorSpace aYUVColorSpace);
static DXGIYCbCrTextureData* Create(
ID3D11Texture2D* aTextureCb, ID3D11Texture2D* aTextureY,
ID3D11Texture2D* aTextureCr, const gfx::IntSize& aSize,
const gfx::IntSize& aSizeY, const gfx::IntSize& aSizeCbCr,
gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace);
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace);
virtual bool Lock(OpenMode) override { return true; }
@ -172,7 +172,7 @@ class DXGIYCbCrTextureData : public TextureData {
gfx::ColorDepth GetColorDepth() const { return mColorDepth; }
YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
ID3D11Texture2D* GetD3D11Texture(size_t index) {
return mD3D11Textures[index];
@ -186,7 +186,7 @@ class DXGIYCbCrTextureData : public TextureData {
gfx::IntSize mSizeY;
gfx::IntSize mSizeCbCr;
gfx::ColorDepth mColorDepth;
YUVColorSpace mYUVColorSpace;
gfx::YUVColorSpace mYUVColorSpace;
};
/**
@ -405,7 +405,7 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost {
virtual gfx::ColorDepth GetColorDepth() const override { return mColorDepth; }
virtual YUVColorSpace GetYUVColorSpace() const override {
virtual gfx::YUVColorSpace GetYUVColorSpace() const override {
return mYUVColorSpace;
}
@ -453,7 +453,7 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost {
WindowsHandle mHandles[3];
bool mIsLocked;
gfx::ColorDepth mColorDepth;
YUVColorSpace mYUVColorSpace;
gfx::YUVColorSpace mYUVColorSpace;
};
class CompositingRenderTargetD3D11 : public CompositingRenderTarget,

Просмотреть файл

@ -6,9 +6,9 @@ using struct gfxPoint from "gfxPoint.h";
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 struct mozilla::null_t from "ipc/IPCMessageUtils.h";
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
using mozilla::gfx::YUVColorSpace from "mozilla/gfx/Types.h";
using mozilla::gfx::ColorDepth from "mozilla/gfx/Types.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";

Просмотреть файл

@ -337,7 +337,7 @@ class MLGDevice {
// This creates or returns a previously created constant buffer, containing
// a YCbCrShaderConstants instance.
RefPtr<MLGBuffer> GetBufferForColorSpace(YUVColorSpace aColorSpace);
RefPtr<MLGBuffer> GetBufferForColorSpace(gfx::YUVColorSpace aColorSpace);
// This creates or returns a previously created constant buffer, containing
// a YCbCrBitDepthConstants instance.
RefPtr<MLGBuffer> GetBufferForColorDepthCoefficient(
@ -454,7 +454,7 @@ class MLGDevice {
nsCString mFailureMessage;
bool mInitialized;
typedef EnumeratedArray<YUVColorSpace, YUVColorSpace::UNKNOWN,
typedef EnumeratedArray<gfx::YUVColorSpace, gfx::YUVColorSpace::UNKNOWN,
RefPtr<MLGBuffer>>
ColorSpaceArray;
ColorSpaceArray mColorSpaceBuffers;

Просмотреть файл

@ -221,7 +221,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems(
// which only supports 8 bits color depth.
aBuilder.PushYCbCrInterleavedImage(
aBounds, aClip, true, aImageKeys[0], wr::ColorDepth::Color8,
wr::ToWrYuvColorSpace(YUVColorSpace::BT601), aFilter);
wr::ToWrYuvColorSpace(gfx::YUVColorSpace::BT601), aFilter);
break;
}
case gfx::SurfaceFormat::NV12: {
@ -231,7 +231,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems(
// which only supports 8 bits color depth.
aBuilder.PushNV12Image(aBounds, aClip, true, aImageKeys[0], aImageKeys[1],
wr::ColorDepth::Color8,
wr::ToWrYuvColorSpace(YUVColorSpace::BT601),
wr::ToWrYuvColorSpace(gfx::YUVColorSpace::BT601),
aFilter);
break;
}

Просмотреть файл

@ -1009,7 +1009,7 @@ void ShaderProgramOGL::SetBlurRadius(float aRX, float aRY) {
gaussianKernel);
}
void ShaderProgramOGL::SetYUVColorSpace(YUVColorSpace aYUVColorSpace) {
void ShaderProgramOGL::SetYUVColorSpace(gfx::YUVColorSpace aYUVColorSpace) {
const float *yuvToRgb =
gfxUtils::YuvToRgbMatrix3x3ColumnMajor(aYUVColorSpace);
SetMatrix3fvUniform(KnownUniform::YuvColorMatrix, yuvToRgb);

Просмотреть файл

@ -231,7 +231,7 @@ class ShaderProgramOGL {
SetUniform(KnownUniform::MaskCoordMultiplier, 2, f);
}
void SetYUVColorSpace(YUVColorSpace aYUVColorSpace);
void SetYUVColorSpace(gfx::YUVColorSpace aYUVColorSpace);
// Set whether we want the component alpha shader to return the color
// vector (pass 1, false) or the alpha vector (pass2, true). With support

Просмотреть файл

@ -74,11 +74,11 @@ already_AddRefed<gfx::DataSourceSurface> WebRenderTextureHost::GetAsSurface() {
void WebRenderTextureHost::SetTextureSourceProvider(
TextureSourceProvider* aProvider) {}
YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const {
gfx::YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const {
if (mWrappedTextureHost) {
return mWrappedTextureHost->GetYUVColorSpace();
}
return YUVColorSpace::UNKNOWN;
return gfx::YUVColorSpace::UNKNOWN;
}
gfx::IntSize WebRenderTextureHost::GetSize() const {

Просмотреть файл

@ -52,7 +52,7 @@ class WebRenderTextureHost : public TextureHost {
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
virtual YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
virtual gfx::IntSize GetSize() const override;

Просмотреть файл

@ -1101,7 +1101,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
0.00000f, 0.00000f, 0.00000f, 1.00000f};
/* static */ const float* gfxUtils::YuvToRgbMatrix4x3RowMajor(
YUVColorSpace aYUVColorSpace) {
gfx::YUVColorSpace aYUVColorSpace) {
#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 }
@ -1112,11 +1112,11 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
#undef X
switch (aYUVColorSpace) {
case YUVColorSpace::BT601:
case gfx::YUVColorSpace::BT601:
return rec601;
case YUVColorSpace::BT709:
case gfx::YUVColorSpace::BT709:
return rec709;
case YUVColorSpace::BT2020:
case gfx::YUVColorSpace::BT2020:
return rec2020;
default: // YUVColorSpace::UNKNOWN
MOZ_ASSERT(false, "unknown aYUVColorSpace");
@ -1125,7 +1125,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
}
/* static */ const float* gfxUtils::YuvToRgbMatrix3x3ColumnMajor(
YUVColorSpace aYUVColorSpace) {
gfx::YUVColorSpace aYUVColorSpace) {
#define X(x) \
{ x[0], x[4], x[8], x[1], x[5], x[9], x[2], x[6], x[10] }
@ -1136,7 +1136,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
#undef X
switch (aYUVColorSpace) {
case YUVColorSpace::BT601:
case gfx::YUVColorSpace::BT601:
return rec601;
case YUVColorSpace::BT709:
return rec709;

Просмотреть файл

@ -168,11 +168,11 @@ class gfxUtils {
static void ClearThebesSurface(gfxASurface* aSurface);
static const float* YuvToRgbMatrix4x3RowMajor(
mozilla::YUVColorSpace aYUVColorSpace);
mozilla::gfx::YUVColorSpace aYUVColorSpace);
static const float* YuvToRgbMatrix3x3ColumnMajor(
mozilla::YUVColorSpace aYUVColorSpace);
mozilla::gfx::YUVColorSpace aYUVColorSpace);
static const float* YuvToRgbMatrix4x4ColumnMajor(
mozilla::YUVColorSpace aYUVColorSpace);
mozilla::gfx::YUVColorSpace aYUVColorSpace);
/**
* Creates a copy of aSurface, but having the SurfaceFormat aFormat.

Просмотреть файл

@ -872,13 +872,13 @@ enum class WebRenderError : int8_t {
};
static inline wr::WrYuvColorSpace ToWrYuvColorSpace(
YUVColorSpace aYUVColorSpace) {
gfx::YUVColorSpace aYUVColorSpace) {
switch (aYUVColorSpace) {
case YUVColorSpace::BT601:
case gfx::YUVColorSpace::BT601:
return wr::WrYuvColorSpace::Rec601;
case YUVColorSpace::BT709:
case gfx::YUVColorSpace::BT709:
return wr::WrYuvColorSpace::Rec709;
case YUVColorSpace::BT2020:
case gfx::YUVColorSpace::BT2020:
return wr::WrYuvColorSpace::Rec2020;
default:
MOZ_ASSERT_UNREACHABLE("Tried to convert invalid YUVColorSpace.");

Просмотреть файл

@ -60,6 +60,8 @@ static __inline int Abs(int v) {
return v >= 0 ? v : -v;
}
typedef mozilla::gfx::YUVColorSpace YUVColorSpace;
struct YUVBuferIter {
int src_width;
int src_height;
@ -204,17 +206,17 @@ static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8* ar
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 src_fourcc, YUVColorSpace yuv_color_space) {
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;
switch (yuv_color_space) {
case mozilla::YUVColorSpace::BT2020:
case YUVColorSpace::BT2020:
iter.yuvconstants = &kYuv2020Constants;
break;
case mozilla::YUVColorSpace::BT709:
case YUVColorSpace::BT709:
iter.yuvconstants = &kYuvH709Constants;
break;
default:
@ -253,7 +255,7 @@ static void ScaleYUVToARGBDown2(int src_width, int src_height,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space) {
int j;
// Allocate 2 rows of ARGB for source conversion.
@ -390,7 +392,7 @@ static void ScaleYUVToARGBDownEven(int src_width, int src_height,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space) {
int j;
// Allocate 2 rows of ARGB for source conversion.
const int kRowSize = (src_width * 4 + 15) & ~15;
@ -511,7 +513,7 @@ static void ScaleYUVToARGBBilinearDown(int src_width, int src_height,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space) {
int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
@ -680,7 +682,7 @@ static void ScaleYUVToARGBBilinearUp(int src_width, int src_height,
int x, int dx, int y, int dy,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space) {
int j;
void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
@ -864,7 +866,7 @@ static void ScaleYUVToARGBSimple(int src_width, int src_height,
uint8* dst_argb,
int x, int dx, int y, int dy,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space) {
YUVColorSpace yuv_color_space) {
int j;
void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb,
int dst_width, int x, int dx) =
@ -933,7 +935,7 @@ static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
uint8* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space)
YUVColorSpace yuv_color_space)
{
YUVBuferIter iter;
iter.src_width = src_width;
@ -961,7 +963,7 @@ static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
int dst_width, int dst_height,
enum FilterMode filtering,
uint32 src_fourcc,
mozilla::YUVColorSpace yuv_color_space)
YUVColorSpace yuv_color_space)
{
// Initial source x/y coordinate and step values as 16.16 fixed point.
int x = 0;
@ -1099,7 +1101,7 @@ 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,
mozilla::YUVColorSpace yuv_color_space,
YUVColorSpace yuv_color_space,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,

Просмотреть файл

@ -14,7 +14,7 @@
#include "libyuv/basic_types.h"
#include "libyuv/scale.h" // For FilterMode
#include "ImageTypes.h" // For YUVColorSpace
#include "mozilla/gfx/Types.h" // For YUVColorSpace
#ifdef __cplusplus
namespace libyuv {
@ -25,7 +25,7 @@ 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,
mozilla::YUVColorSpace yuv_color_space,
mozilla::gfx::YUVColorSpace yuv_color_space,
int src_width, int src_height,
uint8* dst_argb, int dst_stride_argb,
int dst_width, int dst_height,

Просмотреть файл

@ -99,10 +99,10 @@ void ConvertYCbCrToRGB32(const uint8* y_buf, const uint8* u_buf,
const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x;
const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x;
switch (yuv_color_space) {
case mozilla::YUVColorSpace::BT2020:
case YUVColorSpace::BT2020:
fConvertYUVToARGB = libyuv::U444ToARGB;
break;
case mozilla::YUVColorSpace::BT709:
case YUVColorSpace::BT709:
fConvertYUVToARGB = libyuv::H444ToARGB;
break;
default:
@ -120,10 +120,10 @@ void ConvertYCbCrToRGB32(const uint8* y_buf, const uint8* u_buf,
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;
switch (yuv_color_space) {
case mozilla::YUVColorSpace::BT2020:
case YUVColorSpace::BT2020:
fConvertYUVToARGB = libyuv::U422ToARGB;
break;
case mozilla::YUVColorSpace::BT709:
case YUVColorSpace::BT709:
fConvertYUVToARGB = libyuv::H422ToARGB;
break;
default:
@ -142,10 +142,10 @@ void ConvertYCbCrToRGB32(const uint8* y_buf, const uint8* u_buf,
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;
switch (yuv_color_space) {
case mozilla::YUVColorSpace::BT2020:
case YUVColorSpace::BT2020:
fConvertYUVToARGB = libyuv::U420ToARGB;
break;
case mozilla::YUVColorSpace::BT709:
case YUVColorSpace::BT709:
fConvertYUVToARGB = libyuv::H420ToARGB;
break;
default:

Просмотреть файл

@ -6,12 +6,12 @@
#define MEDIA_BASE_YUV_CONVERT_H_
#include "chromium_types.h"
#include "ImageTypes.h"
#include "mozilla/gfx/Types.h"
namespace mozilla {
namespace gfx {
// Type of YUV surface.
// The value of these enums matter as they are used to shift vertical indices.
enum YUVType {