From: michaelni via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: michaelni <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avcodec/vp9: Reallocate on resolution change which does not change tile_cols (PR #21550)
Date: Fri, 23 Jan 2026 02:45:44 -0000
Message-ID: <176913634474.25.13143480878511079517@4457048688e7> (raw)
PR #21550 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21550
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21550.patch
Fixes: out of array access on resolution change with slices threads
Fixes: VULN-10/poc.ivf
Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>From bb74d752a1ba32a76157f13d2ddac119084f863f Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri, 23 Jan 2026 00:06:23 +0100
Subject: [PATCH] avcodec/vp9: Reallocate on resolution change which does not
change tile_cols
Fixes: out of array access on resolution change with slices threads
Fixes: VULN-10/poc.ivf
Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/vp9.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 715d3b7563..454346532c 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -177,10 +177,12 @@ static int update_size(AVCodecContext *avctx, int w, int h)
uint8_t *p;
int bytesperpixel = s->bytesperpixel, ret, cols, rows;
int lflvl_len, i;
+ int changed = 0;
av_assert0(w > 0 && h > 0);
if (!(s->pix_fmt == s->gf_fmt && w == s->w && h == s->h)) {
+ changed = 1;
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
@@ -266,7 +268,7 @@ static int update_size(AVCodecContext *avctx, int w, int h)
rows = (h + 7) >> 3;
if (s->intra_pred_data[0] && cols == s->cols && rows == s->rows && s->pix_fmt == s->last_fmt)
- return 0;
+ return changed;
s->last_fmt = s->pix_fmt;
s->sb_cols = (w + 63) >> 6;
@@ -311,9 +313,10 @@ static int update_size(AVCodecContext *avctx, int w, int h)
ff_vp9dsp_init(&s->dsp, s->s.h.bpp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
ff_videodsp_init(&s->vdsp, s->s.h.bpp);
s->last_bpp = s->s.h.bpp;
+ changed = 1;
}
- return 0;
+ return changed;
}
static int update_block_buffers(AVCodecContext *avctx)
@@ -520,6 +523,7 @@ static int decode_frame_header(AVCodecContext *avctx,
int c, i, j, k, l, m, n, w, h, max, size2, ret, sharp;
int last_invisible;
const uint8_t *data2;
+ int changed;
/* general header */
if ((ret = init_get_bits8(&s->gb, data, size)) < 0) {
@@ -789,10 +793,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
/* tiling info */
- if ((ret = update_size(avctx, w, h)) < 0) {
+ if ((changed = update_size(avctx, w, h)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder for %dx%d @ %d\n",
w, h, s->pix_fmt);
- return ret;
+ return changed;
}
for (s->s.h.tiling.log2_tile_cols = 0;
s->sb_cols > (64 << s->s.h.tiling.log2_tile_cols);
@@ -807,7 +811,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
s->s.h.tiling.log2_tile_rows = decode012(&s->gb);
s->s.h.tiling.tile_rows = 1 << s->s.h.tiling.log2_tile_rows;
- if (s->s.h.tiling.tile_cols != (1 << s->s.h.tiling.log2_tile_cols)) {
+ if (s->s.h.tiling.tile_cols != (1 << s->s.h.tiling.log2_tile_cols) || changed) {
int n_range_coders;
VPXRangeCoder *rc;
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2026-01-23 2:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=176913634474.25.13143480878511079517@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@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