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