lavc/decode: allow to allocate hwaccel_priv_data early

This commit is contained in:
Lynne 2023-05-11 03:55:47 +02:00
parent 8b23644408
commit b6a6e2b19d
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464

View File

@ -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;
}