cygwin patch by (Felix Buenemann <atmosfear at users dot sourceforge dot net>)
[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
89d5dfd5
FB
18elif [ "$1" = "libavtest" ] ; then
19 do_libav=y
5bcfd1ad 20 logfile="$datadir/libav.regression"
51133a7d
FB
21else
22 do_mpeg=y
23 do_msmpeg4=y
24 do_h263=y
25 do_mpeg4=y
26 do_mjpeg=y
89d5dfd5 27 #do_rv10=y #broken
51133a7d
FB
28 do_mp2=y
29 do_ac3=y
30fi
31
32
33# various files
34ffmpeg="../ffmpeg"
5bcfd1ad 35outfile="$datadir/a-"
51133a7d 36reffile="$2"
5bcfd1ad 37benchfile="$datadir/ffmpeg.bench"
51133a7d 38raw_src="vsynth1/%d.pgm"
5bcfd1ad 39raw_dst="$datadir/out.yuv"
51133a7d 40pcm_src="asynth1.sw"
5bcfd1ad
FB
41pcm_dst="$datadir/out.wav"
42
43# create the data directory if it does not exists
44mkdir -p $datadir
51133a7d 45
3f027ca7 46do_ffmpeg()
51133a7d
FB
47{
48 f="$1"
49 shift
89d5dfd5 50 echo $ffmpeg -bitexact $*
5bcfd1ad 51 $ffmpeg -bitexact -benchmark $* > $datadir/bench.tmp
3f027ca7 52 md5sum -b $f >> $logfile
90cee0c3 53 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
5bcfd1ad 54 echo `cat $datadir/bench2.tmp` $f >> $benchfile
51133a7d
FB
55}
56
3f027ca7 57do_ffmpeg_crc()
89d5dfd5
FB
58{
59 f="$1"
60 shift
5bcfd1ad
FB
61 echo $ffmpeg -y -bitexact $* -f crc $datadir/ffmpeg.crc
62 $ffmpeg -y -bitexact $* -f crc $datadir/ffmpeg.crc
89d5dfd5 63 echo -n "$f " >> $logfile
5bcfd1ad 64 cat $datadir/ffmpeg.crc >> $logfile
89d5dfd5 65}
51133a7d
FB
66
67echo "ffmpeg regression test" > $logfile
68echo "ffmpeg benchmarks" > $benchfile
69
70###################################
71if [ -n "$do_mpeg" ] ; then
72# mpeg1 encoding
73file=${outfile}mpeg1.mpg
89d5dfd5 74do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
51133a7d
FB
75
76# mpeg1 decoding
89d5dfd5 77do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
51133a7d
FB
78
79# mpeg2 decoding
80#do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
81# -f rawvideo /tmp/out-mpeg2.yuv
82fi
83
84###################################
85if [ -n "$do_msmpeg4" ] ; then
86# msmpeg4 encoding
87file=${outfile}msmpeg4.avi
88do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
89
90# msmpeg4 decoding
91do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
92fi
93
94###################################
95if [ -n "$do_h263" ] ; then
96# h263 encoding
97file=${outfile}h263.avi
98do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
99
100# h263p decoding
101do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
102fi
103
104###################################
105if [ -n "$do_mpeg4" ] ; then
106# mpeg4
107file=${outfile}odivx.avi
108do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
109
110# mpeg4 decoding
111do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
112fi
113
114###################################
115if [ -n "$do_mjpeg" ] ; then
116# mjpeg
117file=${outfile}mjpeg.avi
118do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
119
120# mjpeg decoding
121do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
122fi
123
124###################################
125if [ -n "$do_rv10" ] ; then
126# rv10 encoding
127file=${outfile}rv10.rm
128do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
129
130# rv10 decoding
131do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
132fi
133
134###################################
135if [ -n "$do_mp2" ] ; then
136# mp2 encoding
137file=${outfile}mp2.mp2
138do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
139
140# mp2 decoding
141do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
142fi
143
144###################################
145if [ -n "$do_ac3" ] ; then
146# ac3 encoding
147file=${outfile}ac3.rm
148do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
149
150# ac3 decoding
151do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
152fi
153
89d5dfd5
FB
154###################################
155# libav testing
156###################################
157
158if [ -n "$do_libav" ] ; then
159
160# avi
161file=${outfile}libav.avi
162do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
163do_ffmpeg_crc $file -i $file
164
165# asf
166file=${outfile}libav.asf
167do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
168do_ffmpeg_crc $file -i $file
169
170# rm
171file=${outfile}libav.rm
172do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
173# broken
174#do_ffmpeg_crc $file -i $file
175
176# mpegps
177file=${outfile}libav.mpg
178do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
179do_ffmpeg_crc $file -i $file
180
181# swf (decode audio only)
182file=${outfile}libav.swf
d0c30ca5
FB
183do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
184do_ffmpeg_crc $file -i $file
89d5dfd5
FB
185
186# ffm
187file=${outfile}libav.ffm
188do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
d0c30ca5 189do_ffmpeg_crc $file -i $file
89d5dfd5
FB
190
191# XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
192
193####################
194# streamed images
195# mjpeg
196file=${outfile}libav.mjpeg
197do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
d0c30ca5 198do_ffmpeg_crc $file -i $file
89d5dfd5
FB
199
200# pgmpipe
201file=${outfile}libav.pgmpipe
202do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f pgmpipe $file
203do_ffmpeg_crc $file -f pgmpipe -i $file
204
205# ppmpipe
206file=${outfile}libav.ppmpipe
207do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
208do_ffmpeg_crc $file -f ppmpipe -i $file
209
210# gif
211file=${outfile}libav.gif
212do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
213#do_ffmpeg_crc $file -f ppmpipe -i $file
214
215####################
216# image formats
217# pgm (we do not do md5 on image files yet)
218file=${outfile}libav%d.pgm
219$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
220do_ffmpeg_crc $file -i $file
221
222# ppm (we do not do md5 on image files yet)
223file=${outfile}libav%d.ppm
224$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
225do_ffmpeg_crc $file -i $file
226
d0c30ca5
FB
227# jpeg (we do not do md5 on image files yet)
228file=${outfile}libav%d.jpg
229$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
230do_ffmpeg_crc $file -i $file
231
89d5dfd5
FB
232####################
233# audio only
234
235# wav
236file=${outfile}libav.wav
237do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
238do_ffmpeg_crc $file -i $file
239
240# alaw
241file=${outfile}libav.al
242do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
243do_ffmpeg_crc $file -i $file
244
245# mulaw
246file=${outfile}libav.ul
247do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
248do_ffmpeg_crc $file -i $file
249
250# au
251file=${outfile}libav.au
252do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
253do_ffmpeg_crc $file -i $file
254
255fi
256
257
51133a7d
FB
258
259if diff -u $logfile $reffile ; then
260 echo
261 echo Regression test succeeded.
262 exit 0
263else
264 echo
265 echo Regression test: Error.
266 exit 1
267fi