Fanbase

heic/heic-box-sizes

version 1.0

Six concrete file layouts (plain, extended item, transform, legacy, sequence, size-extreme) exercising ISOBMFF's zero-size ("extends to EOF") and largesize box-size conventions alongside boundary offset/length values

Format
High Efficiency Image File Format (heic)
Authors
The Fandango Fuzzer Team
License
Apache-2.0
Fandango
>=1.3
Extensions
heic
Media type
image/heic
Specification
https://www.iso.org/standard/89035.html
Its files should decode
never
In the registry
specs/heic/heic-box-sizes/heic-box-sizes.fan

Use it

fanbase install heic-box-sizes
fandango fuzz -F heic-box-sizes -n 10

How it does

accepts 0%, covers 2.8%, 101/s. 1000 inputs, seed 1.

ParserAcceptsVersion
ffmpeg0%ffmpeg version 7.1.5-0+deb13u1
imagemagick0%Version: ImageMagick 7.1.1-43 Q16 x86_64 22550
libheif-cov0%libheif 1.23.6
pillow0%12.3.0

The spec says its files decode never: as expected.

libheif-cov

lines reached
2.8% of 22119
real files reach
18.9%
only the generated files
78 lines
only the real files
3647 lines
1.5% after 1 inputs, 2.8% after 1000real files: 18.9%

Cite it

