From 69f5f6ea375950b4845b241ee27054bfc8f00343 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 13 Aug 2020 13:18:15 +0200 Subject: lavfi: check the validity of formats lists. Part of the code expects valid lists, in particular no duplicates. These tests allow to catch bugs in filters (unlikely but possible) and to give a clear message when the error comes from the user ((a)formats) or the application (buffersink). If we decide to switch to a more efficient merging algorithm, possibly sorting the lists, these functions will be the preferred place for pre-processing, and can be renamed accordingly. --- libavfilter/formats.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libavfilter/formats.h') diff --git a/libavfilter/formats.h b/libavfilter/formats.h index a06e88722e..8378be4b9b 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -291,4 +291,32 @@ void ff_formats_unref(AVFilterFormats **ref); */ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref); +/** + * Check that fmts is a valid pixel formats list. + * + * In particular, check for duplicates. + */ +int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts); + +/** + * Check that fmts is a valid sample formats list. + * + * In particular, check for duplicates. + */ +int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts); + +/** + * Check that fmts is a valid sample rates list. + * + * In particular, check for duplicates. + */ +int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts); + +/** + * Check that fmts is a valid channel layouts list. + * + * In particular, check for duplicates. + */ +int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts); + #endif /* AVFILTER_FORMATS_H */ -- cgit v1.2.3