[FFmpeg-cvslog] avcodec/libjxldec: produce rgbf32 and rgbaf32 frames

Leo Izen git at videolan.org
Sat Dec 23 05:08:55 EET 2023


ffmpeg | branch: master | Leo Izen <leo.izen at gmail.com> | Mon Dec 11 07:02:32 2023 -0500| [f6ef6a853cd6334fcc70aa6c1b3f05028d57b82b] | committer: Leo Izen

avcodec/libjxldec: produce rgbf32 and rgbaf32 frames

These pixel formats have always been supported by libjxl, but at the
time this plugin was written, they were not in FFmpeg yet. Now that
they are in FFmpeg, we should support them.

Signed-off-by: Leo Izen <leo.izen at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6ef6a853cd6334fcc70aa6c1b3f05028d57b82b
---

 libavcodec/libjxldec.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 002740d9c1..d719c06bdf 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -130,10 +130,11 @@ static enum AVPixelFormat libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
             return basic_info->alpha_bits ? AV_PIX_FMT_YA8 : AV_PIX_FMT_GRAY8;
         }
         if (basic_info->exponent_bits_per_sample || basic_info->bits_per_sample > 16) {
-            if (basic_info->alpha_bits)
-                return AV_PIX_FMT_NONE;
-            format->data_type = JXL_TYPE_FLOAT;
-            return AV_PIX_FMT_GRAYF32;
+            if (!basic_info->alpha_bits) {
+                format->data_type = JXL_TYPE_FLOAT;
+                return AV_PIX_FMT_GRAYF32;
+            }
+            av_log(avctx, AV_LOG_WARNING, "Downsampling gray+alpha float to 16-bit integer via libjxl\n");
         }
         format->data_type = JXL_TYPE_UINT16;
         return basic_info->alpha_bits ? AV_PIX_FMT_YA16 : AV_PIX_FMT_GRAY16;
@@ -145,10 +146,10 @@ static enum AVPixelFormat libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
             format->data_type = JXL_TYPE_UINT8;
             return basic_info->alpha_bits ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
         }
-        if (basic_info->exponent_bits_per_sample)
-            av_log(avctx, AV_LOG_WARNING, "Downsampling float to 16-bit integer via libjxl\n");
-        else if (basic_info->bits_per_sample > 16)
-            av_log(avctx, AV_LOG_WARNING, "Downsampling larger integer to 16-bit via libjxl\n");
+        if (basic_info->exponent_bits_per_sample || basic_info->bits_per_sample > 16) {
+            format->data_type = JXL_TYPE_FLOAT;
+            return basic_info->alpha_bits ? AV_PIX_FMT_RGBAF32 : AV_PIX_FMT_RGBF32;
+        }
         format->data_type = JXL_TYPE_UINT16;
         return basic_info->alpha_bits ? AV_PIX_FMT_RGBA64 : AV_PIX_FMT_RGB48;
     }



More information about the ffmpeg-cvslog mailing list