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 AD83A4E178 for ; Tue, 13 Jan 2026 22:49:50 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'tPmMg7SN85/kbErrcp++9sSCfPxHt5YKfSUlkgO6Dto=', expected b'GwpkZqwP+vQWdJqDw9s3K/Cu6No/FDgzF1134+55hpg=')) 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=1768344572; 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=tPmMg7SN85/kbErrcp++9sSCfPxHt5YKfSUlkgO6Dto=; b=uTOA3FrZjPNYVdw3a8CTFAMZeyy01jITNBr1xWAZT8Hs7/3qhQeAG0BZzLZwXX+5w3OXb 7FYeatdhYOtC2AzHoeiiX2J+QXzBp/nTrRM6HZCfSc8+Ed6bsMoBKQt/dUeEK4Xq2g5D5Oi 03VXV7pooLZtQ5cqxNP/Qc4cjtprzPE6Waej8HLA4UPHWacBodT1ISLDk6mOu5SOIG2by6d Yr38K8PLNDaLfLh1H/Hnt6Ydj2LeD3/D7TDtEfopdJwDAuI1ulmTkOFtiGSVcEoglwPdmYf apyuKfBfhqTyO4ZrMX7i3aitZSdaaV0iMAYCVc6E+2b6rNaWD9ah20rsDjSQ== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 5936C690E00; Wed, 14 Jan 2026 00:49:32 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1768344554; b=sNfOFS28ewzwWZLAy8Fu/ar9+XCBjNFTpjI9jZu1EdJ/KVkTqDvAc32oD9O0im0/yU+ac mzQRauDNTER/e4B3anpyXHvcjxpTSyvL2+RSZA3ROsQm1wUmsc5FxzJTxiOFc8mgxJBxHYY wdD/zNU9Fnd6j+EmfC/H0WlPg+xUl8mWEZmePu7dYj+hZaM+nakznE6f+SdMEyKrZY1SkjP IKf8UcMq7nMn8WcnrQv5xR+pke5PCmKzRApfWegCb+q1W8T0hu+pXPz9txAT6pxmjNTQ5Sb Bx0vWIv15iat62AbdNb97BWxDzoX6YeXVweBOaWrBmSH7vt5Rnlh0MvgSh3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1768344554; 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=jS1QRzTn+jV9TD02JRqCItlj0GgUIhaarazTWGtXaQg=; b=iJD7Xt3vys75uRag1D6kT0L5DYjVLZmsb8vra+Y4C8xaytea8aItv5WXB7/A7SAGwF5vf V5Nr7ojDZOodcd89Ab1UPg/duQEuXvmj6BeGJQk8OCDUNLVFzOpnWA8fjecoMRopyRF1IWv ynXVxl2jabxGBBt5fQmfumOmlwDyh8CMnJ9h2kkz9LukfU+yTDsg62avOcnjmIzCXM1NI8R YTyTKXYwdhDMwWsuliAcw+m7PY86wYxmcTclxUBW5okkdmegpgX8hvcUs6a/9nikXSRx1WA YhcGmvQqigTEJpCHQcGqlQzgt/wZibCcJ1Qa+m3ctzrBzD05xdyF7/AU1R+A== 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=1768344546; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=GwpkZqwP+vQWdJqDw9s3K/Cu6No/FDgzF1134+55hpg=; b=rb8E2YfNKXncprpryXthB3rWn8s/VZ5FADTYvcRuV9yES18TKV8ifV3wUOFTESeMCg+ki OdH4KbSEaWDAHEPqN9evIG+/SdZ305pwTMcYtYl3iuzVMcVXdZkh8xT0AoukxpMJDAUhM7S tMNJ0x7P8F0GTPv5jtizdYmXWctM/2gl616+0hGFej8KyubYPvIFTi9m9gtBPBC/4j740vL iJwU/FmFHUi+N0oEFRa3prLI1asFPrBXhPEVjI0iFIn61swYlfgsDi9xN1R3bVlIwFvejdU ZK/T71i86Dd1cBDmyhSNHUU3rSc/+bpPLv8b28XjvJ+ucpE6uVYWQrVNzWVw== Received: from f7c34508609e (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id F3BC9690A08 for ; Wed, 14 Jan 2026 00:49:05 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Jan 2026 22:49:05 -0000 Message-ID: <176834454617.25.18214480058786596409@4457048688e7> Message-ID-Hash: 2UWKIC646TDXGN54BA5SSXVKVBVPLIZY X-Message-ID-Hash: 2UWKIC646TDXGN54BA5SSXVKVBVPLIZY 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] [PR] Minor libvpx fixes and cosmetics (PR #21455) 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: Marton Balint via ffmpeg-devel Cc: Marton Balint Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21455 opened by Marton Balint (cus) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21455 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21455.patch Nothing major here, some minor, mostly cosmetic issues I found. >>From 9efac7687553394a52589a96d5393db6d91614d7 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 11 Jan 2026 18:50:56 +0100 Subject: [PATCH 1/4] avcodec/libvpxenc: log the error message from the correct encoder It is possible that the error happens with the alpha encoder, not the normal one, so let's always pass the affected encoder to the logging function. Signed-off-by: Marton Balint --- libavcodec/libvpxenc.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index af73966141..082709c41f 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -202,15 +202,14 @@ static const char *const ctlidstr[] = { #endif }; -static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) +static av_cold void log_encoder_error(void *logctx, struct vpx_codec_ctx *encoder, const char *desc) { - VPxContext *ctx = avctx->priv_data; - const char *error = vpx_codec_error(&ctx->encoder); - const char *detail = vpx_codec_error_detail(&ctx->encoder); + const char *error = vpx_codec_error(encoder); + const char *detail = vpx_codec_error_detail(encoder); - av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error); + av_log(logctx, AV_LOG_ERROR, "%s: %s\n", desc, error); if (detail) - av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail); + av_log(logctx, AV_LOG_ERROR, " Additional information: %s\n", detail); } static av_cold void dump_enc_cfg(AVCodecContext *avctx, @@ -477,7 +476,7 @@ static av_cold int codecctl_int(AVCodecContext *avctx, if (res != VPX_CODEC_OK) { snprintf(buf, sizeof(buf), "Failed to set %s codec control", ctlidstr[id]); - log_encoder_error(avctx, buf); + log_encoder_error(avctx, &ctx->encoder, buf); return AVERROR(EINVAL); } @@ -486,7 +485,7 @@ static av_cold int codecctl_int(AVCodecContext *avctx, if (res_alpha != VPX_CODEC_OK) { snprintf(buf, sizeof(buf), "Failed to set %s alpha codec control", ctlidstr[id]); - log_encoder_error(avctx, buf); + log_encoder_error(avctx, &ctx->encoder_alpha, buf); return AVERROR(EINVAL); } } @@ -510,7 +509,7 @@ static av_cold int codecctl_intp(AVCodecContext *avctx, if (res != VPX_CODEC_OK) { snprintf(buf, sizeof(buf), "Failed to set %s codec control", ctlidstr[id]); - log_encoder_error(avctx, buf); + log_encoder_error(avctx, &ctx->encoder, buf); return AVERROR(EINVAL); } @@ -519,7 +518,7 @@ static av_cold int codecctl_intp(AVCodecContext *avctx, if (res_alpha != VPX_CODEC_OK) { snprintf(buf, sizeof(buf), "Failed to set %s alpha codec control", ctlidstr[id]); - log_encoder_error(avctx, buf); + log_encoder_error(avctx, &ctx->encoder_alpha, buf); return AVERROR(EINVAL); } } @@ -1183,7 +1182,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, flags); if (res != VPX_CODEC_OK) { dump_enc_cfg(avctx, &enccfg, AV_LOG_WARNING); - log_encoder_error(avctx, "Failed to initialize encoder"); + log_encoder_error(avctx, &ctx->encoder, "Failed to initialize encoder"); return AVERROR(EINVAL); } dump_enc_cfg(avctx, &enccfg, AV_LOG_DEBUG); @@ -1207,7 +1206,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, enccfg_alpha = enccfg; res = vpx_codec_enc_init(&ctx->encoder_alpha, iface, &enccfg_alpha, flags); if (res != VPX_CODEC_OK) { - log_encoder_error(avctx, "Failed to initialize alpha encoder"); + log_encoder_error(avctx, &ctx->encoder_alpha, "Failed to initialize alpha encoder"); return AVERROR(EINVAL); } } @@ -1637,14 +1636,14 @@ static int vp9_encode_set_roi(AVCodecContext *avctx, int frame_width, int frame_ ret = set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt); if (ret) { - log_encoder_error(avctx, "Failed to set_roi_map.\n"); + log_encoder_error(avctx, &ctx->encoder, "Failed to set_roi_map.\n"); return ret; } memset(roi_map.ref_frame, -1, sizeof(roi_map.ref_frame)); if (vpx_codec_control(&ctx->encoder, VP9E_SET_ROI_MAP, &roi_map)) { - log_encoder_error(avctx, "Failed to set VP9E_SET_ROI_MAP codec control.\n"); + log_encoder_error(avctx, &ctx->encoder, "Failed to set VP9E_SET_ROI_MAP codec control.\n"); ret = AVERROR_INVALIDDATA; } av_freep(&roi_map.roi_map); @@ -1669,12 +1668,12 @@ static int vp8_encode_set_roi(AVCodecContext *avctx, int frame_width, int frame_ int ret = set_roi_map(avctx, sd, frame_width, frame_height, &roi_map, block_size, segment_cnt); if (ret) { - log_encoder_error(avctx, "Failed to set_roi_map.\n"); + log_encoder_error(avctx, &ctx->encoder, "Failed to set_roi_map.\n"); return ret; } if (vpx_codec_control(&ctx->encoder, VP8E_SET_ROI_MAP, &roi_map)) { - log_encoder_error(avctx, "Failed to set VP8E_SET_ROI_MAP codec control.\n"); + log_encoder_error(avctx, &ctx->encoder, "Failed to set VP8E_SET_ROI_MAP codec control.\n"); ret = AVERROR_INVALIDDATA; } @@ -1729,7 +1728,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, cfg.rc_max_quantizer = avctx->qmax; res = vpx_codec_enc_config_set(&ctx->encoder, &cfg); if (res != VPX_CODEC_OK) { - log_encoder_error(avctx, "Error reconfiguring encoder"); + log_encoder_error(avctx, &ctx->encoder, "Error reconfiguring encoder"); return AVERROR_INVALIDDATA; } } @@ -1867,7 +1866,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags, ctx->deadline); if (res != VPX_CODEC_OK) { - log_encoder_error(avctx, "Error encoding frame"); + log_encoder_error(avctx, &ctx->encoder, "Error encoding frame"); return AVERROR_INVALIDDATA; } @@ -1875,7 +1874,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp, duration, flags, ctx->deadline); if (res != VPX_CODEC_OK) { - log_encoder_error(avctx, "Error encoding alpha frame"); + log_encoder_error(avctx, &ctx->encoder_alpha, "Error encoding alpha frame"); return AVERROR_INVALIDDATA; } } -- 2.49.1 >>From f1a60ec6070b50608a214b58abb8975a6dbfd4d1 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 11 Jan 2026 21:39:05 +0100 Subject: [PATCH 2/4] avcodec/libvpxdec: cache the decoder interface This saves us some #ifdefry. Signed-off-by: Marton Balint --- libavcodec/libvpxdec.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index c6187fd5a1..b5898c6951 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -41,6 +41,7 @@ #include "profiles.h" typedef struct VPxDecoderContext { + const struct vpx_codec_iface *iface; struct vpx_codec_ctx decoder; struct vpx_codec_ctx decoder_alpha; AVBufferPool *pool; @@ -84,9 +85,9 @@ static int release_frame_buffer(void *priv, vpx_codec_frame_buffer_t *fb) } static av_cold int vpx_init(AVCodecContext *avctx, - struct vpx_codec_ctx* decoder, - const struct vpx_codec_iface *iface) + struct vpx_codec_ctx* decoder) { + VPxContext *ctx = avctx->priv_data; struct vpx_codec_dec_cfg deccfg = { .threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS) }; @@ -94,7 +95,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); - if (vpx_codec_dec_init(decoder, iface, &deccfg, 0) != VPX_CODEC_OK) { + if (vpx_codec_dec_init(decoder, ctx->iface, &deccfg, 0) != VPX_CODEC_OK) { const char *error = vpx_codec_error(decoder); av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n", error); @@ -239,17 +240,7 @@ static int vpx_decode(AVCodecContext *avctx, AVFrame *picture, if (additional_id == 1) { // 1 stands for alpha channel data. if (!ctx->has_alpha_channel) { ctx->has_alpha_channel = 1; - ret = vpx_init(avctx, - &ctx->decoder_alpha, -#if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER - (avctx->codec_id == AV_CODEC_ID_VP8) ? - vpx_codec_vp8_dx() : vpx_codec_vp9_dx() -#elif CONFIG_LIBVPX_VP8_DECODER - vpx_codec_vp8_dx() -#else - vpx_codec_vp9_dx() -#endif - ); + ret = vpx_init(avctx, &ctx->decoder_alpha); if (ret) return ret; } @@ -349,7 +340,8 @@ static av_cold int vpx_free(AVCodecContext *avctx) static av_cold int vp8_init(AVCodecContext *avctx) { VPxContext *ctx = avctx->priv_data; - return vpx_init(avctx, &ctx->decoder, vpx_codec_vp8_dx()); + ctx->iface = vpx_codec_vp8_dx(); + return vpx_init(avctx, &ctx->decoder); } const FFCodec ff_libvpx_vp8_decoder = { @@ -372,7 +364,8 @@ const FFCodec ff_libvpx_vp8_decoder = { static av_cold int vp9_init(AVCodecContext *avctx) { VPxContext *ctx = avctx->priv_data; - return vpx_init(avctx, &ctx->decoder, vpx_codec_vp9_dx()); + ctx->iface = vpx_codec_vp9_dx(); + return vpx_init(avctx, &ctx->decoder); } const FFCodec ff_libvpx_vp9_decoder = { -- 2.49.1 >>From 28c6c9d49cb6bf293accd3d4d679eaff033e24b7 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 11 Jan 2026 22:15:27 +0100 Subject: [PATCH 3/4] avcodec/libvpxdec: use codec capabilities to determine if external frame buffer can be used Previously we used the codec or at the time of decoding fb_priv for this, but fb_priv can be nonzero even if an external frame buffer is not set, so it's cleaner to use the capability flag directly. Also check the result of vpx_codec_set_frame_buffer_functions. Signed-off-by: Marton Balint --- libavcodec/libvpxdec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index b5898c6951..5b926b82ba 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -102,8 +102,12 @@ static av_cold int vpx_init(AVCodecContext *avctx, return AVERROR(EINVAL); } - if (avctx->codec_id == AV_CODEC_ID_VP9) - vpx_codec_set_frame_buffer_functions(decoder, get_frame_buffer, release_frame_buffer, avctx->priv_data); + if (vpx_codec_get_caps(ctx->iface) & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER) { + if (vpx_codec_set_frame_buffer_functions(decoder, get_frame_buffer, release_frame_buffer, avctx->priv_data)) { + av_log(avctx, AV_LOG_ERROR, "Failed to set frame buffer.\n"); + return AVERROR_EXTERNAL; + } + } return 0; } @@ -299,7 +303,7 @@ static int vpx_decode(AVCodecContext *avctx, AVFrame *picture, linesizes[3] = ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0; - if (img->fb_priv && (!ctx->has_alpha_channel || img_alpha->fb_priv)) { + if (vpx_codec_get_caps(ctx->iface) & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER) { ret = ff_decode_frame_props(avctx, picture); if (ret < 0) return ret; -- 2.49.1 >>From bd5e37146405f842349d424d0daba001263eff5b Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Mon, 12 Jan 2026 00:58:00 +0100 Subject: [PATCH 4/4] avcodec/libvpxdec: only set has_alpha_channel if alpha decoder initialization was successful Otherwise we might crash on a subsequent call to vpx_decode(). Signed-off-by: Marton Balint --- libavcodec/libvpxdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 5b926b82ba..b3871a7b6c 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -243,10 +243,10 @@ static int vpx_decode(AVCodecContext *avctx, AVFrame *picture, side_data_size -= 8; if (additional_id == 1) { // 1 stands for alpha channel data. if (!ctx->has_alpha_channel) { - ctx->has_alpha_channel = 1; ret = vpx_init(avctx, &ctx->decoder_alpha); if (ret) return ret; + ctx->has_alpha_channel = 1; } ret = decode_frame(avctx, &ctx->decoder_alpha, side_data, side_data_size); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org