PR #22621 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22621 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22621.patch
The documentation for ff_get_format() says "If it is not possible to decode to software, AVCodecContext.sw_pix_fmt must be set before calling this function." >From 7789e309e8cf55a0a92556bf1d8eec3131179f8c Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 25 Mar 2026 17:32:23 -0300 Subject: [PATCH] avcodec/av1dec: set AVCodecContext.sw_pix_fmt The documentation for ff_get_format() says "If it is not possible to decode to software, AVCodecContext.sw_pix_fmt must be set before calling this function." Signed-off-by: James Almer <[email protected]> --- libavcodec/av1dec.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index ba8442077a..2722242484 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -537,7 +537,7 @@ static int get_pixel_format(AVCodecContext *avctx) AV1DecContext *s = avctx->priv_data; const AV1RawSequenceHeader *seq = s->raw_seq; int ret; - enum AVPixelFormat pix_fmt = get_sw_pixel_format(avctx, seq); + avctx->sw_pix_fmt = get_sw_pixel_format(avctx, seq); #define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \ CONFIG_AV1_D3D11VA_HWACCEL * 2 + \ CONFIG_AV1_D3D12VA_HWACCEL + \ @@ -546,12 +546,12 @@ static int get_pixel_format(AVCodecContext *avctx) CONFIG_AV1_VDPAU_HWACCEL + \ CONFIG_AV1_VIDEOTOOLBOX_HWACCEL + \ CONFIG_AV1_VULKAN_HWACCEL) - enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; + enum AVPixelFormat pix_fmts[HWACCEL_MAX + 1], *fmtp = pix_fmts; - if (pix_fmt == AV_PIX_FMT_NONE) + if (avctx->sw_pix_fmt == AV_PIX_FMT_NONE) return -1; - switch (pix_fmt) { + switch (avctx->sw_pix_fmt) { case AV_PIX_FMT_YUV420P: #if CONFIG_AV1_DXVA2_HWACCEL *fmtp++ = AV_PIX_FMT_DXVA2_VLD; @@ -653,12 +653,11 @@ static int get_pixel_format(AVCodecContext *avctx) break; } - *fmtp++ = pix_fmt; *fmtp = AV_PIX_FMT_NONE; - for (int i = 0; pix_fmts[i] != pix_fmt; i++) + for (int i = 0; pix_fmts[i] != AV_PIX_FMT_NONE; i++) if (pix_fmts[i] == avctx->pix_fmt) { - s->pix_fmt = pix_fmt; + s->pix_fmt = avctx->sw_pix_fmt; return 1; } @@ -676,7 +675,7 @@ static int get_pixel_format(AVCodecContext *avctx) return AVERROR(ENOSYS); } - s->pix_fmt = pix_fmt; + s->pix_fmt = avctx->sw_pix_fmt; avctx->pix_fmt = ret; av_log(avctx, AV_LOG_DEBUG, "AV1 decode get format: %s.\n", -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
