Skip to content
Snippets Groups Projects
Commit ad8bbb0d authored by Steve Lhomme's avatar Steve Lhomme
Browse files

contrib: ffmpeg: fix a rare crash on some odd files with DVXA

There is a cleaner fix proposed but it may have wider impacts and needs to be
checked on all platforms:
https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg137976.html

This one should be safe for 3.0.18
parent f5b18999
No related branches found
No related tags found
2 merge requests!3533Backport MR 3236 to 3.0.x,!2418[3.0] contrib: ffmpeg: fix a rare crash on some odd files with DVXA
Pipeline #255151 passed with stage
in 44 minutes and 55 seconds
From 2a2937b72e2ef17170a7cd617be3cfa578115b7a Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 17 Dec 2019 11:21:17 +0100
Subject: [PATCH] avcodec/pthread_frame: do not give the hardware context
internals to the user
The internal data should not leak to the user. It can potentially be destroyed
twice since the hwaccel uninit was also copied back to the user.
This behaviour may only be found in VLC which uses frame threading with hardware
decoding.
---
libavcodec/pthread_frame.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 9176027f15..26439c1058 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -293,14 +293,17 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->color_range = src->color_range;
dst->chroma_sample_location = src->chroma_sample_location;
- dst->hwaccel = src->hwaccel;
- dst->hwaccel_context = src->hwaccel_context;
+ if (!for_user) {
+ dst->hwaccel = src->hwaccel;
+ dst->hwaccel_context = src->hwaccel_context;
+ }
dst->channels = src->channels;
dst->sample_rate = src->sample_rate;
dst->sample_fmt = src->sample_fmt;
dst->channel_layout = src->channel_layout;
- dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
+ if (!for_user)
+ dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
(dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) {
--
2.27.0.windows.1
......@@ -246,6 +246,9 @@ ifdef USE_FFMPEG
$(APPLY) $(SRC)/ffmpeg/0001-bring-back-XP-support.patch
$(APPLY) $(SRC)/ffmpeg/0001-avcodec-vp9-Do-not-destroy-uninitialized-mutexes-con.patch
$(APPLY) $(SRC)/ffmpeg/0001-dxva2_hevc-don-t-use-frames-as-reference-if-they-are.patch
ifdef HAVE_WIN32
$(APPLY) $(SRC)/ffmpeg/0001-avcodec-pthread_frame-do-not-give-the-hardware-conte.patch
endif
endif
ifdef USE_LIBAV
$(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment