Bug 1657075 - AVIF: use matrix coefficients to set YUVColorSpace. r=jbauman

Differential Revision: https://phabricator.services.mozilla.com/D85839
This commit is contained in:
Thomas Daede 2020-08-04 23:00:38 +00:00
parent 954472a91e
commit 0d996643b9

View File

@ -182,23 +182,26 @@ bool nsAVIFDecoder::DecodeWithDav1d(const Mp4parseByteData& aPrimaryItem,
aDecodedData.mStereoMode = StereoMode::MONO;
aDecodedData.mColorDepth = ColorDepthForBitDepth(mDav1dPicture->p.bpc);
switch (mDav1dPicture->seq_hdr->pri) {
case DAV1D_COLOR_PRI_BT601:
switch (mDav1dPicture->seq_hdr->mtrx) {
case DAV1D_MC_BT601:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT601;
break;
case DAV1D_COLOR_PRI_BT709:
case DAV1D_MC_BT709:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT709;
break;
case DAV1D_COLOR_PRI_BT2020:
case DAV1D_MC_BT2020_NCL:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
break;
case DAV1D_COLOR_PRI_UNKNOWN:
case DAV1D_MC_BT2020_CL:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
break;
case DAV1D_MC_UNKNOWN:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
break;
default:
MOZ_LOG(sAVIFLog, LogLevel::Debug,
("[this=%p] unsupported color primaries value: %u", this,
mDav1dPicture->seq_hdr->pri));
("[this=%p] unsupported color matrix value: %u", this,
mDav1dPicture->seq_hdr->mtrx));
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
}
@ -293,23 +296,26 @@ bool nsAVIFDecoder::DecodeWithAOM(const Mp4parseByteData& aPrimaryItem,
aDecodedData.mStereoMode = StereoMode::MONO;
aDecodedData.mColorDepth = ColorDepthForBitDepth(img->bit_depth);
switch (img->cp) {
case AOM_CICP_CP_BT_601:
switch (img->mc) {
case AOM_CICP_MC_BT_601:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT601;
break;
case AOM_CICP_CP_BT_709:
case AOM_CICP_MC_BT_709:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT709;
break;
case AOM_CICP_CP_BT_2020:
case AOM_CICP_MC_BT_2020_NCL:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
break;
case AOM_CICP_CP_UNSPECIFIED:
case AOM_CICP_MC_BT_2020_CL:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
break;
case AOM_CICP_MC_UNSPECIFIED:
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
break;
default:
MOZ_LOG(sAVIFLog, LogLevel::Debug,
("[this=%p] unsupported aom_color_primaries value: %u", this,
img->cp));
("[this=%p] unsupported aom_matrix_coefficients value: %u", this,
img->mc));
aDecodedData.mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
}