Under the Hood: Preserving HDR Gain Maps, Display P3 & Spatial Entropy in On-Device HEVC
How Compresso achieves 85% video size reduction using Apple VideoToolbox hardware rate control, Laplacian texture guards, and 10-bit BT.2020 color retention.
For iPhone Pro users and mobile photographers, the biggest barrier to using a storage compressor isn’t speed — it is the fear of silent fidelity destruction.
Many naive compression utilities strip wide-gamut color profiles down to sRGB, flatten HDR highlights into muddy grey, or re-encode an already-compressed HEIC file until block artifacts appear. Here is how Compresso’s media pipeline prevents that.
1. Native Color Primaries & 10-Bit HDR Retention
iPhones since the iPhone 12 record HDR video in 10-bit HEVC with ITU-R BT.2020 (HLG / Dolby Vision) or Display P3 (P3_D65) color primaries.
When configuring AVAssetWriter for hardware-accelerated VideoToolbox encoding, Compresso inspects the source track’s CMFormatDescription and explicitly maps valid Apple color transfer functions and primaries (P3_D65, ITU_R_2020, ITU_R_709_2, SMPTE_C). This guarantees no washed-out skin tones or clipped highlights after compression.
2. Laplacian Spatial Entropy Guard
Not every file should be re-encoded. A photo saved from Telegram or an already-optimized HEIC shot may have very little redundancy left.
Before committing a compressed asset to PHPhotoLibrary, Compresso evaluates both the byte-reduction threshold and spatial detail preservation:
- If a target re-encode fails to reduce file size by a meaningful margin, the writer discards the temporary output and keeps your original byte-for-byte.
- For still images and Live Photo keyframes, high-frequency edge detail is preserved while chrominance redundancy is compacted inside the HEIC container.
3. Atomic Live Photo Reconstruction
A Live Photo in iOS is not a single file — it is a paired PHAsset consisting of a still image (PHAssetResourceType.photo) and a short motion movie (PHAssetResourceType.pairedVideo) linked by a shared contentIdentifier UUID in the maker-note metadata.
Most compressors convert Live Photos into flat still images, destroying the motion and audio. Compresso transcodes the paired .MOV track via hardware HEVC, optimizes the still frame, injects the matching kFigAppleMakerNote_AssetIdentifier, and commits both back as a genuine Live Photo reducing total footprint by ~75%.
4. Zero-Cloud Execution
Because every step runs directly on the Apple Silicon media engine (VTCompressionSession and CGImageDestination), Compresso requires zero server bandwidth, has zero cloud costs, and never exposes personal media to third-party networks.