PR #24147 opened by ffmpeg-devel URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24147 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24147.patch
**Backport:** https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23989 Previously only the first thread's context and the user-facing one had it, so frames decoded by the remaining worker threads were missing global side data whenever the per-frame state could not provide it, e.g. extradata-derived HDR metadata after avcodec_flush_buffers(). From 21df65f3ef9fa9d136beaae05a8455579aff9302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Sun, 2 Aug 2026 22:22:58 +0200 Subject: [PATCH] avcodec/pthread_frame: sync decoded side data to all worker threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously only the first thread's context and the user-facing one had it, so frames decoded by the remaining worker threads were missing global side data whenever the per-frame state could not provide it, e.g. extradata-derived HDR metadata after avcodec_flush_buffers(). Signed-off-by: Kacper Michajłow <[email protected]> (cherry picked from commit c48230eb86ff02246f6a14fa1475a0d9398363b4) --- libavcodec/pthread_frame.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 5b4b0b342c..1f604b19e9 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -884,17 +884,18 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, } p->thread_init = NEEDS_CLOSE; - if (first) { + if (first) update_context_from_thread(avctx, copy, 1); - av_frame_side_data_free(&avctx->decoded_side_data, &avctx->nb_decoded_side_data); - for (int i = 0; i < copy->nb_decoded_side_data; i++) { - err = av_frame_side_data_clone(&avctx->decoded_side_data, - &avctx->nb_decoded_side_data, - copy->decoded_side_data[i], 0); - if (err < 0) - return err; - } + const AVCodecContext *src = first ? copy : avctx; + AVCodecContext *dst = first ? avctx : copy; + av_frame_side_data_free(&dst->decoded_side_data, &dst->nb_decoded_side_data); + for (int i = 0; i < src->nb_decoded_side_data; i++) { + err = av_frame_side_data_clone(&dst->decoded_side_data, + &dst->nb_decoded_side_data, + src->decoded_side_data[i], 0); + if (err < 0) + return err; } atomic_init(&p->debug_threads, (copy->debug & FF_DEBUG_THREADS) != 0); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
