1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/utils: add ff_thread_replace_frame()

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2022-08-03 12:36:39 -03:00
parent 01d444c077
commit 3fe74c9017
2 changed files with 24 additions and 0 deletions

View File

@ -84,6 +84,9 @@ void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f);
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src);
int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst,
const ThreadFrame *src);
int ff_thread_can_start_frame(AVCodecContext *avctx);
#endif

View File

@ -915,6 +915,27 @@ int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
return 0;
}
int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst,
const ThreadFrame *src)
{
int ret;
dst->owner[0] = src->owner[0];
dst->owner[1] = src->owner[1];
ret = av_frame_replace(dst->f, src->f);
if (ret < 0)
return ret;
ret = av_buffer_replace(&dst->progress, src->progress);
if (ret < 0) {
ff_thread_release_ext_buffer(dst->owner[0], dst);
return ret;
}
return 0;
}
#if !HAVE_THREADS
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)