Commit 952a5ec9 authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Change AVIF matrix coefficients default to BT.601

Change the AVIF matrix coefficients default to 6 (BT.601). This is
specified in the draft MIAF Amendment 2.

Bug: 1119465
Change-Id: I2aa6a07e709327fd1f776effc5767c887928c660
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364026
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799908}
parent 7c682164
...@@ -47,14 +47,20 @@ namespace { ...@@ -47,14 +47,20 @@ namespace {
// YUV-to-RGB conversion. If the image does not have an ICC profile, this color // YUV-to-RGB conversion. If the image does not have an ICC profile, this color
// space is also used to create the embedded color profile. // space is also used to create the embedded color profile.
gfx::ColorSpace GetColorSpace(const avifImage* image) { gfx::ColorSpace GetColorSpace(const avifImage* image) {
// MIAF Section 7.3.6.4 says: // (As of ISO/IEC 23000-22:2019 Amendment 2) MIAF Section 7.3.6.4 says:
// If a coded image has no associated colour property, the default property // If a coded image has no associated colour property, the default property
// is defined as having colour_type equal to 'nclx' with properties as // is defined as having colour_type equal to 'nclx' with properties as
// follows: // follows:
// – For YCbCr encoding, sYCC should be assumed as indicated by // – colour_primaries equal to 1,
// colour_primaries equal to 1, transfer_characteristics equal to 13, // - transfer_characteristics equal to 13,
// matrix_coefficients equal to 1, and full_range_flag equal to 1. // - matrix_coefficients equal to 5 or 6 (which are functionally identical),
// and
// - full_range_flag equal to 1.
// ... // ...
// These values correspond to AVIF_COLOR_PRIMARIES_BT709,
// AVIF_TRANSFER_CHARACTERISTICS_SRGB, and AVIF_MATRIX_COEFFICIENTS_BT601,
// respectively.
//
// Note that this only specifies the default color property when the color // Note that this only specifies the default color property when the color
// property is absent. It does not really specify the default values for // property is absent. It does not really specify the default values for
// colour_primaries, transfer_characteristics, and matrix_coefficients when // colour_primaries, transfer_characteristics, and matrix_coefficients when
...@@ -73,7 +79,7 @@ gfx::ColorSpace GetColorSpace(const avifImage* image) { ...@@ -73,7 +79,7 @@ gfx::ColorSpace GetColorSpace(const avifImage* image) {
: image->transferCharacteristics; : image->transferCharacteristics;
const auto matrix = const auto matrix =
image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_UNSPECIFIED image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_UNSPECIFIED
? AVIF_MATRIX_COEFFICIENTS_BT709 ? AVIF_MATRIX_COEFFICIENTS_BT601
: image->matrixCoefficients; : image->matrixCoefficients;
const auto range = image->yuvRange == AVIF_RANGE_FULL const auto range = image->yuvRange == AVIF_RANGE_FULL
? gfx::ColorSpace::RangeID::FULL ? gfx::ColorSpace::RangeID::FULL
......
...@@ -157,6 +157,18 @@ StaticColorCheckParam kTestParams[] = { ...@@ -157,6 +157,18 @@ StaticColorCheckParam kTestParams[] = {
{gfx::Point(1, 1), SkColorSetARGB(255, 255, 0, 0)}, {gfx::Point(1, 1), SkColorSetARGB(255, 255, 0, 0)},
{gfx::Point(2, 2), SkColorSetARGB(255, 255, 0, 0)}, {gfx::Point(2, 2), SkColorSetARGB(255, 255, 0, 0)},
}}, }},
{"/images/resources/avif/red-full-range-unspecified-420-8bpc.avif",
8,
ColorType::kRgb,
ImageDecoder::kLosslessFormat,
ImageDecoder::kAlphaNotPremultiplied,
ColorBehavior::Tag(),
3,
{
{gfx::Point(0, 0), SkColorSetARGB(255, 255, 0, 0)},
{gfx::Point(1, 1), SkColorSetARGB(255, 255, 0, 0)},
{gfx::Point(2, 2), SkColorSetARGB(255, 255, 0, 0)},
}},
{"/images/resources/avif/silver-full-range-srgb-420-8bpc.avif", {"/images/resources/avif/silver-full-range-srgb-420-8bpc.avif",
8, 8,
ColorType::kRgb, ColorType::kRgb,
......
...@@ -60,6 +60,11 @@ avifenc -r f -d 10 -y 444 -s 0 --nclx 9/18/9 red.png red-full-range-bt2020-hlg-4 ...@@ -60,6 +60,11 @@ avifenc -r f -d 10 -y 444 -s 0 --nclx 9/18/9 red.png red-full-range-bt2020-hlg-4
avifenc -r f -d 10 -y 444 -s 0 --nclx 9/18/9 red.png red-full-range-bt2020-hlg-444-12bpc.avif avifenc -r f -d 10 -y 444 -s 0 --nclx 9/18/9 red.png red-full-range-bt2020-hlg-444-12bpc.avif
``` ```
Unspecified color primaries, transfer characteristics, and matrix coefficients:
```
avifenc -r f -d 8 -y 420 -s 0 --nclx 2/2/2 red.png red-full-range-unspecified-420-8bpc.avif
```
### silver-full-range-srgb-420-8bpc.avif ### silver-full-range-srgb-420-8bpc.avif
This is generated from silver.png (3x3 rgb(192, 192, 192)) with the appropriate This is generated from silver.png (3x3 rgb(192, 192, 192)) with the appropriate
avifenc command line: avifenc command line:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment