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