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