[FFmpeg-devel] (no subject)
Водянников Александр
aleksoid1978g at gmail.com
Mon Jul 17 10:08:06 EEST 2023
-------------- next part --------------
From 0fe666c4e3d10a689f4c6854a58eec3e7ff3c922 Mon Sep 17 00:00:00 2001
From: Aleksoid <Aleksoid1978 at mail.ru>
Date: Mon, 17 Jul 2023 17:04:43 +1000
Subject: [PATCH] Fixed crash when using hardware acceleration in third party
projects without using hw_frames_ctx.
---
libavcodec/decode.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a19cca1a7c..f34f169910 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1802,18 +1802,21 @@ AVBufferRef *ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx,
const AVHWAccel *hwaccel)
{
AVBufferRef *ref;
- AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
- uint8_t *data = av_mallocz(hwaccel->frame_priv_data_size);
- if (!data)
- return NULL;
-
- ref = av_buffer_create(data, hwaccel->frame_priv_data_size,
- hwaccel->free_frame_priv,
- frames_ctx->device_ctx, 0);
- if (!ref) {
- av_free(data);
- return NULL;
- }
+ if (avctx->hw_frames_ctx) {
+ AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
+ uint8_t *data = av_mallocz(hwaccel->frame_priv_data_size);
+ if (!data)
+ return NULL;
+
+ ref = av_buffer_create(data, hwaccel->frame_priv_data_size,
+ hwaccel->free_frame_priv,
+ frames_ctx->device_ctx, 0);
+ if (!ref) {
+ av_free(data);
+ return NULL;
+ }
+ } else
+ ref = av_buffer_allocz(hwaccel->frame_priv_data_size);
return ref;
}
--
2.41.0.windows.1
More information about the ffmpeg-devel
mailing list