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