Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vrabaud committed Feb 10, 2025
1 parent 2ff8e4c commit 8e37b0a
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 50 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-fuzztest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
-DAVIF_LIBYUV=${{ matrix.libyuv }}
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-unix-shared-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
-DAVIF_LIBYUV=${{ matrix.libyuv }}
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-unix-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
-DAVIF_LIBSHARPYUV=LOCAL -DAVIF_LIBXML2=LOCAL -DAVIF_LIBYUV=LOCAL
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows-installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ jobs:
-DAVIF_LIBYUV=SYSTEM -DAVIF_ZLIBPNG=SYSTEM
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows-shared-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
-DAVIF_LIBYUV=LOCAL -DAVIF_ZLIBPNG=LOCAL
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
-DAVIF_LIBYUV=LOCAL -DAVIF_ZLIBPNG=LOCAL
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_YCGCO_R_ENCODING=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI=ON
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ The changes are relative to the previous release, unless the baseline is specifi
avifCropRectFromCleanApertureBox() and avifCleanApertureBoxFromCropRect().
* Reject non-essential transformative properties.
* Treat avifenc --stdin as a regular positional file path argument.
* Allow YCgCo_Re and YCgCo_Ro decoding by default. Encoding is still conditioned
to the AVIF_ENABLE_YCGCO_R_ENCODING CMake option.
* Allow YCgCo_Re and YCgCo_Ro encoding/decoding.

## [1.1.1] - 2024-07-30

Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ option(BUILD_SHARED_LIBS "Build shared avif library" ON)

option(AVIF_ENABLE_WERROR "Treat all compiler warnings as errors" OFF)

option(AVIF_ENABLE_YCGCO_R_ENCODING "Enable YCgCo-R matrix codes for encoding" OFF)
option(AVIF_ENABLE_EXPERIMENTAL_MINI "Enable experimental reduced header" OFF)
option(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM "Enable experimental sample transform code" OFF)
option(AVIF_ENABLE_EXPERIMENTAL_EXTENDED_PIXI "Enable experimental PixelInformationProperty syntax from HEIF 3rd Ed. Amd2" OFF)
Expand Down Expand Up @@ -340,10 +339,6 @@ if(AVIF_ENABLE_COVERAGE)
endif()
endif()

if(AVIF_ENABLE_YCGCO_R_ENCODING)
add_compile_definitions(AVIF_ENABLE_YCGCO_R_ENCODING)
endif()

if(AVIF_ENABLE_EXPERIMENTAL_MINI)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_MINI)
endif()
Expand Down
24 changes: 6 additions & 18 deletions apps/avifenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,17 +2019,11 @@ int main(int argc, char * argv[])
}
// Matrix coefficients.
if (settings.cicpExplicitlySet) {
avifBool incompatibleMC = (settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_IDENTITY);
#if defined(AVIF_ENABLE_YCGCO_R_ENCODING)
incompatibleMC &= (settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_YCGCO_RE &&
settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_YCGCO_RO);
#endif
avifBool incompatibleMC = (settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_IDENTITY) &&
(settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_YCGCO_RE &&
settings.matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_YCGCO_RO);
if (incompatibleMC) {
#if defined(AVIF_ENABLE_YCGCO_R_ENCODING)
fprintf(stderr, "Matrix coefficients have to be identity, YCgCo-Re, or YCgCo-Ro in lossless mode.\n");
#else
fprintf(stderr, "Matrix coefficients have to be identity in lossless mode.\n");
#endif
goto cleanup;
}
} else {
Expand Down Expand Up @@ -2480,17 +2474,11 @@ int main(int argc, char * argv[])
lossless = AVIF_FALSE;
}

