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