AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.45k stars 190 forks source link

Support clap, imir, irot property in ItemPropertyContainerBox #41

Closed ledyba-z closed 4 years ago

ledyba-z commented 4 years ago

Hi!

@dreampiggy says that he or she wants to support rotation/mirroring/cropping in SDImageAVIFCoder, but I found that imr, irot, clap box (defined in HEIF) is not recognized:

https://github.com/AOMediaCodec/libavif/blob/f9bba7d9934b8aefeb1d5f1a57c98ea809aebe50/src/read.c#L653-L679

MIAF specification says that there are no transformation information in EXIF metadata in MIAF, so libavif might have to parse those boxes to handle transformation correctly.

There is no need for a reader to understand the details of the metadata. There should be no image transformations expressed by Exif (rotation, mirroring, etc.) indicated in the Exif metadata, in files encoded according to this document. MIAF, p16

Our avif parser implementation, libavif-container parses them, so please refer if you need.

https://github.com/link-u/libavif-container/blob/371ca8f421d1622065cd1f34e8d0abe0886cf259/src/avif/Parser.cpp#L231-L321

ledyba-z commented 4 years ago

FYI: I prepared the test images with rotation/mirroring/crop operations, so feel free to use them:

https://github.com/link-u/avif-sample-images#kimono---transformation-tests

novomesk commented 4 years ago

Windows applications display 1080x1920 picture: Ronda_rotate90_IrfanView But we display 1920x1080: Ronda_rotate90_gimp I think it is because of irot. Testfile: https://github.com/AOMediaCodec/av1-avif/blob/master/testFiles/Microsoft/Ronda_rotate90.avif I can rotate the picture myself but I need some info that I should do it.

joedrago commented 4 years ago

I am in the middle of refactoring the RGB conversion, but after that I can surface the content of these boxes the way that I surface container* values right now.

novomesk commented 4 years ago

What a co-incidence. New testfiles appeared: https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Link-U

ledyba-z commented 4 years ago

I created those files 😄. Please use them to check!

joedrago commented 4 years ago

I've decided that it is libavif's responsibility to plumb through these boxes (both encode and decode), but I'm going to consider the implementation of these transformations to be an entirely separate thing . I could see offering optional convenience functions for people that directly manipulate the pixel buffers, but that isn't in scope for this specific issue.

I'm going to implement these boxes now and surface/honor them in avifImage. I'm hoping to have this in today, and they'll be available in v0.6.0.

joedrago commented 4 years ago

@ledyba-z Thanks for those test images; they were very useful in verifying my plumbing.