added av_set_parameters()
[libav.git] / tests / regression.sh
CommitLineData
51133a7d
FB
1#!/bin/sh
2#
3# automatic regression test for ffmpeg
4#
5#
6#set -x
7set -e
8
5bcfd1ad
FB
9datadir="./data"
10
11logfile="$datadir/ffmpeg.regression"
89d5dfd5 12
51133a7d
FB
13# tests to do
14if [ "$1" = "mpeg4" ] ; then
15 do_mpeg4=y
16elif [ "$1" = "mpeg" ] ; then
17 do_mpeg=y
89d5dfd5
FB
18elif [ "$1" = "libavtest" ] ; then
19 do_libav=y
5bcfd1ad 20 logfile="$datadir/libav.regression"
51133a7d
FB
21else
22 do_mpeg=y
6ebd933b 23 do_msmpeg4v2=y
51133a7d 24 do_msmpeg4=y
6ebd933b 25 do_wmv1=y
51133a7d 26 do_h263=y
6e2d5f1a 27 do_h263p=y
51133a7d
FB
28 do_mpeg4=y
29 do_mjpeg=y
64a7a8af 30 do_rv10=y
51133a7d
FB
31 do_mp2=y
32 do_ac3=y
1dbb6d90
MN
33 do_rc=y
34 do_mpeg4adv=y
51133a7d
FB
35fi
36
37
38# various files
3aca208a 39ffmpeg="../ffmpeg_g"
5bcfd1ad 40outfile="$datadir/a-"
51133a7d 41reffile="$2"
5bcfd1ad 42benchfile="$datadir/ffmpeg.bench"
51133a7d 43raw_src="vsynth1/%d.pgm"
5bcfd1ad 44raw_dst="$datadir/out.yuv"
51133a7d 45pcm_src="asynth1.sw"
5bcfd1ad
FB
46pcm_dst="$datadir/out.wav"
47
48# create the data directory if it does not exists
49mkdir -p $datadir
51133a7d 50
3f027ca7 51do_ffmpeg()
51133a7d
FB
52{
53 f="$1"
54 shift
2ad1516a
MN
55 echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
56 $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp
3f027ca7 57 md5sum -b $f >> $logfile
90cee0c3 58 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
5bcfd1ad 59 echo `cat $datadir/bench2.tmp` $f >> $benchfile
51133a7d
FB
60}
61
3f027ca7 62do_ffmpeg_crc()
89d5dfd5
FB
63{
64 f="$1"
65 shift
2ad1516a
MN
66 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
67 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
89d5dfd5 68 echo -n "$f " >> $logfile
5bcfd1ad 69 cat $datadir/ffmpeg.crc >> $logfile
89d5dfd5 70}
51133a7d
FB
71
72echo "ffmpeg regression test" > $logfile
73echo "ffmpeg benchmarks" > $benchfile
74
75###################################
76if [ -n "$do_mpeg" ] ; then
77# mpeg1 encoding
78file=${outfile}mpeg1.mpg
89d5dfd5 79do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
51133a7d
FB
80
81# mpeg1 decoding
89d5dfd5 82do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
51133a7d
FB
83
84# mpeg2 decoding
85#do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
86# -f rawvideo /tmp/out-mpeg2.yuv
87fi
88
89###################################
6ebd933b
MN
90if [ -n "$do_msmpeg4v2" ] ; then
91# msmpeg4 encoding
92file=${outfile}msmpeg4v2.avi
93do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
94
95# msmpeg4v2 decoding
96do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
97fi
98
99###################################
51133a7d
FB
100if [ -n "$do_msmpeg4" ] ; then
101# msmpeg4 encoding
102file=${outfile}msmpeg4.avi
103do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
104
105# msmpeg4 decoding
106do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
107fi
108
109###################################
6ebd933b
MN
110if [ -n "$do_wmv1" ] ; then
111# wmv1 encoding
112file=${outfile}wmv1.avi
113do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
114
115# wmv1 decoding
116do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
117fi
118
119###################################
51133a7d
FB
120if [ -n "$do_h263" ] ; then
121# h263 encoding
122file=${outfile}h263.avi
123do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
124
6e2d5f1a
MN
125# h263 decoding
126do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
127fi
128
129###################################
130if [ -n "$do_h263p" ] ; then
131# h263p encoding
132file=${outfile}h263p.avi
133do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 1000 $file
134
51133a7d
FB
135# h263p decoding
136do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
137fi
138
139###################################
140if [ -n "$do_mpeg4" ] ; then
141# mpeg4
142file=${outfile}odivx.avi
143do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
144
145# mpeg4 decoding
146do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
147fi
148
149###################################
1dbb6d90
MN
150if [ -n "$do_rc" ] ; then
151# mpeg4 rate control
152file=${outfile}mpeg4-rc.avi
153do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
154
155# mpeg4 rate control decoding
156do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
157fi
158
159###################################
160if [ -n "$do_mpeg4adv" ] ; then
161# mpeg4
162file=${outfile}mpeg4-adv.avi
163do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 1000 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
164
165# mpeg4 decoding
166do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
167fi
168
169###################################
51133a7d
FB
170if [ -n "$do_mjpeg" ] ; then
171# mjpeg
172file=${outfile}mjpeg.avi
173do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
174
175# mjpeg decoding
176do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
177fi
178
179###################################
180if [ -n "$do_rv10" ] ; then
181# rv10 encoding
182file=${outfile}rv10.rm
183do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
184
185# rv10 decoding
186do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
187fi
188
189###################################
190if [ -n "$do_mp2" ] ; then
191# mp2 encoding
192file=${outfile}mp2.mp2
193do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
194
195# mp2 decoding
196do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
197fi
198
199###################################
200if [ -n "$do_ac3" ] ; then
201# ac3 encoding
202file=${outfile}ac3.rm
203do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
204
205# ac3 decoding
206do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
207fi
208
89d5dfd5
FB
209###################################
210# libav testing
211###################################
212
213if [ -n "$do_libav" ] ; then
214
215# avi
216file=${outfile}libav.avi
217do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
218do_ffmpeg_crc $file -i $file
219
220# asf
221file=${outfile}libav.asf
222do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
223do_ffmpeg_crc $file -i $file
224
225# rm
226file=${outfile}libav.rm
227do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
228# broken
229#do_ffmpeg_crc $file -i $file
230
231# mpegps
232file=${outfile}libav.mpg
233do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
234do_ffmpeg_crc $file -i $file
235
236# swf (decode audio only)
237file=${outfile}libav.swf
d0c30ca5
FB
238do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
239do_ffmpeg_crc $file -i $file
89d5dfd5
FB
240
241# ffm
242file=${outfile}libav.ffm
243do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
d0c30ca5 244do_ffmpeg_crc $file -i $file
89d5dfd5
FB
245
246# XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
247
248####################
249# streamed images
250# mjpeg
251file=${outfile}libav.mjpeg
252do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
d0c30ca5 253do_ffmpeg_crc $file -i $file
89d5dfd5
FB
254
255# pgmpipe
256file=${outfile}libav.pgmpipe
257do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f pgmpipe $file
258do_ffmpeg_crc $file -f pgmpipe -i $file
259
260# ppmpipe
261file=${outfile}libav.ppmpipe
262do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
263do_ffmpeg_crc $file -f ppmpipe -i $file
264
265# gif
266file=${outfile}libav.gif
267do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
268#do_ffmpeg_crc $file -f ppmpipe -i $file
269
270####################
271# image formats
272# pgm (we do not do md5 on image files yet)
273file=${outfile}libav%d.pgm
274$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
275do_ffmpeg_crc $file -i $file
276
277# ppm (we do not do md5 on image files yet)
278file=${outfile}libav%d.ppm
279$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
280do_ffmpeg_crc $file -i $file
281
d0c30ca5
FB
282# jpeg (we do not do md5 on image files yet)
283file=${outfile}libav%d.jpg
284$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
285do_ffmpeg_crc $file -i $file
286
89d5dfd5
FB
287####################
288# audio only
289
290# wav
291file=${outfile}libav.wav
292do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
293do_ffmpeg_crc $file -i $file
294
295# alaw
296file=${outfile}libav.al
297do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
298do_ffmpeg_crc $file -i $file
299
300# mulaw
301file=${outfile}libav.ul
302do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
303do_ffmpeg_crc $file -i $file
304
305# au
306file=${outfile}libav.au
307do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
308do_ffmpeg_crc $file -i $file
309
310fi
311
312
51133a7d
FB
313
314if diff -u $logfile $reffile ; then
315 echo
316 echo Regression test succeeded.
317 exit 0
318else
319 echo
320 echo Regression test: Error.
321 exit 1
322fi