How can I load HDR(HLG) pixelbuffer to texture?(OpenGLES, Metal)

Hello I am Daeun Sim, working on graphics.

I took the video with 12 Pro and loaded pixelbuffer from video output as a Metal or OpenGL texture. However, it looks brighter than what I saw in the camera roll.
It seems to me that the CVMetalTextureCacheCreateTextureFromImage or CVOpenGLTextureCacheCreateTextureFromImage is not considering the CVImageBufferTransferFunction in pixelbuffer description inside.

My pixel buffer has the following description.
How can i handle HLG images? I think I need a color conversion process(like sRGB image), but I can't figure out the expression.

Code Block
<CVPixelBuffer 0x2827606e0 width=1920 height=1080 bytesPerRow=7680 pixelFormat=BGRA iosurface=0x281460f20 poolName=2922:decode_1 attributes={
PixelFormatDescription = {
BitsPerBlock = 32;
BitsPerComponent = 8;
BlackBlock = {length = 4, bytes = 0x000000ff};
CGBitmapContextCompatibility = 1;
CGBitmapInfo = 8196;
CGImageCompatibility = 1;
ComponentRange = FullRange;
ContainsAlpha = 1;
ContainsGrayscale = 0;
ContainsRGB = 1;
ContainsYCbCr = 0;
FillExtendedPixelsCallback = {length = 24, bytes = 0x0000000000000000ac7430b3010000000000000000000000};
IOSurfaceCoreAnimationCompatibility = 1;
IOSurfaceCoreAnimationCompatibilityHTPCOK = 1;
IOSurfaceOpenGLESFBOCompatibility = 1;
IOSurfaceOpenGLESTextureCompatibility = 1;
OpenGLESCompatibility = 1;
PixelFormat = 1111970369;
};
} propagatedAttachments={
AlphaChannelIsOpaque = 1;
CVFieldCount = 1;
CVImageBufferChromaLocationBottomField = Left;
CVImageBufferChromaLocationTopField = Left;
CVImageBufferColorPrimaries = "ITU_R_2020";
CVImageBufferTransferFunction = "ITU_R_2100_HLG"; // HLG
CVImageBufferYCbCrMatrix = "ITU_R_2020";
QTMovieTime = {
TimeScale = 600;
TimeValue = 810;
};
} nonPropagatedAttachments={
}>


Or would it be desirable to receive the HDE video as kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange rather than kCVPixelFormatType_32BGRA?
It might be the distinction between linear/sRGB/gamma. If it is, you could just change your pixel formats, or perform the appropriate equations in the shader.
修复了吗?我也遇到了

How can I load HDR(HLG) pixelbuffer to texture?(OpenGLES, Metal)
 
 
Q