PR #25980 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25980
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25980.patch


>From 38ad1b9c1150e627b38c2a668ab565c1b887bf98 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Thu, 12 Nov 2026 01:57:34 +0100
Subject: [PATCH 1/2] ffplay: set audio_st once the audio output is started

The display uses audio_tgt as soon as audio_st is set, and divided by
its 0 channels while the read thread was still opening the audio device.

Fixes: division by zero
Fixes: bgaX0SiJAybS
Regression since: c74f97bcd8

Found during the triage of a finding from the review of 
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25375

Division by zero Replicated through UnModified FFmpeg with UBSAN
---
 fftools/ffplay.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index c7c6933a1b6..00e64d255ed 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3067,16 +3067,17 @@ static int stream_component_open(VideoState *is, int 
stream_index)
             goto fail;
 
         is->audio_stream = stream_index;
-        is->audio_st = ic->streams[stream_index];
 
         if ((ret = decoder_init(&is->auddec, avctx, &is->audioq, 
is->continue_read_thread)) < 0)
             goto fail;
         if (is->ic->iformat->flags & AVFMT_NOTIMESTAMPS) {
-            is->auddec.start_pts = is->audio_st->start_time;
-            is->auddec.start_pts_tb = is->audio_st->time_base;
+            is->auddec.start_pts = ic->streams[stream_index]->start_time;
+            is->auddec.start_pts_tb = ic->streams[stream_index]->time_base;
         }
         if (!SDL_AtomicGet(&is->replacement) && (ret = audio_start(is)) < 0)
             stream_component_close(is, stream_index);
+        else
+            is->audio_st = ic->streams[stream_index];
         break;
     case AVMEDIA_TYPE_VIDEO:
         is->video_stream = stream_index;
-- 
2.54.0


>From 88df8b34ba82858ef2652c7d7c130edca89f7fc8 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Thu, 12 Nov 2026 02:15:27 +0100
Subject: [PATCH 2/2] avcodec/cfhd: do not allocate buffers in the next thread
 when the previous one has none

Fixes: PsK6Vw5ds9CE

Found during the triage of a finding from the review of 
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25015

Loss of all following frames Replicated through UnModified FFmpeg
---
 libavcodec/cfhd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index e4f54ba1965..8033fac69db 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -1443,6 +1443,9 @@ static int update_thread_context(AVCodecContext *dst, 
const AVCodecContext *src)
     pdst->progressive = psrc->progressive;
     pdst->planes = psrc->planes;
 
+    if (!psrc->plane[0].idwt_buf)
+        return 0;
+
     if (!pdst->plane[0].idwt_buf) {
         pdst->coded_width  = pdst->a_width;
         pdst->coded_height = pdst->a_height;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to