diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 08b133e1b1c15..279180179d8d4 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -73,6 +73,7 @@ static int videotoolbox_buffer_copy(VTContext *vtctx, static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame) { + VTContext *vtctx = ((AVCodecContext *)avctx)->internal->hwaccel_priv_data; CVPixelBufferRef ref = *(CVPixelBufferRef *)frame->buf[0]->data; if (!ref) { @@ -83,6 +84,11 @@ static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame) frame->data[3] = (uint8_t*)ref; + if (!frame->hw_frames_ctx) + frame->hw_frames_ctx = av_buffer_ref(vtctx->cached_hw_frames_ctx); + if (!frame->hw_frames_ctx) + return AVERROR(ENOMEM); + return 0; }