Hey guys,
my goal is to develop a tool for Final Cut Pro that lets you preview—with the HDR Video display preset enabled—how the final image will look on an iPhone in Instagram and TikTok.
I’ve already managed to measure HDR RGB values on a Mac after image processing, including the effects of AMVE metadata. To achieve my goal, I now need a way to do the same on an iPhone.
Has anyone successfully done this on an iPhone? I’d appreciate any advice or pointers to relevant APIs.
Thanks and wishes from Germany,
Lucas Distler
Thanks for asking, and for explaining what the preview tool is for.
I don't know of an API that reports the pixel values an iPhone's display shows for another app's video. What iOS does offer is HDR tone mapping that your own app can apply to a frame and then read back.
TN3145: HDR video metadata describes where AMVE fits. It says "Playback using AVPlayer will provide optimal tone mapping on any Apple device," and that HDR-rendering apps "may check the parameters in the values in the ambient Viewing Environment atoms ('amve') and pick the correct ambient adaptation strategy for their usage cases." Your app can read that metadata from a sample buffer's format description with kCMFormatDescriptionExtension_AmbientViewingEnvironment. For HLG video your app renders with Metal, CAEDRMetadata has hlg(ambientViewingEnvironment:), in iOS 17 and later. It passes that metadata to the system tone mapper for a CAMetalLayer. The result appears on screen, not in a buffer your app can read.
For the tone mapping, these APIs render HDR content for a target headroom into a buffer you can read:
CIToneMapHeadroom, in iOS 18 and later, takes asourceHeadroomand atargetHeadroom. WWDC24 session 10177, Use HDR for dynamic image experiences in your app, shows it in a display pipeline.- In Core Graphics,
setEDRTargetHeadroom(_:), in iOS 18 and later, andcontentToneMappingInfo, in iOS 26 and later, do the same for aCGContext. Enhancing high dynamic range image rendering has an example. currentEDRHeadroomonUIScreengives you the target. Its header describes headroom as "the ratio of the luminance of the brightest white the display can currently produce to the luminance of SDR white."
Values from these APIs show what your own render produces at a given headroom. Another app's video player can apply its own processing, so what it shows can differ.
If you need the values an iPhone's display produces, please file an enhancement request using Feedback Assistant. Describe your preview tool and the measurements it needs. If you file the request, please post the Feedback number here so we can make sure it gets routed to the right team.
Please note that filing an enhancement request does not guarantee Apple will add any requested functionality to Apple products in the future. However, with that said, filing an enhancement request is a good way to get your ideas in front of the folks who make decisions about that sort of thing.