[FFmpeg-cvslog] configure: speed up print_enabled_components()

Avi Halachmi (:avih) git at videolan.org
Mon Aug 27 17:36:23 EEST 2018


ffmpeg | branch: master | Avi Halachmi (:avih) <avihpit at yahoo.com> | Mon Jul 30 22:48:04 2018 +0300| [923586a58f37deedeb01f742e4804bc36736a6bc] | committer: James Almer

configure: speed up print_enabled_components()

x4 - x10 faster.

Inside print_enabled components, the filter_list case invokes sed
about 350 times to parse the same source file and extract different
info for each arg. This is never instant, and on systems where fork is
slow (notably MSYS2/Cygwin on windows) it takes many seconds.

Change it to use sed once on the source file and set env vars with the
parse results, then use these results inside the loop.

Additionally, the cases of indev_list and outdev_list are very
infrequent, but nevertheless they're faster, and arguably cleaner, with
shell parameter substitutions than with command substitutions.

Tested-by: Michael Niedermayer <michael at niedermayer.cc>
Tested-by: Helmut K. C. Tessarek <tessarek at evermeet.cx>
Tested-by: Dave Yeo <daveryeo at telus.net>
Tested-by: Reino Wijnsma <rwijnsma at xs4all.nl>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=923586a58f37deedeb01f742e4804bc36736a6bc
---

 configure | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 95a38cf20e..2f2c2dc58c 100755
--- a/configure
+++ b/configure
@@ -7237,9 +7237,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
-}
+# full_filter_name_foo=vf_foo
+# full_filter_name_bar=asrc_bar
+# ...
+eval "$(sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_\(.*\);/full_filter_name_\2=\1_\2/p" $source_path/libavfilter/allfilters.c)"
 
 # generate the lists of enabled components
 print_enabled_components(){
@@ -7252,13 +7253,13 @@ print_enabled_components(){
         if enabled $c; then
             case $name in
                 filter_list)
-                    c=$(full_filter_name $(remove_suffix _filter $c))
+                    eval c=\$full_filter_name_${c%_filter}
                 ;;
                 indev_list)
-                    c=$(add_suffix _demuxer $(remove_suffix _indev $c))
+                    c=${c%_indev}_demuxer
                 ;;
                 outdev_list)
-                    c=$(add_suffix _muxer $(remove_suffix _outdev $c))
+                    c=${c%_outdev}_muxer
                 ;;
             esac
             printf "    &ff_%s,\n" $c >> $TMPH



More information about the ffmpeg-cvslog mailing list