From e41290cb094e33b7bfdd91748f66b1027f24295d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 26 Jul 2019 08:45:22 +0000 Subject: [PATCH] Bug 1543359 - P0. Make video range info an enum. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D29639 --HG-- extra : moz-landing-system : lando --- dom/media/MediaInfo.h | 2 +- dom/media/ipc/MediaIPCUtils.h | 4 ++-- dom/media/platforms/agnostic/VPXDecoder.h | 4 ++++ dom/media/platforms/wrappers/MediaChangeMonitor.cpp | 6 ++++-- gfx/2d/Types.h | 6 ++++++ gfx/ipc/GfxMessageUtils.h | 6 ++++++ 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dom/media/MediaInfo.h b/dom/media/MediaInfo.h index 034b2b6ba620..29a53de1ef9f 100644 --- a/dom/media/MediaInfo.h +++ b/dom/media/MediaInfo.h @@ -251,7 +251,7 @@ class VideoInfo : public TrackInfo { // True indicates no restriction on Y, U, V values (otherwise 16-235 for 8 // bits etc) - bool mFullRange = false; + gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; private: // mImage may be cropped; currently only used with the WebM container. diff --git a/dom/media/ipc/MediaIPCUtils.h b/dom/media/ipc/MediaIPCUtils.h index 294cfb18b855..e2d91bdf6978 100644 --- a/dom/media/ipc/MediaIPCUtils.h +++ b/dom/media/ipc/MediaIPCUtils.h @@ -31,7 +31,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mRotation); WriteParam(aMsg, aParam.mColorDepth); WriteParam(aMsg, aParam.mColorSpace); - WriteParam(aMsg, aParam.mFullRange); + WriteParam(aMsg, aParam.mColorRange); WriteParam(aMsg, aParam.HasAlpha()); } @@ -49,7 +49,7 @@ struct ParamTraits { ReadParam(aMsg, aIter, &aResult->mRotation) && ReadParam(aMsg, aIter, &aResult->mColorDepth) && ReadParam(aMsg, aIter, &aResult->mColorSpace) && - ReadParam(aMsg, aIter, &aResult->mFullRange) && + ReadParam(aMsg, aIter, &aResult->mColorRange) && ReadParam(aMsg, aIter, &alphaPresent)) { aResult->SetImageRect(imageRect); aResult->SetAlpha(alphaPresent); diff --git a/dom/media/platforms/agnostic/VPXDecoder.h b/dom/media/platforms/agnostic/VPXDecoder.h index 9f242bd90764..ddd803086303 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.h +++ b/dom/media/platforms/agnostic/VPXDecoder.h @@ -111,6 +111,10 @@ class VPXDecoder : public MediaDataDecoder, */ bool mFullRange = false; + gfx::ColorRange ColorRange() const { + return mFullRange ? gfx::ColorRange::FULL : gfx::ColorRange::LIMITED; + } + /* Sub-sampling, used only for non sRGB colorspace. subsampling_x subsampling_y Description diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp index 0cf3759467e8..db147723a495 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -141,7 +141,9 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { gfx::IntRect(0, 0, spsdata.pic_width, spsdata.pic_height)); mCurrentConfig.mColorDepth = spsdata.ColorDepth(); mCurrentConfig.mColorSpace = spsdata.ColorSpace(); - mCurrentConfig.mFullRange = spsdata.video_full_range_flag; + mCurrentConfig.mColorRange = spsdata.video_full_range_flag + ? gfx::ColorRange::FULL + : gfx::ColorRange::LIMITED; } mCurrentConfig.mExtraData = aExtraData; mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); @@ -202,7 +204,7 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { // The AR data isn't found in the VP8/VP9 bytestream. mCurrentConfig.mColorDepth = gfx::ColorDepthForBitDepth(info.mBitDepth); mCurrentConfig.mColorSpace = info.ColorSpace(); - mCurrentConfig.mFullRange = info.mFullRange; + mCurrentConfig.mColorRange = info.ColorRange(); mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); return rv; diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 54e6cf1d6403..c1cb9e046a50 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -156,6 +156,12 @@ enum class ColorDepth : uint8_t { UNKNOWN }; +enum class ColorRange : uint8_t { + LIMITED, + FULL, + UNKNOWN +}; + static inline SurfaceFormat SurfaceFormatForColorDepth(ColorDepth aColorDepth) { SurfaceFormat format = SurfaceFormat::A8; switch (aColorDepth) { diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 2ddefbc872bc..a4cad43e31cc 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -652,6 +652,12 @@ struct ParamTraits mozilla::gfx::ColorDepth::COLOR_8, mozilla::gfx::ColorDepth::UNKNOWN> {}; +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + template <> struct ParamTraits : public ContiguousEnumSerializer<