Skip to content

Latest commit

 

History

History
72 lines (52 loc) · 5.5 KB

README-EN.md

File metadata and controls

72 lines (52 loc) · 5.5 KB

HDRSample

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:

  1. Playback process: Not all phones support HDR screens, which can result in videos appearing gray. They need to be converted to SDR videos.
  2. 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.

image

The current implemented features are as follows, for everyone to learn and progress together:

  1. Output Modes (Directly to Surface, or through OpenGL)
  2. View Modes (Seamless switching between SurfaceView and TextureView)
  3. Configuration for various texture sources (Auto, YUV420Buffer, external texture OES, Y2Y), and texture bit depth (8-bit, 10-bit, 16-bit)
  4. HDR to SDR CubeLut Configuration, including PQ to SDR (12 options), HLG to SDR (4 options)
  5. 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.
  6. Tone mapping is supported for Android 8's Tonemap, Android 13's Tonemap, BT2446A, BT2446C, and Hable.
  7. Color space conversion is supported for BT2020 to BT709Clip, Compress, and adaptive_l0_cusp.
  8. Seamless switching between 10 test videos.

Planned Features

  • SDR to HDR inverse tone mapping
  • Integration with Exoplayer
  • Recognizing dynamic metadata for HDR10+

Preview

APK Download Link

HDR to SDR

Key Code

All codes are annotated.

  1. Shader directory implements chromatic correction, hue reference, hue mapping, color space conversion, and gamma compression.
  2. YUV420FragmentShader and GLYUV420Renderer implement the conversion of four types of YUV420 buffers to textures using pure Shader.
  3. Java code reads CubeLut file, optimized from about 3 seconds to 70 milliseconds
  4. Directly load CubeLut data with 3D textures
  5. Rendering of 2D textures, OES textures, Y2Y textures
  6. Determine if MediaCodec supports 10-bit decoding
  7. Creating textures with different bit depths
  8. GLVideoOutputImpl
  9. Asynchronous decoding with MediaCodec
  10. OpenGL runtime environment encapsulation

Practical Summary

⭐ Star History

Star History Chart

Special Thanks

Stargazers Forkers
Stargazers repo roster for @JonaNorman/HDRSample Forkers repo roster for @JonaNorman/HDRSample