This library implements HDR and SDR conversion using MediaCodec and OpenGL In Android. If you find it helpful, please give it a star. Your support is my greatest motivation to move forward.
HDR and SDR conversion aims to address the following issues:
- Playback process: Not all phones support HDR screens, which can result in videos appearing gray. They need to be converted to SDR videos.
- Editing process: When mixing HDR and SDR content for editing, either HDR needs to be converted to SDR or SDR needs to be converted to HDR to avoid color differences.
I have collected articles related to HDR and summarized the journey of HDR to SDR conversion. I developed this library with the hope of helping everyone.
The current implemented features are as follows, for everyone to learn and progress together:
- Output Modes (Directly to Surface, or through OpenGL)
- View Modes (Seamless switching between SurfaceView and TextureView)
- Configuration for various texture sources (Auto, YUV420Buffer, external texture OES, Y2Y), and texture bit depth (8-bit, 10-bit, 16-bit)
- HDR to SDR CubeLut Configuration, including PQ to SDR (12 options), HLG to SDR (4 options)
- HDR to SDR Shader Configuration, this Shader supports chromatic correction, hue reference, hue mapping, color space conversion, gamma compression for both PQ and HLG videos.
- Tone mapping is supported for Android 8's Tonemap, Android 13's Tonemap, BT2446A, BT2446C, and Hable.
- Color space conversion is supported for BT2020 to BT709Clip, Compress, and adaptive_l0_cusp.
- Seamless switching between 10 test videos.
Planned Features
- SDR to HDR inverse tone mapping
- Integration with Exoplayer
- Recognizing dynamic metadata for HDR10+
All codes are annotated.
- Shader directory implements chromatic correction, hue reference, hue mapping, color space conversion, and gamma compression.
- YUV420FragmentShader and GLYUV420Renderer implement the conversion of four types of YUV420 buffers to textures using pure Shader.
- Java code reads CubeLut file, optimized from about 3 seconds to 70 milliseconds
- Directly load CubeLut data with 3D textures
- Rendering of 2D textures, OES textures, Y2Y textures
- Determine if MediaCodec supports 10-bit decoding
- Creating textures with different bit depths
- GLVideoOutputImpl
- Asynchronous decoding with MediaCodec
- OpenGL runtime environment encapsulation
- Journey of HDR to SDR Conversion (Part One) Process Summary
- Journey of HDR to SDR Conversion (Part Two) Decoding 10-bit YUV Textures
- Journey of HDR to SDR Conversion (Part Three) YUV420 to YUV Formula
- Journey of HDR to SDR Conversion (Part Four) YUV to RGB Matrix Derivation
- Journey of HDR to SDR Conversion (Part Five) Color Space Conversion BT2020 to BT709
- Journey of HDR to SDR Conversion (Part Six) Transfer Function and Chromatic Aberration Correction
- Journey of HDR to SDR Conversion (Part Seven) Gamma, HLG, PQ Formulas in Detail
- Journey of HDR to SDR Conversion (Part Eight) Tone Mapping
- Journey of HDR to SDR Conversion (Part Nine) Compilation of HDR Development Resources
- Journey of HDR to SDR Conversion (Part Ten) Exploration of SDR to HDR Inverse Tone Mapping
Stargazers | Forkers |
---|---|