@software{fanbase_heic_heic_box_sizes_1_0,
  author  = {{The Fandango Fuzzer Team}},
  title   = {High Efficiency Image File Format (heic/heic-box-sizes), a Fandango input specification},
  version = {1.0},
  url     = {https://github.com/fandango-fuzzer/fanbase},
  note    = {Fanbase registry, specs/heic/heic-box-sizes/heic-box-sizes.fan, sha256 80250c4719fc},
}

Source

Source (155 lines)
# Bounded ISO/IEC 23008-12 HEIF grammar specialized for HEVC-coded HEIC. Box
# sizes are fixed literals in each alternative rather than computed, so every
# layout's length fields are correct by construction.

<start> ::= <heic_file>
<heic_file> ::= <base_file> | <extended_item_file> | <transform_file> | <legacy_file> | <sequence_file> | <size_extreme_file>

<base_file> ::= <ftyp_heic> <meta_base> <mdat_hevc>
<extended_item_file> ::= <ftyp_extended> <free8> <meta_extended> <mdat_grid> <uuid24>
<transform_file> ::= <ftyp_heix> <meta_transforms> <mdat_overlay> <skip8>
<legacy_file> ::= <ftyp_legacy> <wide8> <meta_legacy> <mdat_hevc>
<sequence_file> ::= <ftyp_sequence> <meta_base> <moov_sequence> <mdat_hevc>
<size_extreme_file> ::= <ftyp_heic> <large_free16> <meta_base> <mdat_to_eof>

# FileTypeBox: still-image, sequence, range-extension and legacy compatibility.
<ftyp_heic> ::= "\x00\x00\x00\x18ftypheic\x00\x00\x00\x00mif1heic"
<ftyp_heix> ::= "\x00\x00\x00\x1cftypheix\x00\x00\x00\x00mif1heixhevc"
<ftyp_extended> ::= "\x00\x00\x00\x20ftyphevc\x00\x00\x02\x00mif1hevcmsf1iso8"
<ftyp_legacy> ::= "\x00\x00\x00\x1cftypmif1\x00\x00\x00\x00heicmiafhevc"
<ftyp_sequence> ::= "\x00\x00\x00\x1cftypmsf1\x00\x00\x00\x00mif1hevcmsf1"

<free8> ::= "\x00\x00\x00\x08free"
<skip8> ::= "\x00\x00\x00\x08skip"
<wide8> ::= "\x00\x00\x00\x08wide"
<uuid24> ::= "\x00\x00\x00\x18uuid0123456789abcdef"
<large_free16> ::= "\x00\x00\x00\x01free\x00\x00\x00\x00\x00\x00\x00\x10"

# Four complete MetaBox layouts. All have FullBox version 0 and exact sizes.
<meta_base> ::= "\x00\x00\x00\xe4meta\x00\x00\x00\x00" <hdlr33> <pitm14> <iloc30> <iinf35> <iprp104>
<meta_extended> ::= "\x00\x00\x01\x7ameta\x00\x00\x00\x00" <hdlr33> <pitm14> <iloc30> <iinf35> <iprp211> <iref26> <idat17>
<meta_transforms> ::= "\x00\x00\x01\x2fmeta\x00\x00\x00\x00" <hdlr33> <pitm14> <iloc30> <iinf35> <iprp179>
<meta_legacy> ::= "\x00\x00\x01\x99meta\x00\x00\x00\x00" <hdlr33> <pitm14> <iloc30> <iinf35> <iprp104> <xml19> <grpl32> <ipro94> <dinf36>

<hdlr33> ::= "\x00\x00\x00\x21hdlr\x00\x00\x00\x00\x00\x00\x00\x00pict\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
<pitm14> ::= "\x00\x00\x00\x0epitm\x00\x00\x00\x00\x00\x01"

# ItemLocationBox v0, one item, 32-bit offset and extent length. The selectable
# fields cover zero, first-byte, 31-bit boundary and all-ones boundary values.
<iloc30> ::= "\x00\x00\x00\x1eiloc\x00\x00\x00\x00\x44\x00\x00\x01\x00\x01\x00\x00\x00\x01" <extent_offset> <extent_length>
<extent_offset> ::= "\x00\x00\x00\x00" | "\x00\x00\x00\x01" | "\x7f\xff\xff\xff" | "\xff\xff\xff\xff"
<extent_length> ::= "\x00\x00\x00\x00" | "\x00\x00\x00\x05" | "\x00\x00\x00\x0c" | "\xff\xff\xff\xff"

# ItemInfoBox with modern infe v2. Item identifiers match pitm/ipma/iloc.
<iinf35> ::= "\x00\x00\x00\x23iinf\x00\x00\x00\x00\x00\x01" <infe21>
<infe21> ::= "\x00\x00\x00\x15infe\x02\x00\x00\x00\x00\x01\x00\x00" <item_type> "\x00"
<item_type> ::= "hvc1" | "grid" | "iovl" | "Exif" | "mime" | "uri "

# Base ItemPropertiesBox: ispe + hvcC + pixi, associated as essential.
<iprp104> ::= "\x00\x00\x00\x68iprp" <ipco74> <ipma22>
<ipco74> ::= "\x00\x00\x00\x4aipco" <ispe20> <hvcc32> <pixi14>
<ipma22> ::= "\x00\x00\x00\x16ipma\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x03\x81\x82\x83"

<ispe20> ::= "\x00\x00\x00\x14ispe\x00\x00\x00\x00" <dimension> <dimension>
<dimension> ::= "\x00\x00\x00\x01" | "\x00\x00\x00\x10" | "\x00\x00\x01\x00" | "\x00\x00\x04\x00" | "\x00\x00\x20\x00" | "\x00\x01\x00\x00"

# HEVCDecoderConfigurationRecord with zero arrays (valid out-of-band parameter
# set count), unusual profiles, chroma formats, bit depths and level boundaries.
<hvcc32> ::= "\x00\x00\x00\x20hvcC\x01" <profile_byte> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" <level_byte> "\xf0\x00\xfc\xfc" <chroma_byte> <depth_byte> <depth_byte> "\x00\x00\x0f\x00"
<profile_byte> ::= "\x01" | "\x02" | "\x03" | "\x04" | "\x05" | "\x1f"
<level_byte> ::= "\x1e" | "\x3c" | "\x5a" | "\x78" | "\x99"
<chroma_byte> ::= "\xfc" | "\xfd" | "\xfe" | "\xff"
<depth_byte> ::= "\xf8" | "\xfa" | "\xfc"

<pixi14> ::= "\x00\x00\x00\x0epixi\x00\x00\x00\x00\x01" <single_depth>
<single_depth> ::= "\x01" | "\x08" | "\x0a" | "\x0c" | "\x10"

# Extended property container includes colour, clean aperture, rotation and an
# auxiliary-image type. Its ipma still points to the first three core properties.
<iprp211> ::= "\x00\x00\x00\xd3iprp" <ipco181> <ipma22>
<ipco181> ::= "\x00\x00\x00\xb5ipco" <ispe20> <hvcc32> <pixi14> <colr19> <clap40> <irot9> <auxc39>
<colr19> ::= "\x00\x00\x00\x13colrnclx" <colour_primaries> <transfer_characteristics> <matrix_coefficients> <full_range>
<colour_primaries> ::= "\x00\x01" | "\x00\x09" | "\x00\x0c" | "\x00\x16"
<transfer_characteristics> ::= "\x00\x01" | "\x00\x0d" | "\x00\x10" | "\x00\x12"
<matrix_coefficients> ::= "\x00\x00" | "\x00\x01" | "\x00\x09" | "\x00\x0e"
<full_range> ::= "\x00" | "\x80"
<clap40> ::= "\x00\x00\x00\x28clap" <fraction>{4}
<fraction> ::= "\x00\x00\x00\x00\x00\x00\x00\x01" | "\x00\x00\x00\x01\x00\x00\x00\x01" | "\x00\x00\x04\x00\x00\x00\x00\x01"
<irot9> ::= "\x00\x00\x00\x09irot" <rotation>
<rotation> ::= "\x00" | "\x01" | "\x02" | "\x03"
<auxc39> ::= "\x00\x00\x00\x27auxC\x00\x00\x00\x00urn:mpeg:hevc:2015:auxid:1\x00"

# Transform/property edge cases: pasp, mirror, relative location, layer
# selection and AV1-layered-image indexing retained as HEIF property boxes.
<iprp179> ::= "\x00\x00\x00\xb3iprp" <ipco149> <ipma22>
<ipco149> ::= "\x00\x00\x00\x95ipco" <ispe20> <hvcc32> <pixi14> <pasp16> <imir9> <rloc16> <lsel13> <a1lx21>
<pasp16> ::= "\x00\x00\x00\x10pasp" <ratio> <ratio>
<ratio> ::= "\x00\x00\x00\x01" | "\x00\x00\x00\x02" | "\x00\x00\xff\xff"
<imir9> ::= "\x00\x00\x00\x09imir" <axis>
<axis> ::= "\x00" | "\x01"
<rloc16> ::= "\x00\x00\x00\x10rloc\x00\x00\x00\x00" <dimension>
<lsel13> ::= "\x00\x00\x00\x0dlsel\x00\x00\x00\x00\x00"
<a1lx21> ::= "\x00\x00\x00\x15a1lx\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00"

# ItemReferenceBox v0: dimg/thmb/auxl/cdsc/prem reference item 1 to item 1.
<iref26> ::= "\x00\x00\x00\x1airef\x00\x00\x00\x00\x00\x00\x00\x0e" <ref_type> "\x00\x01\x00\x01\x00\x01"
<ref_type> ::= "dimg" | "thmb" | "auxl" | "cdsc" | "prem"
<idat17> ::= "\x00\x00\x00\x11idat\x00\x00\x00\x05\x26\x01\xaf\x09\x40"

# XML, entity grouping, item protection and data-reference legacy facilities.
<xml19> ::= "\x00\x00\x00\x13xml \x00\x00\x00\x00<heif/>"
<grpl32> ::= "\x00\x00\x00\x20grpl" <altr24>
<altr24> ::= "\x00\x00\x00\x18altr\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01"
<ipro94> ::= "\x00\x00\x00\x5eipro\x00\x00\x00\x00\x00\x01" <sinf80>
<sinf80> ::= "\x00\x00\x00\x50sinf" <frma12> <schm20> <schi40>
<frma12> ::= "\x00\x00\x00\x0cfrmahvc1"
<schm20> ::= "\x00\x00\x00\x14schm\x00\x00\x00\x00cenc\x00\x01\x00\x00"
<schi40> ::= "\x00\x00\x00\x28schi" <tenc32>
<tenc32> ::= "\x00\x00\x00\x20tenc\x00\x00\x00\x00\x00\x01\x08\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
<dinf36> ::= "\x00\x00\x00\x24dinf" <dref28>
<dref28> ::= "\x00\x00\x00\x1cdref\x00\x00\x00\x00\x00\x00\x00\x01" <url12>
<url12> ::= "\x00\x00\x00\x0curl \x00\x00\x00\x01"

# MediaDataBox: HEVC length-prefixed sample, grid derived item, overlay item,
# plus the BMFF size==0 boundary (must remain the final top-level box).
<mdat_hevc> ::= "\x00\x00\x00\x11mdat\x00\x00\x00\x05" <slice_nal5>
<slice_nal5> ::= "\x26\x01\xaf\x09\x40" | "\x28\x01\x80\x00\x01" | "\x02\x01\xd0\x11\x22"
<mdat_grid> ::= "\x00\x00\x00\x13mdat\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01\x00"
<mdat_overlay> ::= "\x00\x00\x00\x14mdat\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01"
<mdat_to_eof> ::= "\x00\x00\x00\x00mdat" <eof_payload>
<eof_payload> ::= <octet>{1,32}
<octet> ::= "\x00" | "\x01" | "\x7f" | "A" | "\xff"

# Bounded image-sequence hierarchy: moov/trak/mdia/minf/stbl with HEVC sample
# entry, 32/64-bit chunk offsets, timing, sync sample, tref and mvex/trex.
<moov_sequence> ::= "\x00\x00\x02\x9cmoov" <mvhd108> <trak512> <mvex40>
<mvhd108> ::= "\x00\x00\x00\x6cmvhd\x00\x00\x00\x00" <zero8> "\x00\x00\x03\xe8\x00\x00\x03\xe8" <mvhd_tail80>
<zero8> ::= "\x00\x00\x00\x00\x00\x00\x00\x00"
<mvhd_tail80> ::= "\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"
<trak512> ::= "\x00\x00\x02\x00trak" <tkhd92> <mdia412>
<tkhd92> ::= "\x00\x00\x00\x5ctkhd\x00\x00\x00\x07" <zero8> "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\xe8" <zero16> <matrix36> <fixed_dimension> <fixed_dimension>
<zero16> ::= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
<matrix36> ::= "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00"
<fixed_dimension> ::= "\x01\x00\x00\x00" | "\x04\x00\x00\x00" | "\x20\x00\x00\x00"
<mdia412> ::= "\x00\x00\x01\x9cmdia" <mdhd32> <media_hdlr50> <minf322>
<mdhd32> ::= "\x00\x00\x00\x20mdhd\x00\x00\x00\x00" <zero8> "\x00\x00\x03\xe8\x00\x00\x03\xe8" <language> "\x00\x00"
<language> ::= "\x55\xc4" | "\x15\xc7" | "\x00\x00"
<media_hdlr50> ::= "\x00\x00\x00\x32hdlr\x00\x00\x00\x00\x00\x00\x00\x00pict" <zero16> "ImageSequence\x00"
<minf322> ::= "\x00\x00\x01\x42minf" <vmhd20> <dinf36> <stbl258>
<vmhd20> ::= "\x00\x00\x00\x14vmhd\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
<stbl258> ::= "\x00\x00\x01\x02stbl" <stsd134> <stts24> <stsc28> <stsz24> <chunk_offset> <stss20>
<stsd134> ::= "\x00\x00\x00\x86stsd\x00\x00\x00\x00\x00\x00\x00\x01" <hvc1_118>
<hvc1_118> ::= "\x00\x00\x00\x76hvc1" <visual_fields78> <hvcc32>
<visual_fields78> ::= <zero8> <zero16> <sample_dimension> <sample_dimension> "\x00\x48\x00\x00\x00\x48\x00\x00\x00\x00\x00\x00\x00\x01" <compressor32> "\x00\x18\xff\xff"
<sample_dimension> ::= "\x00\x01" | "\x01\x00" | "\x04\x00" | "\x20\x00"
<compressor32> ::= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
<stts24> ::= "\x00\x00\x00\x18stts\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x03\xe8"
<stsc28> ::= "\x00\x00\x00\x1cstsc\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01"
<stsz24> ::= "\x00\x00\x00\x18stsz\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x05"
<chunk_offset> ::= "\x00\x00\x00\x14stco\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
<stss20> ::= "\x00\x00\x00\x14stss\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01"
<mvex40> ::= "\x00\x00\x00\x28mvex" <trex32>
<trex32> ::= "\x00\x00\x00\x20trex\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x03\xe8\x00\x00\x00\x05\x00\x01\x00\x00"

# Cross-field sizes and fixed-width enums are paired structurally in the
# productions above; the sole variable payload is bounded directly by {1,32}.