How AVIF imir Box Indicates Image Flipping
The AVIF image format uses transformative item properties inherited
from the High Efficiency Image File Format (HEIF) and the ISO Base Media
File Format (ISOBMFF) to alter image presentation without re-encoding
the underlying bitstream. Among these properties, the Image Mirroring
box (imir) is responsible for indicating horizontal and
vertical image flipping. By storing a single flag value inside the
file's metadata container, the imir box instructs decoders
to invert the decoded pixel grid along a specified axis before
rendering.
The Structure of the
imir Box
The imir box is an item property stored within the
file's metadata (meta) container, specifically inside the
Item Properties Box (iprp). It is classified as an
essential or non-essential transformative property associated with
specific image items via the Item Property Association
(ipma) box.
The payload of the imir box consists of a single byte
containing an 8-bit layout defined as follows:
- Reserved bits (7 bits): The first seven bits are
reserved and must be set to
0. - Mode bit (1 bit): The final, least significant bit specifies the axis of reflection.
How the
mode Field Dictates Orientation
The mode field defines the reflection axis for the
mirror operation:
- Mode
0(Horizontal Flip): Signals reflection about a vertical axis. This operation swaps the left and right sides of the image while maintaining the original vertical order (top remains top, bottom remains bottom). - Mode
1(Vertical Flip): Signals reflection about a horizontal axis. This operation swaps the top and bottom sides of the image while maintaining the horizontal order (left remains left, right remains right).
Application Order and Non-Destructive Transformations
AVIF decoders apply transformations non-destructively. When an image
contains both rotation (irot) and mirroring
(imir) boxes, the transformation order depends strictly on
their sequence in the associated ipma box:
- The raw AV1 bitstream is decoded into pixel memory.
- The decoder inspects the sequence of transformative properties mapped to that item ID.
- The transformations are executed in the exact order listed. Applying
an
irotbox before animirbox yields a different visual result than applying theimirbox first.
By interpreting the imir box's single-bit
mode, compliant decoders can render mirrored AVIF assets
efficiently without modifying the encoded AV1 video frames.