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
This commit is contained in:
Jean-Yves Avenard 2019-07-26 08:45:22 +00:00
parent 79b0c0cd82
commit e41290cb09
6 changed files with 23 additions and 5 deletions

View File

@ -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.

View File

@ -31,7 +31,7 @@ struct ParamTraits<mozilla::VideoInfo> {
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<mozilla::VideoInfo> {
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);

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -652,6 +652,12 @@ struct ParamTraits<mozilla::gfx::ColorDepth>
mozilla::gfx::ColorDepth::COLOR_8,
mozilla::gfx::ColorDepth::UNKNOWN> {};
template <>
struct ParamTraits<mozilla::gfx::ColorRange>
: public ContiguousEnumSerializer<mozilla::gfx::ColorRange,
mozilla::gfx::ColorRange::LIMITED,
mozilla::gfx::ColorRange::UNKNOWN> {};
template <>
struct ParamTraits<mozilla::gfx::YUVColorSpace>
: public ContiguousEnumSerializer<