diff mbox series

[FFmpeg-devel,v2] avcodec/libjxlenc: avoid hard failure with unspecified primaries

Message ID 20220715172537.25483-1-leo.izen@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avcodec/libjxlenc: avoid hard failure with unspecified primaries | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Leo Izen July 15, 2022, 5:25 p.m. UTC
This patch prevents the libjxl encoder wrapper from failing to
encode images when the input video has untagged primaries. It will
instead assume BT.709/sRGB primaries and print a warning.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
 libavcodec/libjxlenc.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 6a948cc3ae..3910d93e82 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -211,6 +211,11 @@  static int libjxl_populate_primaries(JxlColorEncoding *jxl_color, enum AVColorPr
         jxl_color->primaries = JXL_PRIMARIES_P3;
         jxl_color->white_point = JXL_WHITE_POINT_D65;
         return 0;
+    case AVCOL_PRI_UNSPECIFIED:
+        av_log(avctx, AV_LOG_WARNING, "Unknown primaries, assuming BT.709/sRGB. Colors may be wrong.\n");
+        jxl_color->primaries = JXL_PRIMARIES_SRGB;
+        jxl_color->white_point = JXL_WHITE_POINT_D65;
+        return 0;
     }
 
     desc = av_csp_primaries_desc_from_id(prm);