]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
Fix channel count for resizing decoded audio buffer when not resampling.
[mlt] / src / modules / avformat / configure
1 #!/bin/sh
2
3 # Determine whether to recommend/use the HEAD revision of FFmpeg (unreleased)
4 # or a specific revision based upon whether the last digit of our version
5 # is even or odd. An odd MLT version number always represents unreleased.
6 svn_rev="0.6.1"
7 micro_version=$(echo $version | cut -d . -f 3)
8 odd_version=$(($micro_version % 2))
9 [ "$odd_version" -eq "1" ] && svn_rev="HEAD"
10
11 if [ "$help" = "1" ]
12 then
13         cat << EOF
14 FFmpeg/avformat options:
15
16   --avformat-svn          - Obtain FFmpeg from its Subversion repository
17   --avformat-svn-version  - Specify a particular revision for --avformat-svn
18   --avformat-svn-extra    - Add extra configure options for --avformat-svn
19   --avformat-shared=path  - Link against a shared installation of FFmpeg (default)
20   --avformat-static=path  - Link against a static FFmpeg development tree
21   --avformat-ldextra=libs - Provide additional libs to link with
22   --avformat-suffix=suff  - Specify a custom suffix for a shared build of FFmpeg
23   --avformat-swscale      - Use libswcale instead of img_convert
24   --avformat-no-codecs    - Disable the producer and consumer to avoid the FFmpeg codecs
25   --avformat-no-filters   - Disable the filters to make a codecs+muxers-only plugin
26   --avformat-no-devices   - Disable support for libavdevice
27   --avformat-vdpau        - Enable support for NVIDIA VDPAU
28
29   NOTE: The recommended version of FFmpeg is $([ "$svn_rev" = "0.6.1" ] && echo $svn_rev || echo SVN-r$svn_rev).
30
31 EOF
32
33 else
34         targetos=$(uname -s)
35         case $targetos in
36         Darwin)
37                 export LIBSUF=.dylib
38                 ;;
39         Linux|FreeBSD|NetBSD)
40                 export LIBSUF=.so
41                 ;;
42         *)
43                 ;;
44         esac
45                 
46         bits=$(uname -m)
47         case $bits in
48         x86_64)
49                 [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
50                 ;;
51         *)
52                 export LIBDIR=lib
53                 ;;
54         esac
55
56         echo > config.mak
57
58         export static_ffmpeg=
59         export shared_ffmpeg=$(pkg-config --variable=prefix libavformat)
60         export extra_libs=
61         export svn_ffmpeg=
62         export svn_ffmpeg_extra=
63         export avformat_suffix=
64         export swscale=
65         export codecs=true
66         export filters=true
67         export devices=true
68         export vdpau=false
69         pkg-config x11 > /dev/null 2>&1
70         export x11=$?
71
72         for i in "$@"
73         do
74                 case $i in
75                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
76                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
77                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
78                         --avformat-svn )                svn_ffmpeg=true ;;
79                         --avformat-svn-extra=* ) svn_ffmpeg_extra="${i#--avformat-svn-extra=}" ;;
80                         --avformat-svn-version=* )      svn_rev="${i#--avformat-svn-version=}" ;;
81                         --avformat-cvs )                svn_ffmpeg=true ;;
82                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
83                         --avformat-swscale )    swscale=true ;;
84                         --avformat-swscaler )   swscale=true ;;
85                         --avformat-no-codecs )  codecs=false ;;
86                         --avformat-no-filters ) filters=false ;;
87                         --avformat-no-devices ) devices=false ;;
88                         --avformat-no-vdpau )   vdpau=false ;;
89                         --avformat-vdpau )      vdpau=true ;;
90                 esac
91         done
92
93         if [ "$svn_ffmpeg" != "" ]
94         then
95                 if [ "$gpl" = "true" ]  
96                 then
97                         enable_gpl="--enable-gpl"
98                         [ "$swscale" != "" ] && [ "$svn_rev" = "0.5" ] &&
99                                 enable_swscale="--enable-swscale"
100                 fi
101                 if [ ! -d "ffmpeg" ]
102                 then
103                         echo
104                         echo "Checking out ffmpeg/avformat revision $svn_rev - no password required"
105                         echo
106                         if [ "$svn_rev" = "0.6.1" ] || [ "$svn_rev" = "0.6" ] || [ "$svn_rev" = "0.5" ]
107                         then
108                                 svn checkout svn://svn.mplayerhq.hu/ffmpeg/branches/$svn_rev ffmpeg
109                         else
110                                 svn checkout -r $svn_rev svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
111                         fi
112                 fi
113                 [ "$devices" = "false" ] && disable_devices="--disable-devices"
114                 [ -d "ffmpeg" ] && ( cd ffmpeg ; ./configure $enable_gpl $disable_devices $enable_swscale $svn_ffmpeg_extra --extra-cflags=-fPIC )
115                 #[ ! -f "ffmpeg/ffmpeg.patch" ] && ( cd ffmpeg ; cp ../ffmpeg.patch . ; patch -p0 < ffmpeg.patch )
116                 echo "CFLAGS+=-DAVDATADIR=\\\"${prefix}/share/ffmpeg/\\\"" >> config.mak
117                 echo "CFLAGS+=-I`pwd`/ffmpeg" >> config.mak
118                 echo "LDFLAGS+=-L`pwd`/ffmpeg/libavformat -L`pwd`/ffmpeg/libavcodec -L`pwd`/ffmpeg/libavutil" >> config.mak
119                 if [ "$swscale" != "" ] || [ "$svn_rev" = "HEAD" ] || [ "$svn_rev" = "0.6.1" ] || [ "$svn_rev" = "0.6" ] || [ "$svn_rev" = "0.5" ]
120                 then
121                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libswscale" >> config.mak
122                         echo "SWSCALE=1" >> config.mak
123                 fi
124                 if [ "$devices" = "true" ]
125                 then
126                         echo "LDFLAGS+=-L`pwd`/ffmpeg/libavdevice" >> config.mak
127                 fi
128                 [ $targetos = "Darwin" ] &&
129                         echo "LDFLAGS+=-single_module" >> config.mak
130                 echo "LOCAL_FFMPEG=1" >> config.mak
131                 echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
132                 extra_libs="$extra_libs -lm -lz -lbz2"
133                 
134                 if [ "$vdpau" = "true" ]
135                 then
136                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"`pwd`/ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
137                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
138                 fi
139         elif [ "$static_ffmpeg" != "" ]
140         then 
141                 if [ -d "$static_ffmpeg" ]
142                 then
143                         echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
144                         echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
145                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
146                         [ $targetos = "Darwin" ] &&
147                                 echo "LDFLAGS+=-single_module" >> config.mak
148                         if [ "$swscale" != "" ]
149                         then
150                                 echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
151                                 echo "SWSCALE=1" >> config.mak
152                         fi
153                         if [ "$devices" = "true" ]
154                         then
155                                 echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
156                         fi
157                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
158                         extra_libs="$extra_libs -lm -lz -lbz2"
159                         
160                         if [ "$vdpau" = "true" ]
161                         then
162                                 printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$static_ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
163                                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
164                         fi
165                 else
166                         echo "avformat: Invalid path specified: $static_ffmpeg"
167                         touch ../disable-avformat
168                         echo 0
169                 fi
170         elif [ "$shared_ffmpeg" != "" ]
171         then
172                 echo "PREFIX=$shared_ffmpeg" >> config.mak
173                 case $targetos in
174                         MINGW32_NT-*)
175                                 echo "CFLAGS+=-DAVDATADIR=\\\"share/ffmpeg/\\\"" >> config.mak
176                         ;;
177                         *)
178                                 echo "CFLAGS+=-DAVDATADIR=\\\"${shared_ffmpeg}/share/ffmpeg/\\\"" >> config.mak
179                         ;;
180                 esac
181                 echo "CFLAGS+=$(pkg-config --cflags libavformat)" >> config.mak
182                 echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat)" >> config.mak
183                 if [ "$devices" = "true" ]
184                 then
185                         echo "CFLAGS+=$(pkg-config --cflags libavdevice)" >> config.mak
186                         echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice)" >> config.mak
187                 fi
188                 avcodec_version=$(pkg-config --modversion libavcodec)
189                 if [ "$swscale" != "" ] || [ $(echo $avcodec_version | cut -d. -f1) -gt 52 ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
190                 then
191                         echo "CFLAGS+=$(pkg-config --cflags libswscale)" >> config.mak
192                         echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale)" >> config.mak
193                         echo "SWSCALE=1" >> config.mak
194                 fi
195                 
196                 if [ "$vdpau" = "true" ]
197                 then
198                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$(pkg-config --cflags libavformat)" -I"$shared_ffmpeg/include" $CFLAGS -c -x c -  >/dev/null 2>&1
199                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
200                 fi
201         else
202                 echo "avformat: No build environment found. "
203                 echo "          Try configuring mlt with --avformat-svn."
204                 touch ../disable-avformat
205                 exit 0
206         fi
207
208         echo "EXTRA_LIBS=$extra_libs" >> config.mak
209         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
210         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
211         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
212         [ "$devices" = "true" ] && echo "DEVICES=1" >> config.mak
213         exit 0
214
215 fi