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