Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Leo Izen <leo.izen@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Leo Izen <leo.izen@gmail.com>
Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/libjxl: use RGB32F or RGBA32F for 32-bit float JPEG XL
Date: Sun,  2 Oct 2022 03:58:35 -0400
Message-ID: <20221002075835.415465-3-leo.izen@gmail.com> (raw)
In-Reply-To: <20221002075835.415465-1-leo.izen@gmail.com>

Use AV_PIX_FMT_RGB32F or AV_PIX_FMT_RGBA32F for encoding and decoding
JPEG XL files when encountered, rather than returning an error and
refusing to do anything.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
 libavcodec/libjxldec.c | 15 +++++++++------
 libavcodec/libjxlenc.c |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index de48bea4b2..92b98388d4 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -104,9 +104,12 @@ static enum AVPixelFormat libjxl_get_pix_fmt(void *avctx, const JxlBasicInfo *ba
             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;
+            if (basic_info->alpha_bits) {
+                av_log(avctx, AV_LOG_WARNING, "Decoding gray+alpha JXL input as RGBA\n");
+                format->num_channels = 4;
+                return AV_PIX_FMT_RGBAF32;
+            }
             return AV_PIX_FMT_GRAYF32;
         }
         format->data_type = JXL_TYPE_UINT16;
@@ -119,10 +122,10 @@ static enum AVPixelFormat libjxl_get_pix_fmt(void *avctx, const JxlBasicInfo *ba
             format->data_type = JXL_TYPE_UINT8;
             return basic_info->alpha_bits ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
         }
-        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)
-            av_log(avctx, AV_LOG_WARNING, "Downsampling float to 16-bit integer 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;
     }
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 0793ed251b..f9ae086e38 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -474,6 +474,7 @@ const FFCodec ff_libjxl_encoder = {
     .p.pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
         AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,
+        AV_PIX_FMT_RGBF32, AV_PIX_FMT_RGBAF32,
         AV_PIX_FMT_GRAY8, AV_PIX_FMT_YA8,
         AV_PIX_FMT_GRAY16, AV_PIX_FMT_YA16,
         AV_PIX_FMT_GRAYF32,
-- 
2.37.3

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-10-02  7:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02  7:58 [FFmpeg-devel] [PATCH 0/2] RGB(A)32F in libjxl Leo Izen
2022-10-02  7:58 ` [FFmpeg-devel] [PATCH 1/2] avutil/pixfmt.h: add native-endian RGB32F and RGBA32F formats Leo Izen
2022-10-09 17:29   ` Michael Niedermayer
2022-10-02  7:58 ` Leo Izen [this message]
2022-10-14 16:51   ` [FFmpeg-devel] [PATCH 2/2] avcodec/libjxl: use RGB32F or RGBA32F for 32-bit float JPEG XL Leo Izen
2022-10-09 11:58 ` [FFmpeg-devel] [PATCH 0/2] RGB(A)32F in libjxl Leo Izen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221002075835.415465-3-leo.izen@gmail.com \
    --to=leo.izen@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git