os2 support patch by ("Slavik Gnatenko" <miracle9 at newmail dot ru>)
[libav.git] / tests / regression.sh
CommitLineData
51133a7d
FB
1#!/bin/sh
2#
3# automatic regression test for ffmpeg
4#
5#
6#set -x
7set -e
8
5bcfd1ad
FB
9datadir="./data"
10
11logfile="$datadir/ffmpeg.regression"
89d5dfd5 12
51133a7d
FB
13# tests to do
14if [ "$1" = "mpeg4" ] ; then
15 do_mpeg4=y
16elif [ "$1" = "mpeg" ] ; then
17 do_mpeg=y
7481e919
FB
18elif [ "$1" = "ac3" ] ; then
19 do_ac3=y
89d5dfd5
FB
20elif [ "$1" = "libavtest" ] ; then
21 do_libav=y
5bcfd1ad 22 logfile="$datadir/libav.regression"
51133a7d
FB
23else
24 do_mpeg=y
6ebd933b 25 do_msmpeg4v2=y
51133a7d 26 do_msmpeg4=y
6ebd933b 27 do_wmv1=y
51133a7d 28 do_h263=y
6e2d5f1a 29 do_h263p=y
51133a7d
FB
30 do_mpeg4=y
31 do_mjpeg=y
64a7a8af 32 do_rv10=y
51133a7d
FB
33 do_mp2=y
34 do_ac3=y
1dbb6d90
MN
35 do_rc=y
36 do_mpeg4adv=y
51133a7d
FB
37fi
38
39
40# various files
3aca208a 41ffmpeg="../ffmpeg_g"
5bcfd1ad 42outfile="$datadir/a-"
51133a7d 43reffile="$2"
5bcfd1ad 44benchfile="$datadir/ffmpeg.bench"
51133a7d 45raw_src="vsynth1/%d.pgm"
5bcfd1ad 46raw_dst="$datadir/out.yuv"
51133a7d 47pcm_src="asynth1.sw"
5bcfd1ad
FB
48pcm_dst="$datadir/out.wav"
49
50# create the data directory if it does not exists
51mkdir -p $datadir
51133a7d 52
3f027ca7 53do_ffmpeg()
51133a7d
FB
54{
55 f="$1"
56 shift
2ad1516a
MN
57 echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
58 $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp
3f027ca7 59 md5sum -b $f >> $logfile
90cee0c3 60 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
5bcfd1ad 61 echo `cat $datadir/bench2.tmp` $f >> $benchfile
51133a7d
FB
62}
63
3f027ca7 64do_ffmpeg_crc()
89d5dfd5
FB
65{
66 f="$1"
67 shift
2ad1516a
MN
68 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
69 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
89d5dfd5 70 echo -n "$f " >> $logfile
5bcfd1ad 71 cat $datadir/ffmpeg.crc >> $logfile
89d5dfd5 72}
51133a7d
FB
73
74echo "ffmpeg regression test" > $logfile
75echo "ffmpeg benchmarks" > $benchfile
76
77###################################
78if [ -n "$do_mpeg" ] ; then
79# mpeg1 encoding
80file=${outfile}mpeg1.mpg
89d5dfd5 81do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
51133a7d
FB
82
83# mpeg1 decoding
89d5dfd5 84do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
51133a7d
FB
85
86# mpeg2 decoding
87#do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
88# -f rawvideo /tmp/out-mpeg2.yuv
89fi
90
91###################################
6ebd933b
MN
92if [ -n "$do_msmpeg4v2" ] ; then
93# msmpeg4 encoding
94file=${outfile}msmpeg4v2.avi
95do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
96
97# msmpeg4v2 decoding
98do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
99fi
100
101###################################
51133a7d
FB
102if [ -n "$do_msmpeg4" ] ; then
103# msmpeg4 encoding
104file=${outfile}msmpeg4.avi
105do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
106
107# msmpeg4 decoding
108do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
109fi
110
111###################################
6ebd933b
MN
112if [ -n "$do_wmv1" ] ; then
113# wmv1 encoding
114file=${outfile}wmv1.avi
115do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
116
117# wmv1 decoding
118do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
119fi
120
121###################################
51133a7d
FB
122if [ -n "$do_h263" ] ; then
123# h263 encoding
124file=${outfile}h263.avi
125do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
126
6e2d5f1a
MN
127# h263 decoding
128do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
129fi
130
131###################################
132if [ -n "$do_h263p" ] ; then
133# h263p encoding
134file=${outfile}h263p.avi
135do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 1000 $file
136
51133a7d
FB
137# h263p decoding
138do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
139fi
140
141###################################
142if [ -n "$do_mpeg4" ] ; then
143# mpeg4
144file=${outfile}odivx.avi
145do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
146
147# mpeg4 decoding
148do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
149fi
150
151###################################
1dbb6d90
MN
152if [ -n "$do_rc" ] ; then
153# mpeg4 rate control
154file=${outfile}mpeg4-rc.avi
155do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
156
157# mpeg4 rate control decoding
158do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
159fi
160
161###################################
162if [ -n "$do_mpeg4adv" ] ; then
163# mpeg4
164file=${outfile}mpeg4-adv.avi
165do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 1000 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
166
167# mpeg4 decoding
168do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
169fi
170
171###################################
51133a7d
FB
172if [ -n "$do_mjpeg" ] ; then
173# mjpeg
174file=${outfile}mjpeg.avi
175do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
176
177# mjpeg decoding
178do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
179fi
180
181###################################
182if [ -n "$do_rv10" ] ; then
183# rv10 encoding
184file=${outfile}rv10.rm
185do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
186
187# rv10 decoding
188do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
189fi
190
191###################################
192if [ -n "$do_mp2" ] ; then
193# mp2 encoding
194file=${outfile}mp2.mp2
195do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
196
197# mp2 decoding
198do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
199fi
200
201###################################
202if [ -n "$do_ac3" ] ; then
203# ac3 encoding
204file=${outfile}ac3.rm
205do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
206
207# ac3 decoding
208do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
209fi
210
89d5dfd5
FB
211###################################
212# libav testing
213###################################
214
215if [ -n "$do_libav" ] ; then
216
217# avi
218file=${outfile}libav.avi
219do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
220do_ffmpeg_crc $file -i $file
221
222# asf
223file=${outfile}libav.asf
224do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
225do_ffmpeg_crc $file -i $file
226
227# rm
228file=${outfile}libav.rm
229do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
230# broken
231#do_ffmpeg_crc $file -i $file
232
233# mpegps
234file=${outfile}libav.mpg
235do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
236do_ffmpeg_crc $file -i $file
237
238# swf (decode audio only)
239file=${outfile}libav.swf
d0c30ca5
FB
240do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
241do_ffmpeg_crc $file -i $file
89d5dfd5
FB
242
243# ffm
244file=${outfile}libav.ffm
245do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
d0c30ca5 246do_ffmpeg_crc $file -i $file
89d5dfd5
FB
247
248# XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
249
250####################
251# streamed images
252# mjpeg
253file=${outfile}libav.mjpeg
254do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
d0c30ca5 255do_ffmpeg_crc $file -i $file
89d5dfd5 256
7481e919
FB
257# pbmpipe
258file=${outfile}libav.pbm
259do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
260do_ffmpeg_crc $file -f imagepipe -i $file
261
89d5dfd5 262# pgmpipe
7481e919
FB
263file=${outfile}libav.pgm
264do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
265do_ffmpeg_crc $file -f imagepipe -i $file
89d5dfd5
FB
266
267# ppmpipe
7481e919
FB
268file=${outfile}libav.ppm
269do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
270do_ffmpeg_crc $file -f imagepipe -i $file
89d5dfd5
FB
271
272# gif
273file=${outfile}libav.gif
7481e919
FB
274do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
275#do_ffmpeg_crc $file -i $file
276
277# yuv4mpeg
278file=${outfile}libav.yuv4mpeg
279do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
280#do_ffmpeg_crc $file -i $file
89d5dfd5
FB
281
282####################
283# image formats
284# pgm (we do not do md5 on image files yet)
285file=${outfile}libav%d.pgm
286$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
287do_ffmpeg_crc $file -i $file
288
289# ppm (we do not do md5 on image files yet)
290file=${outfile}libav%d.ppm
291$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
292do_ffmpeg_crc $file -i $file
293
d0c30ca5
FB
294# jpeg (we do not do md5 on image files yet)
295file=${outfile}libav%d.jpg
296$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
297do_ffmpeg_crc $file -i $file
298
89d5dfd5
FB
299####################
300# audio only
301
302# wav
303file=${outfile}libav.wav
304do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
305do_ffmpeg_crc $file -i $file
306
307# alaw
308file=${outfile}libav.al
309do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
310do_ffmpeg_crc $file -i $file
311
312# mulaw
313file=${outfile}libav.ul
314do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
315do_ffmpeg_crc $file -i $file
316
317# au
318file=${outfile}libav.au
319do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
320do_ffmpeg_crc $file -i $file
321
322fi
323
324
51133a7d
FB
325
326if diff -u $logfile $reffile ; then
327 echo
328 echo Regression test succeeded.
329 exit 0
330else
331 echo
332 echo Regression test: Error.
333 exit 1
334fi