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

Invalid test files using CleanApertureBox (clap) transformation #150

Open
baumanj opened this issue May 22, 2021 · 0 comments
Open

Invalid test files using CleanApertureBox (clap) transformation #150

baumanj opened this issue May 22, 2021 · 0 comments
Labels

Comments

@baumanj
Copy link
Collaborator

baumanj commented May 22, 2021

All 5 of the files under https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles which use the CleanApertureBox (clap) are invalid.

Per ISOBMFF (ISO 14496-12:2020) § 12.1.4.1

Considering the pixel dimensions as defined by the VisualSampleEntr width and height. If picture centre of the image is at pcXandpcY, then horizOffandvertOff` are defined as follows:

pcX = horizOff + (width  - 1)/2
pcY = vertOff  + (height - 1)/2;

Typically, horizOff and vertOff are zero, so the image is centre
about the picture centre. The leftmost/rightmost pixel and the
topmost/bottommost line of the clean aperture fall at:

pcX ± (cleanApertureWidth - 1)/2
pcY ± (cleanApertureHeight - 1)/2;

Applying these formuæ show that the lines of the clean aperture do not fall on integer pixels. Take
testFiles/Microsoft/Chimera_10bit_cropped_to_1920x1008.avif. Loading this file in MP4Box.js shows the relevant inputs: ImageSpatialExtents (ispe) and CleanApertureBox (clap) under meta::iprp::ipco:

ispe

  • image_width | 1920
  • image_height | 1080

clap

  • cleanApertureWidthN | 1920
  • cleanApertureWidthD | 1
  • cleanApertureHeightN | 1008
  • cleanApertureHeightD | 1
  • horizOffN | 1
  • horizOffD | 2
  • vertOffN | 1
  • vertOffD | 2

Calculating the vertical clean aperture lines:

pcX = horizOff + (width  - 1)/2
    = ( 1/2  ) + (1920   - 1)/2
    = ( 1/2  ) + (1919      )/2
    = 1920/2
    = 960

pcX ± (cleanApertureWidth - 1)/2
960 ± (1920               - 1)/2
960 ± 1919/2
960 ± 959.5
(1919.5, 0.5)

A quick test is that if the length of the image dimension and the crop dimension have the same parity, the offset in that dimension must be a while number. If they have opposite parity, the offset must be a half pixel value. The above example fails because 1920 and 1920 are both even, but 1/2 is not a whole number.

There are similar issues with the rest of these files as well:

baumanj added a commit to mozilla/mp4parse-rust that referenced this issue May 24, 2021
The main change is adding support for the mirroring (imir) and rotation (irot)
transformations. Additional changes include:

- Rename existing AvifItem → IsobmffItem since it isn't AVIF-specific
- Rename AvifImage → Mp4parseAvifImage (for consistency with the C API)
- Create AvifItem for more specific use cases
- Expose spatial_extents (i.e., size), image_rotation and image_mirror to C API
- Add newtypes for PropertyIndex and ItemId
- Store ipma with the nested structure it has in the file rather than
  flattening it; this facilitates validation (especially of transform ordering)
- Simplify mp4parse_avif_get_image to make it safer and eliminate the need for
  Mp4parseAvifImage to implement Default
- Add mp4parse_avif_get_image output to dump example
- Add AV1_AVIF_CORRUPT_IMAGES to skip bad upstream examples
 (see AOMediaCodec/av1-avif#150)
- Various testing improvements

Note this removes clap code because it's preferable to add that support all
together and this change is already big enough.
baumanj added a commit to mozilla/mp4parse-rust that referenced this issue May 25, 2021
The main change is adding support for the mirroring (imir) and rotation (irot)
transformations. Additional changes include:

- Rename existing AvifItem → IsobmffItem since it isn't AVIF-specific
- Rename AvifImage → Mp4parseAvifImage (for consistency with the C API)
- Create AvifItem for more specific use cases
- Expose spatial_extents (i.e., size), image_rotation and image_mirror to C API
- Add newtypes for PropertyIndex and ItemId
- Store ipma with the nested structure it has in the file rather than
  flattening it; this facilitates validation (especially of transform ordering)
- Simplify mp4parse_avif_get_image to make it safer and eliminate the need for
  Mp4parseAvifImage to implement Default
- Add mp4parse_avif_get_image output to dump example
- Add AV1_AVIF_CORRUPT_IMAGES to skip bad upstream examples
 (see AOMediaCodec/av1-avif#150)
- Various testing improvements

Note this removes clap code because it's preferable to add that support all
together and this change is already big enough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants