This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 083a0147463074e66bdc9475631cb1cc5ad8c1f7 Author: Niklas Haas <[email protected]> AuthorDate: Tue Mar 24 18:02:32 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Fri Apr 10 15:12:17 2026 +0200 avfilter/framepool: add ff_frame_pool_*_reinit() helpers This moves the check-uninit-reinit logic out of audio.c/video.c and into framepool.c, where it can be more conveniently re-used by future users. Signed-off-by: Niklas Haas <[email protected]> --- libavfilter/framepool.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ libavfilter/framepool.h | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c index d0d8dceffa..61451cdb4e 100644 --- a/libavfilter/framepool.c +++ b/libavfilter/framepool.c @@ -291,3 +291,53 @@ av_cold void ff_frame_pool_uninit(FFFramePool **pool) av_freep(pool); } + +int ff_frame_pool_video_reinit(FFFramePool **pool, + int width, + int height, + enum AVPixelFormat format, + int align) +{ + FFFramePool *cur = *pool; + if (cur && cur->format == format && + FFALIGN(cur->width, cur->align) == FFALIGN(width, align) && + FFALIGN(cur->height, cur->align) == FFALIGN(height, align) && + cur->align == align) + { + av_assert1(cur->type == AVMEDIA_TYPE_VIDEO); + return 0; + } + + FFFramePool *new = ff_frame_pool_video_init(width, height, format, align); + if (!new) + return AVERROR(ENOMEM); + + *pool = new; + ff_frame_pool_uninit(&cur); + return 0; +} + +int ff_frame_pool_audio_reinit(FFFramePool **pool, + int channels, + int nb_samples, + enum AVSampleFormat format, + int align) +{ + FFFramePool *cur = *pool; + if (cur && cur->format == format && + cur->channels == channels && + cur->nb_samples == nb_samples && + cur->align == align) + { + av_assert1(cur->type == AVMEDIA_TYPE_AUDIO); + return 0; + } + + FFFramePool *new = ff_frame_pool_audio_init(channels, nb_samples, format, align); + if (!new) + return AVERROR(ENOMEM); + + *pool = new; + ff_frame_pool_uninit(&cur); + return 0; +} diff --git a/libavfilter/framepool.h b/libavfilter/framepool.h index f18d3c1536..e73ab6cb79 100644 --- a/libavfilter/framepool.h +++ b/libavfilter/framepool.h @@ -68,6 +68,44 @@ FFFramePool *ff_frame_pool_audio_init(int channels, */ void ff_frame_pool_uninit(FFFramePool **pool); +/** + * Recreate the video frame pool if its current configuration differs from the + * provided configuration. If initialization fails, the old pool is kept + * unchanged. + * + * @param pool pointer to the frame pool to be reinitialized, or a pointer to + * NULL to create a new pool. + * @param width width of each frame in this pool + * @param height height of each frame in this pool + * @param format format of each frame in this pool + * @param align buffers alignment of each frame in this pool + * @return 0 on success, a negative AVERROR otherwise. + */ +int ff_frame_pool_video_reinit(FFFramePool **pool, + int width, + int height, + enum AVPixelFormat format, + int align); + +/** + * Recreate the audio frame pool if its current configuration differs from the + * provided configuration. If initialization fails, the old pool is kept + * unchanged. + * + * @param pool pointer to the frame pool to be reinitialized, or a pointer to + * NULL to create a new pool. + * @param channels channels of each frame in this pool + * @param nb_samples number of samples of each frame in this pool + * @param format format of each frame in this pool + * @param align buffers alignment of each frame in this pool + * @return 0 on success, a negative AVERROR otherwise. + */ +int ff_frame_pool_audio_reinit(FFFramePool **pool, + int channels, + int nb_samples, + enum AVSampleFormat format, + int align); + /** * Get the video frame pool configuration. * _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
