aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2024-10-07 17:43:07 +0200
committerZhao Zhili <zhilizhao@tencent.com>2024-10-30 21:31:17 +0800
commit44a0a0c050461abfc10de722c7e67534751ba760 (patch)
tree3fb1b9ac314f2bcdb13e952852c7eb1584346fb4
parentbb57b780134f59e3bddfab295e34e88468bbd545 (diff)
downloadffmpeg-44a0a0c050461abfc10de722c7e67534751ba760.tar.gz
avcodec/decode: clean-up if get_hw_frames_parameters fails
Fixes the following assert: [00007f1df83d17e0] vaapi generic error: avcodec_get_hw_frames_parameters failed: -22 Assertion p_dst->hwaccel_threadsafe || (!dst->hwaccel && !dst->internal->hwaccel_priv_data) failed at libavcodec/pthread_frame.c:349 Reproduced from VLC with VAAPI, when fallbacking from hw to sw. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--libavcodec/decode.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c331bb8596..3380cb27cf 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -19,6 +19,7 @@
*/
#include <stdint.h>
+#include <stdbool.h>
#include <string.h>
#include "config.h"
@@ -1173,6 +1174,7 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
const AVCodecHWConfigInternal *hw_config;
const FFHWAccel *hwa;
int i, ret;
+ bool clean_priv_data = false;
for (i = 0;; i++) {
hw_config = ffcodec(avctx->codec)->hw_configs[i];
@@ -1197,6 +1199,7 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
av_buffer_unref(&frames_ref);
return AVERROR(ENOMEM);
}
+ clean_priv_data = true;
}
ret = hwa->frame_params(avctx, frames_ref);
@@ -1217,6 +1220,8 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
*out_frames_ref = frames_ref;
} else {
+ if (clean_priv_data)
+ av_freep(&avctx->internal->hwaccel_priv_data);
av_buffer_unref(&frames_ref);
}
return ret;