Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial revert "Ignore descr props after transf" #2585

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ The changes are relative to the previous release, unless the baseline is specifi
* Deprecate avifCropRectConvertCleanApertureBox() and
avifCleanApertureBoxConvertCropRect(). Replace them with
avifCropRectFromCleanApertureBox() and avifCleanApertureBoxFromCropRect().
* Ignore descriptive properties associated after transformative ones.
* Reject non-essential transformative properties.

## [1.1.1] - 2024-07-30
Expand Down
23 changes: 0 additions & 23 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -2735,7 +2735,6 @@ static avifResult avifParseItemPropertyAssociation(avifMeta * meta, const uint8_

uint8_t associationCount;
AVIF_CHECKERR(avifROStreamRead(&s, &associationCount, 1), AVIF_RESULT_BMFF_PARSE_FAILED);
avifBool transformativePropertySeen = AVIF_FALSE;
for (uint8_t associationIndex = 0; associationIndex < associationCount; ++associationIndex) {
uint8_t essential;
AVIF_CHECKERR(avifROStreamReadBitsU8(&s, &essential, /*bitCount=*/1), AVIF_RESULT_BMFF_PARSE_FAILED); // bit(1) essential;
Expand Down Expand Up @@ -2766,23 +2765,6 @@ static avifResult avifParseItemPropertyAssociation(avifMeta * meta, const uint8_
// Copy property to item
const avifProperty * srcProp = &meta->properties.prop[propertyIndex];

// ISO/IEC 23000-22:2019/Amd. 2:2021 Section 7.3.9:
// All transformative properties associated with coded and derived images shall be marked as essential,
// and shall be from the set defined in 7.3.6.7 or the applicable MIAF profile. No other essential
// transformative property shall be associated with such images.
const avifBool isTransformative = !memcmp(srcProp->type, "clap", 4) || !memcmp(srcProp->type, "irot", 4) ||
!memcmp(srcProp->type, "imir", 4);
// ISO/IEC 23008-12:2022 Section 3.1.28:
// item property: descriptive or transformative information
const avifBool isDescriptive = !isTransformative;
// ISO/IEC 23008-12:2022 Section 6.5.1:
// Readers shall allow and ignore descriptive properties following the first transformative or
// unrecognized property, whichever is earlier, in the sequence associating properties with an item.
// No need to check for unrecognized properties as they cannot be transformative according to MIAF.
if (transformativePropertySeen && isDescriptive) {
continue;
}

// Some properties are supported and parsed by libavif.
// Other properties are forwarded to the user as opaque blobs.
const avifBool supportedType = !srcProp->isOpaque;
Expand Down Expand Up @@ -2870,11 +2852,6 @@ static avifResult avifParseItemPropertyAssociation(avifMeta * meta, const uint8_
AVIF_CHECKRES(
avifRWDataSet(&dstProp->u.opaque.boxPayload, srcProp->u.opaque.boxPayload.data, srcProp->u.opaque.boxPayload.size));
}

if (isTransformative) {
AVIF_ASSERT_OR_RETURN(supportedType);
transformativePropertySeen = AVIF_TRUE;
}
}
}
return AVIF_RESULT_OK;
Expand Down
10 changes: 7 additions & 3 deletions tests/gtest/aviftransformtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ TEST(TransformTest, ClopIrotImor) {
ASSERT_EQ(avifDecoderSetIOFile(decoder.get(), path.c_str()), AVIF_RESULT_OK);
ASSERT_EQ(avifDecoderParse(decoder.get()), AVIF_RESULT_OK);

// 'imor' shall be ignored by libavif as it is after a transformative property
// in the 'ipma' association order.
ASSERT_EQ(decoder->image->numProperties, 1u);
// 'imor' should be ignored as it is after a transformative property in the
// 'ipma' association order. libavif still surfaces it because this constraint
// is relaxed in Amd2 of HEIF ISO/IEC 23008-12.
// See https://github.com/MPEGGroup/FileFormat/issues/113.
ASSERT_EQ(decoder->image->numProperties, 2u);
const avifImageItemProperty& clop = decoder->image->properties[0];
EXPECT_EQ(std::string(clop.boxtype, clop.boxtype + 4), "clop");
const avifImageItemProperty& imor = decoder->image->properties[1];
EXPECT_EQ(std::string(imor.boxtype, imor.boxtype + 4), "imor");
}

//------------------------------------------------------------------------------
Expand Down
Loading