You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavc/decode: allow to allocate hwaccel_priv_data early
This commit is contained in:
@@ -1087,6 +1087,15 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
|
|||||||
if (!frames_ref)
|
if (!frames_ref)
|
||||||
return AVERROR(ENOMEM);
|
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);
|
ret = hwa->frame_params(avctx, frames_ref);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frames_ref->data;
|
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frames_ref->data;
|
||||||
@@ -1122,7 +1131,7 @@ static int hwaccel_init(AVCodecContext *avctx,
|
|||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hwaccel->priv_data_size) {
|
if (!avctx->internal->hwaccel_priv_data && hwaccel->priv_data_size) {
|
||||||
avctx->internal->hwaccel_priv_data =
|
avctx->internal->hwaccel_priv_data =
|
||||||
av_mallocz(hwaccel->priv_data_size);
|
av_mallocz(hwaccel->priv_data_size);
|
||||||
if (!avctx->internal->hwaccel_priv_data)
|
if (!avctx->internal->hwaccel_priv_data)
|
||||||
@@ -1288,6 +1297,9 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
|
|||||||
--n;
|
--n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
ff_hwaccel_uninit(avctx);
|
||||||
|
|
||||||
av_freep(&choices);
|
av_freep(&choices);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user