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