Skip to content

Commit

Permalink
output AVIF transformations after 'clap' as required by MIAF and alwa…
Browse files Browse the repository at this point in the history
…ys include MIAF brand for AVIF images
  • Loading branch information
farindk committed Nov 10, 2023
1 parent 84eb828 commit a4a2bfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2803,20 +2803,25 @@ Error HeifContext::encode_image_as_av1(const std::shared_ptr<HeifPixelImage>& im

// Note: 'ispe' must be before the transformation properties
m_heif_file->add_ispe_property(image_id, encoded_width, encoded_height);
m_heif_file->add_orientation_properties(image_id, options.image_orientation);

if (input_width != encoded_width ||
input_height != encoded_height) {
m_heif_file->add_clap_property(image_id, input_width, input_height,
encoded_width, encoded_height);

// MIAF 7.3.6.7
// According to MIAF without Amd2, an image is required to be cropped to multiples of the chroma format raster.
// However, since AVIF is based on MIAF, the whole image would be invalid in that case.
// As this restriction was lifted with MIAF-Amd2, we include the MIAF brand for all AVIF images.

if (!is_integer_multiple_of_chroma_size(out_image->get_width(),
out_image->get_height(),
/*
if (!is_integer_multiple_of_chroma_size(input_width,
input_height,
src_image->get_chroma_format())) {
out_image->mark_not_miaf_compatible();
}
*/

m_heif_file->add_orientation_properties(image_id, options.image_orientation);
}


Expand Down
3 changes: 3 additions & 0 deletions libheif/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,9 @@ heif_property_id HeifFile::add_property(heif_item_id id, std::shared_ptr<Box> pr

void HeifFile::add_orientation_properties(heif_item_id id, heif_orientation orientation)
{
// Note: ISO/IEC 23000-22:2019(E) (MIAF) 7.3.6.7 requires the following order:
// clean aperture first, then rotation, then mirror

int rotation_ccw = 0;
heif_transform_mirror_direction mirror;
bool has_mirror = false;
Expand Down

0 comments on commit a4a2bfa

Please sign in to comment.