From 9497657c83389511488ef6b0be16dea7a2ba31a7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 16 Dec 2023 17:28:35 -0600 Subject: [PATCH] Fix handling of zero minimum HDR luminance --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index 12d0fa70..5ff03121 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -351,6 +351,16 @@ bool PlVkRenderer::mapAvFrameToPlacebo(const AVFrame *frame, pl_frame* mappedFra return false; } + // libplacebo assumes a minimum luminance value of 0 means the actual value was unknown. + // Since we assume the host values are correct, we use the PL_COLOR_HDR_BLACK constant to + // indicate infinite contrast. + // + // NB: We also have to check that the AVFrame actually had metadata in the first place, + // because libplacebo may infer metadata if the frame didn't have any. + if (av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) && !mappedFrame->color.hdr.min_luma) { + mappedFrame->color.hdr.min_luma = PL_COLOR_HDR_BLACK; + } + return true; }