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