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