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