[FFmpeg-devel] [PATCH] lavfi: rename avfilter_all_* function names to avfilter_make_all_*
Stefano Sabatini
stefasab at gmail.com
Tue Sep 13 20:05:12 CEST 2011
Function names should tell what the function does rather than what the
function returns. This also avoids possible conflicts (e.g. between a
function and a public list of all supported formats), and clarifies
the code a bit.
Breaks audio API/ABI, add a backward compatibility layer for video API/ABI.
---
libavfilter/af_aformat.c | 6 +++---
libavfilter/af_aresample.c | 4 ++--
libavfilter/avfilter.h | 19 +++++++++++++++----
libavfilter/defaults.c | 8 ++++----
libavfilter/formats.c | 13 ++++++++++---
5 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 0eb7dfa..a7aa45f 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -63,9 +63,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
if (*args) \
args++;
- ADD_FORMATS(avfilter_all_formats(AVMEDIA_TYPE_AUDIO), sample_format, int, formats);
- ADD_FORMATS(avfilter_all_channel_layouts(), channel_layout, int64_t, chlayouts);
- ADD_FORMATS(avfilter_all_packing_formats(), packing_format, int, packing);
+ ADD_FORMATS(avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO), sample_format, int, formats);
+ ADD_FORMATS(avfilter_make_all_channel_layouts(), channel_layout, int64_t, chlayouts);
+ ADD_FORMATS(avfilter_make_all_packing_formats(), packing_format, int, packing);
return 0;
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index fa26788..04188c8 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -104,12 +104,12 @@ static int query_formats(AVFilterContext *ctx)
return AVERROR(ENOMEM);
avfilter_set_common_sample_formats(ctx, formats);
- formats = avfilter_all_channel_layouts();
+ formats = avfilter_make_all_channel_layouts();
if (!formats)
return AVERROR(ENOMEM);
avfilter_set_common_channel_layouts(ctx, formats);
- formats = avfilter_all_packing_formats();
+ formats = avfilter_make_all_packing_formats();
if (!formats)
return AVERROR(ENOMEM);
avfilter_set_common_packing_formats(ctx, formats);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 995653f..05da80f 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -43,6 +43,9 @@
#ifndef FF_API_OLD_VSINK_API
#define FF_API_OLD_VSINK_API (LIBAVUTIL_VERSION_MAJOR < 3)
#endif
+#ifndef FF_API_OLD_MAKE_FORMATS_API
+#define FF_API_OLD_MAKE_FORMATS_API (LIBAVUTIL_VERSION_MAJOR < 3)
+#endif
#include <stddef.h>
@@ -258,25 +261,33 @@ AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts);
*/
int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
+#if FF_API_OLD_MAKE_FORMATS_API
/**
- * Return a list of all formats supported by FFmpeg for the given media type.
+ * @deprecated Use avfilter_make_all_formats() instead.
*/
+attribute_deprecated
AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
+#endif
+
+/**
+ * Return a list of all formats supported by FFmpeg for the given media type.
+ */
+AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type);
/**
* A list of all channel layouts supported by libavfilter.
*/
-extern const int64_t avfilter_all_channel_layouts_int64[];
+extern const int64_t avfilter_all_channel_layouts[];
/**
* Return a list of all channel layouts supported by FFmpeg.
*/
-AVFilterFormats *avfilter_all_channel_layouts(void);
+AVFilterFormats *avfilter_make_all_channel_layouts(void);
/**
* Return a list of all audio packing formats.
*/
-AVFilterFormats *avfilter_all_packing_formats(void);
+AVFilterFormats *avfilter_make_all_packing_formats(void);
/**
* Return a format list which contains the intersection of the formats of
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index c231f75..79fb38d 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -222,10 +222,10 @@ void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *
int avfilter_default_query_formats(AVFilterContext *ctx)
{
- avfilter_set_common_pixel_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_VIDEO));
- avfilter_set_common_sample_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_AUDIO));
- avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts());
- avfilter_set_common_packing_formats(ctx, avfilter_all_packing_formats());
+ avfilter_set_common_pixel_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_VIDEO));
+ avfilter_set_common_sample_formats(ctx, avfilter_make_all_formats(AVMEDIA_TYPE_AUDIO));
+ avfilter_set_common_channel_layouts(ctx, avfilter_make_all_channel_layouts());
+ avfilter_set_common_packing_formats(ctx, avfilter_make_all_packing_formats());
return 0;
}
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 4efb50d..fb7cc20 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -138,8 +138,15 @@ int avfilter_add_format(AVFilterFormats **avff, int64_t fmt)
return 0;
}
+#if FF_API_OLD_MAKE_FORMATS_API
AVFilterFormats *avfilter_all_formats(enum AVMediaType type)
{
+ return avfilter_make_all_formats(type);
+}
+#endif
+
+AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type)
+{
AVFilterFormats *ret = NULL;
int fmt;
int num_formats = type == AVMEDIA_TYPE_VIDEO ? PIX_FMT_NB :
@@ -158,12 +165,12 @@ const int64_t avfilter_all_channel_layouts_int64[] = {
-1
};
-AVFilterFormats *avfilter_all_channel_layouts(void)
+AVFilterFormats *avfilter_make_all_channel_layouts(void)
{
- return avfilter_make_format64_list(avfilter_all_channel_layouts_int64);
+ return avfilter_make_format64_list(avfilter_all_channel_layouts);
}
-AVFilterFormats *avfilter_all_packing_formats(void)
+AVFilterFormats *avfilter_make_all_packing_formats(void)
{
static int packing[] = {
AVFILTER_PACKED,
--
1.7.2.5
More information about the ffmpeg-devel
mailing list