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