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