From 01351a6412be8751d06c8ccc9baa3979c530325c Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 13 Feb 2023 20:59:46 +0100 Subject: [PATCH] video/image_writer: add image_writer_flexible_csp PNG only supports this since the introduction of cICP, so put a version check on the next API version bump after the cICP writing patch got merged. --- video/image_writer.c | 13 +++++++++++++ video/image_writer.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/video/image_writer.c b/video/image_writer.c index 1a3dab7fbd..67eb2aa7a8 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -332,6 +332,19 @@ bool image_writer_high_depth(const struct image_writer_opts *opts) ; } +bool image_writer_flexible_csp(const struct image_writer_opts *opts) +{ + return false +#if HAVE_JPEGXL + || opts->format == AV_CODEC_ID_JPEGXL +#endif +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 58, 100) + // This version added support for cICP tag writing + || opts->format == AV_CODEC_ID_PNG +#endif + ; +} + int image_writer_format_from_ext(const char *ext) { for (int n = 0; mp_image_writer_formats[n].name; n++) { diff --git a/video/image_writer.h b/video/image_writer.h index 54871bacf0..8a9d67e5bf 100644 --- a/video/image_writer.h +++ b/video/image_writer.h @@ -50,6 +50,9 @@ const char *image_writer_file_ext(const struct image_writer_opts *opts); // Return whether the selected format likely supports >8 bit per component. bool image_writer_high_depth(const struct image_writer_opts *opts); +// Return whether the selected format likely supports non-sRGB colorspaces +bool image_writer_flexible_csp(const struct image_writer_opts *opts); + // Map file extension to format ID - return 0 (which is invalid) if unknown. int image_writer_format_from_ext(const char *ext);