From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 19CE64D1CA for ; Sun, 14 Dec 2025 16:14:43 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'ZHCRxZcmJOiyUTG67+yUMp9tQGLCygE2gHX5RMKCV3c=', expected b'4UL+5OgFpfyQQkY/Aol8E4PAr4EZaaS15OVpiXCqwPE=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1765728870; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=ZHCRxZcmJOiyUTG67+yUMp9tQGLCygE2gHX5RMKCV3c=; b=pbMRw50a2QtgRM8AeYuOT8teO6BcDaWrhBSpXL+9/fM6ygSapSTzXxeQMGu2dGMvGlF/V 3ZmG5eDiQ7lz5Nl023EUmmFT7O02eYhIedADbWV088cvrZ3HFxpPrQnZsjTkjqIz19YIlTJ Z5wrQvNq2JiDYWQ4mR8PRdgIvZLhWaM3JkwR1927uhw2IPMM+sarBmQXWz+Fc/C7qt3xLfN z5yg+2pOvdRupIy+oXsr/mNt13ABwL7iHr6/wTSPS7k+XG5Z96Ru5u+5BHOS9YxUbQLW9oD H6bLp54TRtycqIYLc1vwEPfce5wgzYBofW0PfQy83Pmckl13yIgsMRANaNNw== Received: from [172.20.0.2] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 182D4690814; Sun, 14 Dec 2025 18:14:30 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1765728861; b=pzwYDHsr3Sy2S5J9lIP6FCuED0EdxNoLvly+fa83s3O343mRBN6a06BNFXgQoohKhLH/T CHXaKjaxxOhfWCfb03AHSDnpG5hVbuwOWlg5xSUQzAgAE+sQMnJwtC5Q3MZMoZ5UDNJurDT TQGiQTwwX8hHmjMwQYE/RGUEnpV9wUCCjDswvNUqkZTxh2e1i1fI9OGpWu+ZEgetYhgS+yS 1wP26Jg8MKmV/59HeWd4ADROUsF8/x7EVZ1Qjzn2Cg7yhaST+TNNATdTlUB1A0qr8/3RTxW E3HSmq8YP7ZKMDjRDNyNADuYnkExez2NbMacW6rZDhQjR0BLVqFZehdGftfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1765728861; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=8ev94t1Js0Tys2cGBh9tqoOBW4hxDXQx7eaqe1ZQxZc=; b=QsvO5PqPAuKq1/GNivrGJOYto799na9Tp3JEpfW5jTVOLEDB2983/SExXV2E6YG9FC4la 2IwP6UidXnXloc2tblE3SwsmKALeIXajh39CH1IERXwPpP+Kebq4Z2dpltwsDvIcrucxkG6 Dn30AbgU/AMM3xZTZYSVqvOjSIshQco+ghtySLx638LhDmSAlNz53VLXJJZS8Tf64bs7Dxd Tx5Y4oiNNC7aCzL58TzcHoLrt8xewYlL/VAfIHMFNFzxpEae5UYqTw59F5yyIlwgPx2rcTf naslKr7NVz0hs6jXyYYF8+67OyTLLLRbzEKu3D4/R2S84pNgSagD/cynIAsg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1765728854; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=4UL+5OgFpfyQQkY/Aol8E4PAr4EZaaS15OVpiXCqwPE=; b=DCnNvlkx2M1EEcWm3QKr+S/rb6VpuhczwTind5XGBd4kQ7+QqxEVHYWh/SMSmHxL6ducc 9yzXONBQuQmokQYFmeIjFgcUdpnHGtQFYPzimeBJvBAfEvEUIpGlv88JMjHc/Ff1mCHoES9 imlNDMGQfVELL6qWOhe7aCt4HA7dE7ec7UzgQeqgbjW7Zf/4bV49wesgt3M1Lqs031uAZDy MZQWRsAXSwJBeCIhu7wN/eRSGJAZsPZZ8Y3nbSoAvfsnvRxap7QrdiddCdXmAi238VNehHe V8z4GNj6HbcicsTbPvAJLRD1yo2/sDuC2MtwbzLmKmpzYF4w3EPPAnYiKfbg== Received: from 55ca25703178 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 88524690805 for ; Sun, 14 Dec 2025 18:14:14 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Dec 2025 16:14:14 -0000 Message-ID: <176572885470.60.10903798705352741951@2cb04c0e5124> Message-ID-Hash: T6TRINB2GCAVAAN46ZLBQYCULJBA3T52 X-Message-ID-Hash: T6TRINB2GCAVAAN46ZLBQYCULJBA3T52 X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] Various libsvtjpegxs fixes (PR #21195) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21195 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21195 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21195.patch >>From bc7d1847c5ffe4984bc65e6b800ab43913963d23 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 14 Dec 2025 16:05:09 +0100 Subject: [PATCH 1/5] avcodec/libsvtjpegxs{dec,enc}: Don't get log level multiple times Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtjpegxsdec.c | 9 +++------ libavcodec/libsvtjpegxsenc.c | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/libavcodec/libsvtjpegxsdec.c b/libavcodec/libsvtjpegxsdec.c index 45d9134cd4..56beff9edb 100644 --- a/libavcodec/libsvtjpegxsdec.c +++ b/libavcodec/libsvtjpegxsdec.c @@ -237,12 +237,9 @@ static av_cold int svt_jpegxs_dec_init(AVCodecContext* avctx) { SvtJpegXsDecodeContext* svt_dec = avctx->priv_data; - if (av_log_get_level() < AV_LOG_DEBUG) - svt_dec->decoder.verbose = VERBOSE_ERRORS; - else if (av_log_get_level() == AV_LOG_DEBUG) - svt_dec->decoder.verbose = VERBOSE_SYSTEM_INFO; - else - svt_dec->decoder.verbose = VERBOSE_WARNINGS; + int log_level = av_log_get_level(); + svt_dec->decoder.verbose = log_level < AV_LOG_DEBUG ? VERBOSE_ERRORS : + log_level == AV_LOG_DEBUG ? VERBOSE_SYSTEM_INFO : VERBOSE_WARNINGS; if (svt_dec->proxy_mode == 1) svt_dec->decoder.proxy_mode = proxy_mode_half; diff --git a/libavcodec/libsvtjpegxsenc.c b/libavcodec/libsvtjpegxsenc.c index 2f7ec095df..dc4d238457 100644 --- a/libavcodec/libsvtjpegxsenc.c +++ b/libavcodec/libsvtjpegxsenc.c @@ -189,12 +189,9 @@ static av_cold int svt_jpegxs_enc_init(AVCodecContext* avctx) { svt_enc->encoder.threads_num = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64); - if (av_log_get_level() < AV_LOG_DEBUG) - svt_enc->encoder.verbose = VERBOSE_ERRORS; - else if (av_log_get_level() == AV_LOG_DEBUG) - svt_enc->encoder.verbose = VERBOSE_SYSTEM_INFO; - else - svt_enc->encoder.verbose = VERBOSE_WARNINGS; + int log_level = av_log_get_level(); + svt_enc->encoder.verbose = log_level < AV_LOG_DEBUG ? VERBOSE_ERRORS : + log_level == AV_LOG_DEBUG ? VERBOSE_SYSTEM_INFO : VERBOSE_WARNINGS; if (avctx->bit_rate <= 0) { av_log(avctx, AV_LOG_ERROR, "bitrate can't be 0\n"); -- 2.49.1 >>From c261ea81eb6767e1e8581d51b3323cfbecc77f36 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 14 Dec 2025 16:23:35 +0100 Subject: [PATCH 2/5] avcodec/libsvtjpegxsenc: Remove dead code The pixel format has already been checked generically. This also fixes the bug that the earlier code ignored the return value of set_pix_fmt(). Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtjpegxsenc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/libsvtjpegxsenc.c b/libavcodec/libsvtjpegxsenc.c index dc4d238457..6b10a32d33 100644 --- a/libavcodec/libsvtjpegxsenc.c +++ b/libavcodec/libsvtjpegxsenc.c @@ -25,6 +25,7 @@ #include +#include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/cpu.h" #include "libavutil/imgutils.h" @@ -113,62 +114,61 @@ static av_cold int svt_jpegxs_enc_free(AVCodecContext* avctx) { return 0; } -static int set_pix_fmt(AVCodecContext* avctx, svt_jpeg_xs_encoder_api_t *encoder) +static void set_pix_fmt(AVCodecContext *avctx, svt_jpeg_xs_encoder_api_t *encoder) { switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: encoder->input_bit_depth = 8; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420; - return 0; + return; case AV_PIX_FMT_YUV422P: encoder->input_bit_depth = 8; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422; - return 0; + return; case AV_PIX_FMT_YUV444P: encoder->input_bit_depth = 8; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB; - return 0; + return; case AV_PIX_FMT_YUV420P10LE: encoder->input_bit_depth = 10; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420; - return 0; + return; case AV_PIX_FMT_YUV422P10LE: encoder->input_bit_depth = 10; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422; - return 0; + return; case AV_PIX_FMT_YUV444P10LE: encoder->input_bit_depth = 10; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB; - return 0; + return; case AV_PIX_FMT_YUV420P12LE: encoder->input_bit_depth = 12; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420; - return 0; + return; case AV_PIX_FMT_YUV422P12LE: encoder->input_bit_depth = 12; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422; - return 0; + return; case AV_PIX_FMT_YUV444P12LE: encoder->input_bit_depth = 12; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB; - return 0; + return; case AV_PIX_FMT_YUV420P14LE: encoder->input_bit_depth = 14; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420; - return 0; + return; case AV_PIX_FMT_YUV422P14LE: encoder->input_bit_depth = 14; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422; - return 0; + return; case AV_PIX_FMT_YUV444P14LE: encoder->input_bit_depth = 14; encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB; - return 0; + return; default: + av_unreachable("Already checked via CODEC_PIXFMTS_ARRAY"); break; } - av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); - return AVERROR_INVALIDDATA; } static av_cold int svt_jpegxs_enc_init(AVCodecContext* avctx) { -- 2.49.1 >>From 39f2635e34ba8e7b174d000f9a1f4ddf49b239d4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 14 Dec 2025 16:47:12 +0100 Subject: [PATCH 3/5] avcodec/libsvtjpegxs{dec,enc}: Don't call av_cpu_count() multiple times (Like the old code, the new code limits the number of threads to 64, even when the user explicitly set a higher thread count. I don't know whether it is intentional to apply this limit even when the user explicitly supplied the number of threads.) Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtjpegxsdec.c | 3 ++- libavcodec/libsvtjpegxsenc.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libsvtjpegxsdec.c b/libavcodec/libsvtjpegxsdec.c index 56beff9edb..2499f32059 100644 --- a/libavcodec/libsvtjpegxsdec.c +++ b/libavcodec/libsvtjpegxsdec.c @@ -248,7 +248,8 @@ static av_cold int svt_jpegxs_dec_init(AVCodecContext* avctx) else svt_dec->decoder.proxy_mode = proxy_mode_full; - svt_dec->decoder.threads_num = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64); + int thread_count = avctx->thread_count ? avctx->thread_count : av_cpu_count(); + svt_dec->decoder.threads_num = FFMIN(thread_count, 64); svt_dec->decoder.use_cpu_flags = CPU_FLAGS_ALL; return 0; diff --git a/libavcodec/libsvtjpegxsenc.c b/libavcodec/libsvtjpegxsenc.c index 6b10a32d33..9daf226c9d 100644 --- a/libavcodec/libsvtjpegxsenc.c +++ b/libavcodec/libsvtjpegxsenc.c @@ -187,7 +187,8 @@ static av_cold int svt_jpegxs_enc_init(AVCodecContext* avctx) { set_pix_fmt(avctx, &svt_enc->encoder); - svt_enc->encoder.threads_num = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64); + int thread_count = avctx->thread_count ? avctx->thread_count : av_cpu_count(); + svt_enc->encoder.threads_num = FFMIN(thread_count, 64); int log_level = av_log_get_level(); svt_enc->encoder.verbose = log_level < AV_LOG_DEBUG ? VERBOSE_ERRORS : -- 2.49.1 >>From 6b58bd0916024e77096b045cefb5124afb9c3466 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 14 Dec 2025 17:00:06 +0100 Subject: [PATCH 4/5] avcodec/libsvtjpegxsenc: Don't copy unnecessarily Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtjpegxsenc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/libsvtjpegxsenc.c b/libavcodec/libsvtjpegxsenc.c index 9daf226c9d..2a7c67fe44 100644 --- a/libavcodec/libsvtjpegxsenc.c +++ b/libavcodec/libsvtjpegxsenc.c @@ -55,9 +55,9 @@ static int svt_jpegxs_enc_encode(AVCodecContext* avctx, AVPacket* pkt, { SvtJpegXsEncodeContext* svt_enc = avctx->priv_data; - svt_jpeg_xs_bitstream_buffer_t out_buf; - svt_jpeg_xs_image_buffer_t in_buf; svt_jpeg_xs_frame_t enc_input; + svt_jpeg_xs_bitstream_buffer_t *const out_buf = &enc_input.bitstream; + svt_jpeg_xs_image_buffer_t *const in_buf = &enc_input.image; svt_jpeg_xs_frame_t enc_output; SvtJxsErrorType_t err = SvtJxsErrorNone; @@ -67,19 +67,17 @@ static int svt_jpegxs_enc_encode(AVCodecContext* avctx, AVPacket* pkt, if (ret < 0) return ret; - out_buf.buffer = pkt->data;// output bitstream ptr - out_buf.allocation_size = pkt->size;// output bitstream size - out_buf.used_size = 0; + out_buf->buffer = pkt->data;// output bitstream ptr + out_buf->allocation_size = pkt->size;// output bitstream size + out_buf->used_size = 0; for (int comp = 0; comp < 3; comp++) { // svt-jpegxs require stride in pixel's not in bytes, this means that for 10 bit-depth, stride is half the linesize - in_buf.stride[comp] = frame->linesize[comp] / pixel_size; - in_buf.data_yuv[comp] = frame->data[comp]; - in_buf.alloc_size[comp] = in_buf.stride[comp] * svt_enc->encoder.source_height * pixel_size; + in_buf->stride[comp] = frame->linesize[comp] / pixel_size; + in_buf->data_yuv[comp] = frame->data[comp]; + in_buf->alloc_size[comp] = in_buf->stride[comp] * svt_enc->encoder.source_height * pixel_size; } - enc_input.bitstream = out_buf; - enc_input.image = in_buf; enc_input.user_prv_ctx_ptr = pkt; err = svt_jpeg_xs_encoder_send_picture(&svt_enc->encoder, &enc_input, 1 /*blocking*/); -- 2.49.1 >>From 265b645fd9ed30174e9fb0c6ba67e19f1d5eb546 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 14 Dec 2025 17:06:07 +0100 Subject: [PATCH 5/5] avcodec/libsvtjpegxsenc: Replace divisions by shifts Also simplify setting alloc_size. Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtjpegxsenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libsvtjpegxsenc.c b/libavcodec/libsvtjpegxsenc.c index 2a7c67fe44..ba626b03c0 100644 --- a/libavcodec/libsvtjpegxsenc.c +++ b/libavcodec/libsvtjpegxsenc.c @@ -61,7 +61,6 @@ static int svt_jpegxs_enc_encode(AVCodecContext* avctx, AVPacket* pkt, svt_jpeg_xs_frame_t enc_output; SvtJxsErrorType_t err = SvtJxsErrorNone; - uint32_t pixel_size = svt_enc->encoder.input_bit_depth <= 8 ? 1 : 2; int ret = ff_get_encode_buffer(avctx, pkt, svt_enc->bitstream_frame_size, 0); if (ret < 0) @@ -71,11 +70,12 @@ static int svt_jpegxs_enc_encode(AVCodecContext* avctx, AVPacket* pkt, out_buf->allocation_size = pkt->size;// output bitstream size out_buf->used_size = 0; + unsigned pixel_shift = svt_enc->encoder.input_bit_depth <= 8 ? 0 : 1; for (int comp = 0; comp < 3; comp++) { // svt-jpegxs require stride in pixel's not in bytes, this means that for 10 bit-depth, stride is half the linesize - in_buf->stride[comp] = frame->linesize[comp] / pixel_size; + in_buf->stride[comp] = frame->linesize[comp] >> pixel_shift; in_buf->data_yuv[comp] = frame->data[comp]; - in_buf->alloc_size[comp] = in_buf->stride[comp] * svt_enc->encoder.source_height * pixel_size; + in_buf->alloc_size[comp] = frame->linesize[comp] * svt_enc->encoder.source_height; } enc_input.user_prv_ctx_ptr = pkt; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org