Bug 1951423. Use the sRGB transfer characteristics for BT.709, BT.601, and BT.2020. r=gfx-reviewers,aosmond
That is what other apps are doing. Differential Revision: https://phabricator.services.mozilla.com/D240850
This commit is contained in:
@@ -16,11 +16,13 @@
|
|||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsProxyRelease.h"
|
#include "nsProxyRelease.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "mozilla/StaticPrefs_gfx.h"
|
||||||
|
|
||||||
using mozilla::gfx::IntPoint;
|
using mozilla::gfx::IntPoint;
|
||||||
using mozilla::gfx::IntRect;
|
using mozilla::gfx::IntRect;
|
||||||
using mozilla::gfx::IntSize;
|
using mozilla::gfx::IntSize;
|
||||||
using mozilla::gfx::SurfaceFormat;
|
using mozilla::gfx::SurfaceFormat;
|
||||||
|
using namespace mozilla::gfx::CICP;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace image {
|
namespace image {
|
||||||
@@ -588,5 +590,38 @@ void Decoder::PostError() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
uint8_t Decoder::ChooseTransferCharacteristics(uint8_t aTC) {
|
||||||
|
// Most apps, including Chrome
|
||||||
|
// (https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/color_space.cc;l=906;drc=2e47178120fb82aced74f8dbccf358aa13073a83),
|
||||||
|
// use the sRGB TC for BT.709 TC. We have a pref to provide that behaviour.
|
||||||
|
// Since BT.2020 uses the same TC we can also optionally use this behaviour
|
||||||
|
// for BT.2020.
|
||||||
|
const bool rec709GammaAsSrgb =
|
||||||
|
StaticPrefs::gfx_color_management_rec709_gamma_as_srgb();
|
||||||
|
const bool rec2020GammaAsRec709 =
|
||||||
|
StaticPrefs::gfx_color_management_rec2020_gamma_as_rec709();
|
||||||
|
switch (aTC) {
|
||||||
|
case TransferCharacteristics::TC_BT709:
|
||||||
|
case TransferCharacteristics::TC_BT601:
|
||||||
|
if (rec709GammaAsSrgb) {
|
||||||
|
return TransferCharacteristics::TC_SRGB;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TransferCharacteristics::TC_BT2020_10BIT:
|
||||||
|
case TransferCharacteristics::TC_BT2020_12BIT:
|
||||||
|
if (rec2020GammaAsRec709) {
|
||||||
|
if (rec709GammaAsSrgb) {
|
||||||
|
return TransferCharacteristics::TC_SRGB;
|
||||||
|
}
|
||||||
|
return TransferCharacteristics::TC_BT709;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return aTC;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace image
|
} // namespace image
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -580,6 +580,8 @@ class Decoder {
|
|||||||
RawAccessFrameRef&& aPreviousFrame);
|
RawAccessFrameRef&& aPreviousFrame);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static uint8_t ChooseTransferCharacteristics(uint8_t aTC);
|
||||||
|
|
||||||
/// Color management profile from the ICCP chunk in the image.
|
/// Color management profile from the ICCP chunk in the image.
|
||||||
qcms_profile* mInProfile;
|
qcms_profile* mInProfile;
|
||||||
|
|
||||||
|
|||||||
@@ -1746,7 +1746,8 @@ nsAVIFDecoder::DecodeResult nsAVIFDecoder::DoDecodeInternal(
|
|||||||
MOZ_ASSERT(tc != CICP::TransferCharacteristics::TC_UNSPECIFIED &&
|
MOZ_ASSERT(tc != CICP::TransferCharacteristics::TC_UNSPECIFIED &&
|
||||||
!CICP::IsReserved(tc));
|
!CICP::IsReserved(tc));
|
||||||
|
|
||||||
mInProfile = qcms_profile_create_cicp(cp, tc);
|
mInProfile =
|
||||||
|
qcms_profile_create_cicp(cp, ChooseTransferCharacteristics(tc));
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_LOG(sAVIFLog, LogLevel::Debug,
|
MOZ_LOG(sAVIFLog, LogLevel::Debug,
|
||||||
|
|||||||
@@ -446,7 +446,8 @@ uint32_t nsPNGDecoder::ReadColorProfile(png_structp png_ptr, png_infop info_ptr,
|
|||||||
"supported\n"));
|
"supported\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mInProfile = qcms_profile_create_cicp(primaries, tc);
|
mInProfile = qcms_profile_create_cicp(
|
||||||
|
primaries, ChooseTransferCharacteristics(tc));
|
||||||
if (mInProfile) {
|
if (mInProfile) {
|
||||||
return qcms_profile_get_rendering_intent(mInProfile);
|
return qcms_profile_get_rendering_intent(mInProfile);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
image/test/reftest/color-management/720p-CCWH.png
Normal file
BIN
image/test/reftest/color-management/720p-CCWH.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@@ -5,3 +5,6 @@
|
|||||||
== invalid-whitepoint.png invalid-chrm-ref.png
|
== invalid-whitepoint.png invalid-chrm-ref.png
|
||||||
# test for bug 488955
|
# test for bug 488955
|
||||||
== trc-type.html trc-type-ref.html # Bug 1560617
|
== trc-type.html trc-type-ref.html # Bug 1560617
|
||||||
|
# test for bug 1951423, bt709/bt601/bt2020/bt1886
|
||||||
|
fuzzy(0-4,0-182740) == 720p-CCWH.png 720p-CCWH_yuv444p_pc-1-13-6.avif
|
||||||
|
fuzzy(0-16,0-268977) == 720p-CCWH.png 720p-CCWH_yuv444p_tv-1-1-1.avif
|
||||||
|
|||||||
Reference in New Issue
Block a user