Skip to content

Add HEIF (HEIC) and AVIF Ultra HDR multi-format container support (v2.0.0) - #413

Open
DichenZhang1 wants to merge 6 commits into
mainfrom
v2.0.0-heif-support-staging
Open

Add HEIF (HEIC) and AVIF Ultra HDR multi-format container support (v2.0.0)#413
DichenZhang1 wants to merge 6 commits into
mainfrom
v2.0.0-heif-support-staging

Conversation

@DichenZhang1

Copy link
Copy Markdown
Collaborator

Overview

This pull request introduces multi-format container support for Ultra HDR v2.0.0, extending libultrahdr beyond JPEG to support HEIF/HEIC (.heic) and AVIF (.avif) images with ISO 21496-1 gain map metadata and color profile preservation.


Key Architectural Changes

  1. Modular UltraHdr Base Class Hierarchy:

    • Refactored the monolithic JpegR implementation by extracting core gain map algorithms into a shared UltraHdr base class (ultrahdrcommon.h).
    • Added specialized derived classes:
      • JpegR (jpegr.h / jpegr.cpp): JPEG Multi-Picture Format (MPF), EXIF, and XMP encapsulation.
      • HeifUltraHdr (heifultrahdr.h / heifultrahdr.cpp): HEVC bitstream encoding/decoding via libheif with ISO 21496-1 tmap tone-mapping item references.
      • AvifUltraHdr (avifultrahdr.h / avifultrahdr.cpp): AV1 bitstream encoding/decoding via libheif with ISO 21496-1 tmap item references.
  2. C-API Multi-Format Extensions:

    • Activated UHDR_CODEC_HEIF and UHDR_CODEC_AVIF in uhdr_enc_set_output_format().
    • Enhanced uhdr_dec_probe() with automatic container sniffing (ISO BMFF ftyp vs JPEG SOI markers) and metadata extraction.
    • Transparently dispatched uhdr_decode() across JPEG, HEIF, and AVIF streams.
  3. Color Space & Gain Map Conversion Robustness:

    • Extracted NCLX container properties directly from image handles with fallbacks to standard color spaces.
    • Added RGBA-to-monochrome gain map pixel conversion in copy_raw_image() for decoders producing RGB/RGBA chroma formats.
  4. Testing, Portability & Documentation:

    • Added comprehensive end-to-end unit test suite in tests/ultrahdr_api_test.cpp covering all API entry points.
    • Cross-platform CMake configuration supporting standalone builds on Linux, macOS (Intel & Apple Silicon), and Windows.
    • Documented all architectural changes in docs/api_changes_v1.5_to_v2.0.md.
    • Added scheduled daily regression matrix workflow (.github/workflows/daily-regression.yml), issue deduplication reporter (scripts/report_regression_issue.py), and automated triage candidate fixer (scripts/auto_repair.py).

- Refactor UltraHDR class hierarchy:
  * UltraHdr: Common base class for gain map generation, tone mapping math, and metadata handling.
  * JpegR: Subclass implementing encodeJpegR and decodeJpegR for JPEG containers.
  * HeifUltraHdr: Subclass implementing encodeHeicUltraHdr and decodeHeicUltraHdr via libheif.
  * AvifUltraHdr: Subclass implementing encodeAvifUltraHdr and decodeAvifUltraHdr via libheif.
- Extend ultrahdr_api.h/cpp with multi-format container support for UHDR_CODEC_HEIF and UHDR_CODEC_AVIF.
- Add transparent format-agnostic probing and decoding for JPEG, HEIF, and AVIF streams.
- Update Android.bp and CMakeLists.txt with UHDR_ENABLE_HEIF option and libheif dependency.
- Add container sniffing and metadata probing for HEIC and AVIF in uhdr_dec_probe()
- Route HEIC and AVIF decode requests in uhdr_decode() to HeifUltraHdr / AvifUltraHdr
- Robust NCLX profile and gainmap decode fallback in HeifUltraHdr and AvifUltraHdr
- Add format conversion from 32bpp RGBA8888 to 8bpp YCbCr400 in copy_raw_image()
- Add comprehensive API tests in ultrahdr_api_test.cpp
…aft repair pipeline

- Add .github/workflows/daily-regression.yml for scheduled 02:00 UTC matrix CI
- Add scripts/report_regression_issue.py for fingerprint deduplication and bug filing
- Add scripts/auto_repair.py for candidate fix verification and draft PR creation
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.

1 participant