Skip to content

Fix ImHex pattern tile_size_in_fh truncation and extend tile/AUI/gainmap parsing - #285

Merged
cpncf merged 1 commit into
mainfrom
improve_imhex_pattern
Sep 23, 2026
Merged

cpncf merged 1 commit into
mainfrom
improve_imhex_pattern

Conversation

@kpchoi

@kpchoi kpchoi commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Updates util/apv.hexpat.

Bug fixes:

  • tile_size_in_fh : 32 * NumTiles is truncated to 8 bits by the pattern
    engine whenever 32 * NumTiles >= 256, desynchronizing the whole pattern for
    streams with tile_size_present_in_fh_flag = 1 and NumTiles >= 8. It is now
    an array of 32-bit bitfield members.
  • The MSB of the frame_info trailing byte is decoded as use_companding
    (444-16C12 / 4444-16C12, see readme/apv_ext.md) instead of showing
    reserved_zero_8bits = 128, with a warning when set for other profiles.
  • Metadata PBUs consume the trailing filler() bytes so subsequent PBUs stay in
    sync, and payload structs consume any unread remainder.
  • Guards for undersized metadata payloads (T.35, MDCV, CLL, user-defined),
    malformed pbu_size and tile sizes; invalid tile_info skips the frame data
    with a warning instead of forcing a parse.
  • The verbose AU log line now shows the real AU index.

New parsing:

  • Frame tiles: per-tile tile_size, tile_header() fields (tile_index,
    tile_data_size[], tile_qp[]) and a sealed tile data blob.
  • au_info() (pbu_type 65): num_frames and per-frame pbu_type, group_id,
    frame_info().
  • Metadata payload types 20 (ICC profile) and 21 (gainmap), and the gainmap
    frame PBU (pbu_type 28) from the APV gainmap/ICC specification draft.
  • profile_idc / chroma_format_idc / pbu_type are shown as enums.

Console output:

  • A start line and a summary (AU/PBU/frame/metadata counts, distinct frame
    configurations, metadata payload types).
  • Frame info changes are reported with the changed fields at the AU/frame
    position, keyed by (pbu_type, group_id) so coexisting frames such as
    previews are not reported as changes.
  • Detailed per-PBU output is available by setting verbose = true at the top
    of the pattern.

…sing to ImHex pattern

Signed-off-by: KP Choi <19379257+kpchoi@users.noreply.github.com>

@cpncf cpncf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cpncf
cpncf merged commit c420153 into main Sep 23, 2026
10 checks passed
@cpncf
cpncf deleted the improve_imhex_pattern branch September 23, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants