# High Dynamic Range Editing
Table of Contents
- [High Dynamic Range Editing](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#high-dynamic-range-editing)
- [Editing Applications](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#editing-applications)
- [Applications developed using MediaCodec](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#applications-developed-using-mediacodec)
- [Applications developed with Media Transformer support library](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#applications-developed-with-media-transformer-support-library)
- [HDR editing workflows](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-editing-workflows)
- [HDR-HDR editing](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-hdr-editing)
- [Android API Support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#android-api-support)
- [Advanced HDR-HDR Editing Applications with RGBA FP16 Linear Surfaces](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#advanced-hdr-hdr-editing-applications-with-rgba-fp16-linear-surfaces)
- [Android API support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id1)
- [HDR-SDR Editing](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-sdr-editing)
- [Android API support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id3)
- [Application-generated HDR metadata (CUVA/HDR Vivid)](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#application-generated-hdr-metadata-cuva-hdr-vivid)
- [Android API Support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id5)
Encoders can expose HDR editing using the new feature flag [FEATURE_HdrEditing](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#FEATURE_HdrEditing).
This encoder (hereinafter referred to as hdr-capable-encoder), must support:
>
>
> - Encoding RGBA1010102 format (COLOR\_Format32bitABGR2101010)
> - (Optional) Encoding RGBA FP16 format (COLOR\_Format64bitABGRFloat)
> - Generating HDR10 static metadata if the profile is set to HEVCMain10HDR10 profile and there is no metadata set by the client (app) or generated by the camera.
> - Generating HDR10+ dynamic metadata if the profile is set to HEVCMain10HDR10+ profile and there is no metadata set by the client (app) or generated by the camera.
## [Editing Applications](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id9)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#editing-applications)
### [Applications developed using MediaCodec](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id10)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#applications-developed-using-mediacodec)
A typical editor application’s pipeline involves decoding the video, applying transformations with OpenGL (scale, rotate, effects), and re-encoding with a different codec and parameters.
You can build this application using MediaExtractor, MediaCodec, and MediaMuxer.

Single track editor application[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id6)
### [Applications developed with Media Transformer support library](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id11)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#applications-developed-with-media-transformer-support-library)
To simplify the editor application development, Google provides a [Media Transformer support library](https://developer.android.com/reference/androidx/media3/transformer/package-summary)
(similar to Exoplayer for developing player applications).
Applications can develop their editors with fewer lines of code and focus on developing creative filters/lenses. An application developed on top of a support library looks something like the following:

Single track editor application developed using media3 transformer support library[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id7)
## [HDR editing workflows](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id12)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-editing-workflows)
On Snapdragon, we have implemented the HDR editing capabilities in our HEVC encoder to offer the best in class performace and quality.
Applications are enabled to develop the following HDR editing workflows:
### [HDR-HDR editing](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id13)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-hdr-editing)
- Applications can edit an HDR video and save the transformed video in HDR format:
- 1. HDR asset is decoded.
2. Transformations are applied in HDR space.
3. Transformed image is re-encoded in HDR mode.
This process appears identical to HDR recording, but there are some nuanced differences from the encoder:
>
>
> - Encoder input are post-GPU textures, so the color format will be RGBA1010102. This puts an implicit requirement on the encoder to support RGBA1010102 buffers
> - There is no HDR10+ dynamic metadata associated with the image buffers because the image was manipulated and the GPU drops all metadata during transformation.
> This requires the encoder to generate HDR10 (static) and HDR10+ (dynamic) metadata after frame analysis.
> - Applications may queue P010 via ImageWriter interface. However, this is not a popular use case. This option requires Android P010 format support for the encoder
> and HDR10(+) metadata generation based on the configured profile.
#### [Android API Support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id14)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#android-api-support)
| API | Usage |
| --- | --- |
| [CodecCapabilities#FEATURE_HdrEditing](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#FEATURE_HdrEditing) | This feature string is introduced in Android T for the applications to query if the encoder supports HDR editing.
Devices can enlist separate encoders for this purpose. Applications are required to enumerate all HDR capable codec entries and pick the encoder that advertises this feature. |
| [COLOR_Format32bitABGR2101010](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#COLOR_Format32bitABGR2101010) | Enumeration for RGBA1010102 format (32-bit RGB with 10-bit R/G/B channels). |
| [COLOR_FormatYUVP010](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#COLOR_FormatYUVP010) | Enumeration of P010 format which contains 10-bit per component YUV 4:2:0. |
### [Advanced HDR-HDR Editing Applications with RGBA FP16 Linear Surfaces](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id15)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#advanced-hdr-hdr-editing-applications-with-rgba-fp16-linear-surfaces)
Applications that allow users to mix multiple video tracks or overlay images onto video (typically known as multi-asset editing) prefer to use a higher
bit-depth container with a common dataspace.
[RGBA_FP16](https://developer.android.com/reference/android/graphics/PixelFormat#RGBA_F16) is a 64-bit per-pixel format (16-bit half precision float per channel).
The Android Media equivalent of this pixel format is [COLOR_Format64bitABGRFloat](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#COLOR_Format64bitABGRFloat).
This format allows storing values without a non-linear transfer-function (aka linear), which would overflow beyond the normalized -1.0 and 1.0 range.
This workflow is similar to the HDR-HDR Editing workflow above. However, the application configures the EGL texture to render FP16 linear output.
This requires the encoder to accept RGBA-FP16 input. It is also required to generate HDR10 (static) and HDR10+ (dynamic) metadata in this use case.
#### [Android API support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id16)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id1)
| API | Usage |
| --- | --- |
| [COLOR_Format64bitABGRFloat](https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities#COLOR_Format64bitABGRFloat) | A 64-bit per-pixel RGBA format that contains 16-bit (half-precision) floats for R, G, B, and Alpha components. This format is defined, but not configured by applications explicitly by the encoder’s configuration. However, it will be detected by hardware encoder based on the incoming buffer dataspace. |
### [HDR-SDR Editing](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id17)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#hdr-sdr-editing)
When sharing videos from an HDR capable device, applications cannot assume that all devices in the ecosystem support HDR playback.
For example, HEVC HDR10 content may not be supported on an older Android, due to the lack of HEVC codec or HDR display support.
In this case, it is imperative to transcode videos from HDR format to a compatible format such as AVC 8-bit.
The process of converting a 10-bit HDR video to 8-bit is not trivial. Downsampling the 10-bit luma/chroma components will result in clipping and bad output.
This requires a pixel-to-pixel translation from the HDR colorspace to SDR space, i.e., tone-mapping.
Applications can request the decoders to decode an HDR video and produce 8-bit tone-mapped output rather than HDR. The resulting output can be re-encoded using a compatible 8-bit codec and profile.
#### [Android API support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id18)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id3)
| API | Usage |
| --- | --- |
| [MediaFormat#KEY_COLOR_TRANSFER_REQUEST](https://developer.android.com/reference/android/media/MediaFormat#KEY_COLOR_TRANSFER_REQUEST) | Applications can use this key to request the decoders to produce vide output in a certain OETF (Transfer Function).
This is only supported for decoder output.
The only supported value is [COLOR_TRANSFER_SDR_VIDEO](https://developer.android.com/reference/android/media/MediaFormat#COLOR_TRANSFER_SDR_VIDEO). |
| [COLOR_TRANSFER_SDR_VIDEO](https://developer.android.com/reference/android/media/MediaFormat#COLOR_TRANSFER_SDR_VIDEO) | Enumeration to indicate SDR Transfer (BT709). |
Please refer [HDR to SDR decode sample application](https://github.com/quic/android-on-snapdragon/blob/master/video/sample-apps/app/src/main/java/com/example/VideoSampleApp/SdrDecode.java)
### [Application-generated HDR metadata (CUVA/HDR Vivid)](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id19)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#application-generated-hdr-metadata-cuva-hdr-vivid)
Some applications may generate HDR metadata, such as CUVA HDR, and pass the metadata along with the image buffer. In this case, the HDR-capable encoder shall
skip metadata generation and use the application specified metadata to embed in the bitstream.
- note:
- Applications that intend to do this must use [MediaCodec.QueueRequest](https://developer.android.com/reference/android/media/MediaCodec.QueueRequest)
to bundle the metadata along with the corresponding frame and queue to the MediaCodec.
Sending metadata via [MediaCodec.setParameter()](https://developer.android.com/reference/android/media/MediaCodec#setParameters%28android.os.Bundle%29) will result in
synchronization issues that lead to an incorrect correlation of metadata with the frames.
#### [Android API Support](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id20)[](https://docs.qualcomm.com/doc/80-56386-10/topic/hdr_editing.html#id5)
| API | Usage |
| --- | --- |
| [KEY_HDR_STATIC_INFO](https://developer.android.com/reference/android/media/MediaFormat#KEY_HDR_STATIC_INFO) | Applications can use this key to set HDR static information at configuration. |
| [KEY_HDR10_PLUS_INFO](https://developer.android.com/reference/android/media/MediaFormat#KEY_HDR10_PLUS_INFO) | Applications can use this key to set HDR static information per-frame. |
Last Published: Jun 13, 2023
[Previous Topic
High Dynamic Range Playback](https://docs.qualcomm.com/bundle/publicresource/80-56386-10/topics/hdr_playback.md)