aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2023-05-11 03:55:47 +0200
committerLynne <dev@lynne.ee>2023-05-29 00:41:27 +0200
commitb6a6e2b19da74c44a0f3f0821d499c032bc74647 (patch)
tree22345353827b404ef6fd4b76e4fc892cd090e0af /libavcodec
parent8b23644408ef4ea98184325d7a98f43c316143a1 (diff)
downloadffmpeg-b6a6e2b19da74c44a0f3f0821d499c032bc74647.tar.gz
lavc/decode: allow to allocate hwaccel_priv_data early
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/decode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index d75f831a74..9ff132a15c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1087,6 +1087,15 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
if (!frames_ref)
return AVERROR(ENOMEM);
+ if (!avctx->internal->hwaccel_priv_data) {
+ avctx->internal->hwaccel_priv_data =
+ av_mallocz(hwa->priv_data_size);
+ if (!avctx->internal->hwaccel_priv_data) {
+ av_buffer_unref(&frames_ref);
+ return AVERROR(ENOMEM);
+ }
+ }
+
ret = hwa->frame_params(avctx, frames_ref);
if (ret >= 0) {
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frames_ref->data;
@@ -1122,7 +1131,7 @@ static int hwaccel_init(AVCodecContext *avctx,
return AVERROR_PATCHWELCOME;
}
- if (hwaccel->priv_data_size) {
+ if (!avctx->internal->hwaccel_priv_data && hwaccel->priv_data_size) {
avctx->internal->hwaccel_priv_data =
av_mallocz(hwaccel->priv_data_size);
if (!avctx->internal->hwaccel_priv_data)
@@ -1288,6 +1297,9 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
--n;
}
+ if (ret < 0)
+ ff_hwaccel_uninit(avctx);
+
av_freep(&choices);
return ret;
}