avifBool matrixCoefficientsAreLosslessCompatible = usingIdentityMatrix;
#if defined(AVIF_ENABLE_YCGCO_R_ENCODING)
matrixCoefficientsAreLosslessCompatible |= (image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RE ||
image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RO);
#endif
avifBool matrixCoefficientsAreLosslessCompatible = usingIdentityMatrix ||
(image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RE ||
image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RO);
if (!matrixCoefficientsAreLosslessCompatible && !using400) {
#if defined(AVIF_ENABLE_YCGCO_R_ENCODING)
fprintf(stderr, "WARNING: [--lossless] Input data was RGB and matrixCoefficients isn't set to identity (--cicp x/x/0) or YCgCo-Re/Ro (--cicp x/x/16 or x/x/17); Output might not be lossless.\n");
#else
fprintf(stderr, "WARNING: [--lossless] Input data was RGB and matrixCoefficients isn't set to identity (--cicp x/x/0); Output might not be lossless.\n");
#endif
lossless = AVIF_FALSE;
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/avif/avif.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ enum
AVIF_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL = 12,
AVIF_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL = 13,
AVIF_MATRIX_COEFFICIENTS_ICTCP = 14,
AVIF_MATRIX_COEFFICIENTS_YCGCO_RE = 16,
AVIF_MATRIX_COEFFICIENTS_YCGCO_RO = 17,
AVIF_MATRIX_COEFFICIENTS_YCGCO_RE = 16, // Added to libavif in Feb 2025
AVIF_MATRIX_COEFFICIENTS_YCGCO_RO = 17, // Added to libavif in Feb 2025
AVIF_MATRIX_COEFFICIENTS_LAST
};
typedef uint16_t avifMatrixCoefficients; // AVIF_MATRIX_COEFFICIENTS_*
Expand Down
10 changes: 0 additions & 10 deletions src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,16 +1629,6 @@ static avifResult avifValidateGrid(uint32_t gridCols,
AVIF_ASSERT_OR_RETURN(cellImage->gainMap && cellImage->gainMap->image);
cellImage = cellImage->gainMap->image;
}
#if !defined(AVIF_ENABLE_YCGCO_R_ENCODING)
if (cellImage->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RE ||
cellImage->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO_RO) {
avifDiagnosticsPrintf(diag,
"YCGCO_R is not enabled for encoding. "
"Please set AVIF_ENABLE_YCGCO_R_ENCODING in CMake. "
"cf https://github.com/AOMediaCodec/libavif/issues/2077.");
return AVIF_RESULT_NOT_IMPLEMENTED;
}
#endif
const uint32_t expectedCellWidth = ((cellIndex + 1) % gridCols) ? tileWidth : bottomRightCell->width;
const uint32_t expectedCellHeight = (cellIndex < (cellCount - gridCols)) ? tileHeight : bottomRightCell->height;
if ((cellImage->width != expectedCellWidth) || (cellImage->height != expectedCellHeight)) {
Expand Down
7 changes: 0 additions & 7 deletions tests/gtest/aviflosslesstest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ TEST(BasicTest, EncodeDecodeMatrixCoefficients) {
avifResult result =
avifEncoderWrite(encoder.get(), image.get(), &encoded);

#if !defined(AVIF_ENABLE_YCGCO_R_ENCODING)
if (matrix_coefficient == AVIF_MATRIX_COEFFICIENTS_YCGCO_RE) {
EXPECT_EQ(result, AVIF_RESULT_NOT_IMPLEMENTED);
continue;
}
#endif

ASSERT_EQ(result, AVIF_RESULT_OK) << avifResultToString(result);

// Decode to RAM.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_cmd_lossless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ pushd ${TMP_DIR}
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE_LOSSLESS}"
"${ARE_IMAGES_EQUAL}" "${INPUT_PNG}" "${DECODED_FILE_LOSSLESS}" 0

echo "Testing YCgCo-Re lossless"
"${AVIFENC}" -s 10 -l --cicp 2/2/16 "${INPUT_PNG}" -o "${ENCODED_FILE}"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE_LOSSLESS}"
"${ARE_IMAGES_EQUAL}" "${INPUT_PNG}" "${DECODED_FILE_LOSSLESS}" 0

echo "Testing YCgCo-Ro lossless fails because the input bit depth is even"
"${AVIFENC}" -s 10 -l --cicp 2/2/17 "${INPUT_PNG}" -o "${ENCODED_FILE}" && exit 1

# 400 test.
echo "Testing 400 lossless"
"${AVIFENC}" -y 400 -s 10 -l "${INPUT_GRAY_PNG}" -o "${ENCODED_FILE}"
Expand Down

0 comments on commit 8e37b0a

Please sign in to comment.