* [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions @ 2023-02-04 13:32 Leo Izen 2023-02-04 15:24 ` Andreas Rheinhardt 2023-02-04 23:28 ` [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features Leo Izen 0 siblings, 2 replies; 6+ messages in thread From: Leo Izen @ 2023-02-04 13:32 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Leo Izen Commit fb823161a8e3dfc864a7bd83a9b968f4912c5b1d added a dependency of JxlBitDepth, which wasn't present in 0.7.0. This updates the library versions in ./configure required to match 0.8.0, the new required version. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d67855c729..013bd3dcfd 100755 --- a/configure +++ b/configure @@ -6596,8 +6596,8 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs -enabled libjxl && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion && - require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner +enabled libjxl && require_pkg_config libjxl "libjxl >= 0.8.0" jxl/decode.h JxlDecoderVersion && + require_pkg_config libjxl_threads "libjxl_threads >= 0.8.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new -- 2.39.1 _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions 2023-02-04 13:32 [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions Leo Izen @ 2023-02-04 15:24 ` Andreas Rheinhardt 2023-02-04 16:59 ` Leo Izen 2023-02-04 23:28 ` [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features Leo Izen 1 sibling, 1 reply; 6+ messages in thread From: Andreas Rheinhardt @ 2023-02-04 15:24 UTC (permalink / raw) To: ffmpeg-devel Leo Izen: > Commit fb823161a8e3dfc864a7bd83a9b968f4912c5b1d added a dependency of > JxlBitDepth, which wasn't present in 0.7.0. This updates the library > versions in ./configure required to match 0.8.0, the new required > version. > --- > configure | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/configure b/configure > index d67855c729..013bd3dcfd 100755 > --- a/configure > +++ b/configure > @@ -6596,8 +6596,8 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do > check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; > done || die "ERROR: libgsm not found"; } > enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs > -enabled libjxl && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion && > - require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner > +enabled libjxl && require_pkg_config libjxl "libjxl >= 0.8.0" jxl/decode.h JxlDecoderVersion && > + require_pkg_config libjxl_threads "libjxl_threads >= 0.8.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner > enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc > enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get > enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new How recent is this? - Andreas _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions 2023-02-04 15:24 ` Andreas Rheinhardt @ 2023-02-04 16:59 ` Leo Izen 2023-02-04 17:58 ` Jan Ekström 0 siblings, 1 reply; 6+ messages in thread From: Leo Izen @ 2023-02-04 16:59 UTC (permalink / raw) To: ffmpeg-devel On 2/4/23 10:24, Andreas Rheinhardt wrote: > Leo Izen: >> Commit fb823161a8e3dfc864a7bd83a9b968f4912c5b1d added a dependency of >> JxlBitDepth, which wasn't present in 0.7.0. This updates the library >> versions in ./configure required to match 0.8.0, the new required >> version. >> --- >> configure | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/configure b/configure >> index d67855c729..013bd3dcfd 100755 >> --- a/configure >> +++ b/configure >> @@ -6596,8 +6596,8 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do >> check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; >> done || die "ERROR: libgsm not found"; } >> enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs >> -enabled libjxl && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion && >> - require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner >> +enabled libjxl && require_pkg_config libjxl "libjxl >= 0.8.0" jxl/decode.h JxlDecoderVersion && >> + require_pkg_config libjxl_threads "libjxl_threads >= 0.8.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner >> enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc >> enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get >> enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new > > How recent is this? > > - Andreas > Version 0.8.0 was released about two weeks ago. Is this too recent? - Leo Izen (thebombzen) _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions 2023-02-04 16:59 ` Leo Izen @ 2023-02-04 17:58 ` Jan Ekström 0 siblings, 0 replies; 6+ messages in thread From: Jan Ekström @ 2023-02-04 17:58 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, Feb 4, 2023 at 6:59 PM Leo Izen <leo.izen@gmail.com> wrote: > > On 2/4/23 10:24, Andreas Rheinhardt wrote: > > Leo Izen: > >> Commit fb823161a8e3dfc864a7bd83a9b968f4912c5b1d added a dependency of > >> JxlBitDepth, which wasn't present in 0.7.0. This updates the library > >> versions in ./configure required to match 0.8.0, the new required > >> version. > >> --- > >> configure | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/configure b/configure > >> index d67855c729..013bd3dcfd 100755 > >> --- a/configure > >> +++ b/configure > >> @@ -6596,8 +6596,8 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do > >> check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; > >> done || die "ERROR: libgsm not found"; } > >> enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs > >> -enabled libjxl && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion && > >> - require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner > >> +enabled libjxl && require_pkg_config libjxl "libjxl >= 0.8.0" jxl/decode.h JxlDecoderVersion && > >> + require_pkg_config libjxl_threads "libjxl_threads >= 0.8.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner > >> enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc > >> enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get > >> enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new > > > > How recent is this? > > > > - Andreas > > > > Version 0.8.0 was released about two weeks ago. Is this too recent? > > - Leo Izen (thebombzen) Generally keeping backwards compatibility becomes more relevant when either: 1. the library is already stable and well-established 2. some addition can be easily #ifdef'd or so with version guards. At this point the lack of this bump is failing compilation on my Fedora 37 system as it currently still packages libjxl version 0.7.0, so as it seems like libjxl is still in the process of adding basic APIs, I'd maybe edge on the side of just bumping the requirement, even if the bit depth feature itself isn't that critical and could in theory be ifdef'd around (if libjxl even has useful defines for such checks). Jan _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features 2023-02-04 13:32 [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions Leo Izen 2023-02-04 15:24 ` Andreas Rheinhardt @ 2023-02-04 23:28 ` Leo Izen 2023-02-04 23:30 ` Leo Izen 1 sibling, 1 reply; 6+ messages in thread From: Leo Izen @ 2023-02-04 23:28 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Leo Izen Since many distributions ship libjxl 0.7.0 still, we'd still prefer to compile against that, but don't want to lose the features that require libjxl 0.8.0 or greater. For this reason I've added preprocessor #ifdef guards around the features that aren't necessarily in libjxl 0.7.0. Signed-off-by: Leo Izen <leo.izen@gmail.com> --- libavcodec/libjxl.h | 12 ++++++++++++ libavcodec/libjxldec.c | 19 +++++++++++++------ libavcodec/libjxlenc.c | 18 ++++++++++++++---- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/libavcodec/libjxl.h b/libavcodec/libjxl.h index 5387c438fd..e305b6e758 100644 --- a/libavcodec/libjxl.h +++ b/libavcodec/libjxl.h @@ -27,8 +27,20 @@ #ifndef AVCODEC_LIBJXL_H #define AVCODEC_LIBJXL_H +#include <jxl/decode.h> #include <jxl/memory_manager.h> +/* + * libjxl version 0.7.0 and earlier doesn't contain these macros at all + * so to detect version 0.7.0 versus 0.8.0 we need to define them ourselves + */ +#ifndef JPEGXL_COMPUTE_NUMERIC_VERSION + #define JPEGXL_COMPUTE_NUMERIC_VERSION(major,minor,patch) ((major<<24) | (minor<<16) | (patch<<8) | 0) +#endif +#ifndef JPEGXL_NUMERIC_VERSION + #define JPEGXL_NUMERIC_VERSION JPEGXL_COMPUTE_NUMERIC_VERSION(0, 7, 0) +#endif + /** * Transform threadcount in ffmpeg to one used by libjxl. * diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index abe08eb400..045a1535f9 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -47,7 +47,9 @@ typedef struct LibJxlDecodeContext { JxlDecoder *decoder; JxlBasicInfo basic_info; JxlPixelFormat jxl_pixfmt; +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) JxlBitDepth jxl_bit_depth; +#endif JxlDecoderStatus events; AVBufferRef *iccp; } LibJxlDecodeContext; @@ -94,14 +96,17 @@ static av_cold int libjxl_decode_init(AVCodecContext *avctx) return libjxl_init_jxl_decoder(avctx); } -static enum AVPixelFormat libjxl_get_pix_fmt(AVCodecContext *avctx, const JxlBasicInfo *basic_info, - JxlPixelFormat *format, JxlBitDepth *depth) +static enum AVPixelFormat libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecodeContext *ctx) { + const JxlBasicInfo *basic_info = &ctx->basic_info; + JxlPixelFormat *format = &ctx->jxl_pixfmt; format->endianness = JXL_NATIVE_ENDIAN; format->num_channels = basic_info->num_color_channels + (basic_info->alpha_bits > 0); - depth->bits_per_sample = avctx->bits_per_raw_sample = basic_info->bits_per_sample; - depth->type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT; - depth->exponent_bits_per_sample = basic_info->exponent_bits_per_sample; +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) + ctx->jxl_bit_depth.bits_per_sample = avctx->bits_per_raw_sample = basic_info->bits_per_sample; + ctx->jxl_bit_depth.type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT; + ctx->jxl_bit_depth.exponent_bits_per_sample = basic_info->exponent_bits_per_sample; +#endif /* Gray */ if (basic_info->num_color_channels == 1) { if (basic_info->bits_per_sample <= 8) { @@ -372,7 +377,7 @@ static int libjxl_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_f av_log(avctx, AV_LOG_ERROR, "Bad libjxl basic info event\n"); return AVERROR_EXTERNAL; } - avctx->pix_fmt = libjxl_get_pix_fmt(avctx, &ctx->basic_info, &ctx->jxl_pixfmt, &ctx->jxl_bit_depth); + avctx->pix_fmt = libjxl_get_pix_fmt(avctx, ctx); if (avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Bad libjxl pixel format\n"); return AVERROR_EXTERNAL; @@ -395,10 +400,12 @@ static int libjxl_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_f av_log(avctx, AV_LOG_ERROR, "Bad libjxl dec need image out buffer event\n"); return AVERROR_EXTERNAL; } +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) if (JxlDecoderSetImageOutBitDepth(ctx->decoder, &ctx->jxl_bit_depth) != JXL_DEC_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Error setting output bit depth\n"); return AVERROR_EXTERNAL; } +#endif continue; case JXL_DEC_FULL_IMAGE: /* full image is one frame, even if animated */ diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c index c51024f180..897452f575 100644 --- a/libavcodec/libjxlenc.c +++ b/libavcodec/libjxlenc.c @@ -250,7 +250,10 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra JxlBasicInfo info; JxlColorEncoding jxl_color; JxlPixelFormat jxl_fmt; + int bits_per_sample; +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) JxlBitDepth jxl_bit_depth; +#endif JxlEncoderStatus jret; int ret; size_t available = ctx->buffer_size; @@ -270,22 +273,26 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra info.ysize = frame->height; info.num_extra_channels = (jxl_fmt.num_channels + 1) % 2; info.num_color_channels = jxl_fmt.num_channels - info.num_extra_channels; - jxl_bit_depth.bits_per_sample = av_get_bits_per_pixel(pix_desc) / jxl_fmt.num_channels; + bits_per_sample = av_get_bits_per_pixel(pix_desc) / jxl_fmt.num_channels; info.bits_per_sample = avctx->bits_per_raw_sample > 0 && !(pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT) - ? avctx->bits_per_raw_sample : jxl_bit_depth.bits_per_sample; + ? avctx->bits_per_raw_sample : bits_per_sample; info.alpha_bits = (info.num_extra_channels > 0) * info.bits_per_sample; if (pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT) { info.exponent_bits_per_sample = info.bits_per_sample > 16 ? 8 : 5; info.alpha_exponent_bits = info.alpha_bits ? info.exponent_bits_per_sample : 0; jxl_fmt.data_type = info.bits_per_sample > 16 ? JXL_TYPE_FLOAT : JXL_TYPE_FLOAT16; - jxl_bit_depth.exponent_bits_per_sample = info.exponent_bits_per_sample; } else { info.exponent_bits_per_sample = 0; info.alpha_exponent_bits = 0; jxl_fmt.data_type = info.bits_per_sample <= 8 ? JXL_TYPE_UINT8 : JXL_TYPE_UINT16; - jxl_bit_depth.exponent_bits_per_sample = 0; } + +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) + jxl_bit_depth.bits_per_sample = bits_per_sample; jxl_bit_depth.type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT; + jxl_bit_depth.exponent_bits_per_sample = pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT ? + info.exponent_bits_per_sample : 0; +#endif /* JPEG XL format itself does not support limited range */ if (avctx->color_range == AVCOL_RANGE_MPEG || @@ -362,8 +369,11 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra av_log(avctx, AV_LOG_WARNING, "Could not set ICC Profile\n"); if (JxlEncoderSetColorEncoding(ctx->encoder, &jxl_color) != JXL_ENC_SUCCESS) av_log(avctx, AV_LOG_WARNING, "Failed to set JxlColorEncoding\n"); + +#if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0) if (JxlEncoderSetFrameBitDepth(ctx->options, &jxl_bit_depth) != JXL_ENC_SUCCESS) av_log(avctx, AV_LOG_WARNING, "Failed to set JxlBitDepth\n"); +#endif /* depending on basic info, level 10 might * be required instead of level 5 */ -- 2.39.1 _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features 2023-02-04 23:28 ` [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features Leo Izen @ 2023-02-04 23:30 ` Leo Izen 0 siblings, 0 replies; 6+ messages in thread From: Leo Izen @ 2023-02-04 23:30 UTC (permalink / raw) To: FFmpeg Development On 2/4/23 18:28, Leo Izen wrote: > Since many distributions ship libjxl 0.7.0 still, we'd still prefer to > compile against that, but don't want to lose the features that require > libjxl 0.8.0 or greater. For this reason I've added preprocessor #ifdef > guards around the features that aren't necessarily in libjxl 0.7.0. > > Signed-off-by: Leo Izen <leo.izen@gmail.com> This is an alternative to the above patch. I replied it to the previous patch so they can be compared but only one should be applied. - Leo Izen (thebombzen) _______________________________________________ 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". ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-04 23:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-02-04 13:32 [FFmpeg-devel] [PATCH] configure: update libjxl pkg-config versions Leo Izen 2023-02-04 15:24 ` Andreas Rheinhardt 2023-02-04 16:59 ` Leo Izen 2023-02-04 17:58 ` Jan Ekström 2023-02-04 23:28 ` [FFmpeg-devel] [PATCH] avcodec/libjxl: add #ifdef guards for libjxl >= 0.8.0 features Leo Izen 2023-02-04 23:30 ` Leo Izen
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