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