Commit 8f1382f8 authored by Josh de Kock's avatar Josh de Kock

lavfi: add new iteration API

Signed-off-by: 's avatarJosh de Kock <josh@itanimul.li>
parent cda43940
......@@ -3622,15 +3622,6 @@ for v in "$@"; do
FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
done
find_things(){
thing=$1
pattern=$2
file=$source_path/$3
sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
}
FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
find_things_extern(){
thing=$1
pattern=$2
......@@ -3639,6 +3630,13 @@ find_things_extern(){
sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
}
find_filters_extern(){
file=$source_path/$1
#sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_\(\w\+\);/\2_filter/p" $file
sed -E -n "s/^extern AVFilter ff_([avfsinkrc]{2,5})_([a-zA-Z0-9_]+);/\2_filter/p" $file
}
FILTER_LIST=$(find_filters_extern libavfilter/allfilters.c)
OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c outdev)
INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c indev)
MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
......@@ -7157,6 +7155,10 @@ echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
cp_if_changed $TMPH libavutil/avconfig.h
full_filter_name(){
sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_$1;/\1_$1/p" $source_path/libavfilter/allfilters.c
}
# generate the lists of enabled components
print_enabled_components(){
file=$1
......@@ -7167,6 +7169,9 @@ print_enabled_components(){
for c in $*; do
if enabled $c; then
case $name in
filter_list)
c=$(full_filter_name $(remove_suffix _filter $c))
;;
indev_list)
c=$(add_suffix _demuxer $(remove_suffix _indev $c))
;;
......@@ -7177,10 +7182,16 @@ print_enabled_components(){
printf " &ff_%s,\n" $c >> $TMPH
fi
done
if [ "$name" == "filter_list" ]; then
for c in asrc_abuffer vsrc_buffer asink_abuffer vsink_buffer; do
printf " &ff_%s,\n" $c >> $TMPH
done
fi
echo " NULL };" >> $TMPH
cp_if_changed $TMPH $file
}
print_enabled_components libavfilter/filter_list.c AVFilter filter_list $FILTER_LIST
print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST
print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST
......
......@@ -15,6 +15,10 @@ libavutil: 2017-10-21
API changes, most recent first:
2018-xx-xx - xxxxxxx - lavc 7.13.100 - avcodec.h
Deprecate use of avfilter_register(), avfilter_register_all(),
avfilter_next(). Add av_filter_iterate().
2018-03-xx - xxxxxxx - lavc 58.16.100 - avcodec.h
Add FF_SUB_CHARENC_MODE_IGNORE.
......
......@@ -31,10 +31,8 @@ If everything went right, you should get a foobar.png with Lena edge-detected.
That's it, your new playground is ready.
Some little details about what's going on:
libavfilter/allfilters.c:avfilter_register_all() is called at runtime to create
a list of the available filters, but it's important to know that this file is
also parsed by the configure script, which in turn will define variables for
the build system and the C:
libavfilter/allfilters.c:this file is parsed by the configure script, which in turn
will define variables for the build system and the C:
--- after running configure ---
......
This diff is collapsed.
......@@ -575,51 +575,6 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
return AVERROR(ENOSYS);
}
static AVFilter *first_filter;
static AVFilter **last_filter = &first_filter;
const AVFilter *avfilter_get_by_name(const char *name)
{
const AVFilter *f = NULL;
if (!name)
return NULL;
while ((f = avfilter_next(f)))
if (!strcmp(f->name, name))
return (AVFilter *)f;
return NULL;
}
static AVMutex filter_register_mutex = AV_MUTEX_INITIALIZER;
int avfilter_register(AVFilter *filter)
{
AVFilter **f;
/* the filter must select generic or internal exclusively */
av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != AVFILTER_FLAG_SUPPORT_TIMELINE);
ff_mutex_lock(&filter_register_mutex);
f = last_filter;
while (*f)
f = &(*f)->next;
*f = filter;
filter->next = NULL;
last_filter = &filter->next;
ff_mutex_unlock(&filter_register_mutex);
return 0;
}
const AVFilter *avfilter_next(const AVFilter *prev)
{
return prev ? prev->next : first_filter;
}
int avfilter_pad_count(const AVFilterPad *pads)
{
int count;
......@@ -648,10 +603,11 @@ static void *filter_child_next(void *obj, void *prev)
static const AVClass *filter_child_class_next(const AVClass *prev)
{
void *opaque = NULL;
const AVFilter *f = NULL;
/* find the filter that corresponds to prev */
while (prev && (f = avfilter_next(f)))
while (prev && (f = av_filter_iterate(&opaque)))
if (f->priv_class == prev)
break;
......@@ -660,7 +616,7 @@ static const AVClass *filter_child_class_next(const AVClass *prev)
return NULL;
/* find next filter with specific options */
while ((f = avfilter_next(f)))
while ((f = av_filter_iterate(&opaque)))
if (f->priv_class)
return f->priv_class;
......
......@@ -697,7 +697,20 @@ int avfilter_config_links(AVFilterContext *filter);
*/
int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
/**
* Iterate over all registered filters.
*
* @param opaque a pointer where libavfilter will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered filter or NULL when the iteration is
* finished
*/
const AVFilter *av_filter_iterate(void **opaque);
#if FF_API_NEXT
/** Initialize the filter system. Register all builtin filters. */
attribute_deprecated
void avfilter_register_all(void);
/**
......@@ -710,8 +723,18 @@ void avfilter_register_all(void);
* @return 0 if the registration was successful, a negative value
* otherwise
*/
attribute_deprecated
int avfilter_register(AVFilter *filter);
/**
* Iterate over all registered filters.
* @return If prev is non-NULL, next registered filter after prev or NULL if
* prev is the last filter. If prev is NULL, return the first registered filter.
*/
attribute_deprecated
const AVFilter *avfilter_next(const AVFilter *prev);
#endif
/**
* Get a filter definition matching the given name.
*
......@@ -721,12 +744,6 @@ int avfilter_register(AVFilter *filter);
*/
const AVFilter *avfilter_get_by_name(const char *name);
/**
* Iterate over all registered filters.
* @return If prev is non-NULL, next registered filter after prev or NULL if
* prev is the last filter. If prev is NULL, return the first registered filter.
*/
const AVFilter *avfilter_next(const AVFilter *prev);
/**
* Initialize a filter with the supplied parameters.
......
......@@ -58,5 +58,8 @@
#ifndef FF_API_FILTER_GET_SET
#define FF_API_FILTER_GET_SET (LIBAVFILTER_VERSION_MAJOR < 8)
#endif
#ifndef FF_API_NEXT
#define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
#endif
#endif /* AVFILTER_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment