Rename function
[FFMpeg-mirror/DVCPRO-HD.git] / tests / regression.sh
blob3735e0a4598f2744ac63be4be59894f72525787f
1 #!/bin/sh
3 # automatic regression test for ffmpeg
6 #set -x
8 set -e
10 datadir="./tests/data"
12 test="${1#regtest-}"
13 this="$test.$2"
14 logfile="$datadir/$this.regression"
15 outfile="$datadir/$4-"
17 eval do_$test=y
19 # various files
20 ffmpeg="./ffmpeg_g"
21 tiny_psnr="tests/tiny_psnr"
22 benchfile="$datadir/$this.bench"
23 bench="$datadir/$this.bench.tmp"
24 bench2="$datadir/$this.bench2.tmp"
25 raw_src="$3/%02d.pgm"
26 raw_dst="$datadir/$this.out.yuv"
27 raw_ref="$datadir/$2.ref.yuv"
28 pcm_src="tests/asynth1.sw"
29 pcm_dst="$datadir/$this.out.wav"
30 pcm_ref="$datadir/$2.ref.wav"
31 crcfile="$datadir/$this.crc"
33 if [ X"`echo | md5sum 2> /dev/null`" != X ]; then
34 do_md5sum() { md5sum -b $1; }
35 elif [ -x /sbin/md5 ]; then
36 do_md5sum() { /sbin/md5 -r $1 | sed 's# \**\./# *./#'; }
37 else
38 do_md5sum() { echo No md5sum program found; }
41 # create the data directory if it does not exist
42 mkdir -p $datadir
44 FFMPEG_OPTS="-y -flags +bitexact -dct fastint -idct simple"
46 do_ffmpeg()
48 f="$1"
49 shift
50 echo $ffmpeg $FFMPEG_OPTS $*
51 $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
52 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
53 rm -f /tmp/ffmpeg$$
54 do_md5sum $f >> $logfile
55 if [ $f = $raw_dst ] ; then
56 $tiny_psnr $f $raw_ref >> $logfile
57 elif [ $f = $pcm_dst ] ; then
58 $tiny_psnr $f $pcm_ref 2 >> $logfile
59 else
60 wc -c $f >> $logfile
62 expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
63 echo `cat $bench2` $f >> $benchfile
66 do_ffmpeg_nomd5()
68 f="$1"
69 shift
70 echo $ffmpeg $FFMPEG_OPTS $*
71 $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
72 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
73 rm -f /tmp/ffmpeg$$
74 if [ $f = $raw_dst ] ; then
75 $tiny_psnr $f $raw_ref >> $logfile
76 elif [ $f = $pcm_dst ] ; then
77 $tiny_psnr $f $pcm_ref 2 >> $logfile
78 else
79 wc -c $f >> $logfile
81 expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
82 echo `cat $bench2` $f >> $benchfile
85 do_ffmpeg_crc()
87 f="$1"
88 shift
89 echo $ffmpeg $FFMPEG_OPTS $* -f crc "$crcfile"
90 $ffmpeg $FFMPEG_OPTS $* -f crc "$crcfile" > /tmp/ffmpeg$$ 2>&1
91 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:|ffmpeg version| configuration| built)" /tmp/ffmpeg$$ || true
92 rm -f /tmp/ffmpeg$$
93 echo "$f `cat $crcfile`" >> $logfile
94 rm -f "$crcfile"
97 do_ffmpeg_nocheck()
99 f="$1"
100 shift
101 echo $ffmpeg $FFMPEG_OPTS $*
102 $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
103 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
104 rm -f /tmp/ffmpeg$$
105 expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
106 echo `cat $bench2` $f >> $benchfile
109 do_video_decoding()
111 do_ffmpeg $raw_dst $1 -i $file -f rawvideo $2 $raw_dst
112 rm -f $raw_dst
115 do_video_encoding()
117 file=${outfile}$1
118 do_ffmpeg $file $2 -f image2 -vcodec pgmyuv -i $raw_src $3 $file
121 do_audio_encoding()
123 file=${outfile}$1
124 do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $3 $file
127 do_audio_decoding()
129 do_ffmpeg $pcm_dst -i $file -f wav $pcm_dst
132 do_libav()
134 file=${outfile}libav.$1
135 do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $2 $file
136 do_ffmpeg_crc $file -i $file $3
139 do_streamed_images()
141 file=${outfile}${1}pipe.$1
142 do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe $file
143 do_ffmpeg_crc $file -f image2pipe -i $file
146 do_image_formats()
148 file=${outfile}libav%02d.$1
149 $ffmpeg -t 0.5 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $2 $3 -flags +bitexact $file
150 do_md5sum ${outfile}libav02.$1 >> $logfile
151 do_ffmpeg_crc $file $3 -i $file
152 wc -c ${outfile}libav02.$1 >> $logfile
155 do_audio_only()
157 file=${outfile}libav.$1
158 do_ffmpeg $file -t 1 -qscale 10 -f s16le -i $pcm_src $file
159 do_ffmpeg_crc $file -i $file
162 rm -f "$logfile"
163 rm -f "$benchfile"
165 # generate reference for quality check
166 if [ -n "$do_ref" ]; then
167 do_ffmpeg_nocheck $raw_ref -f image2 -vcodec pgmyuv -i $raw_src -an -f rawvideo $raw_ref
168 do_ffmpeg_nocheck $pcm_ref -ab 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav $pcm_ref
171 if [ -n "$do_mpeg" ] ; then
172 # mpeg1
173 do_video_encoding mpeg1.mpg "-qscale 10" "-f mpeg1video"
174 do_video_decoding
177 if [ -n "$do_mpeg2" ] ; then
178 # mpeg2
179 do_video_encoding mpeg2.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video"
180 do_video_decoding
182 # mpeg2 encoding intra vlc qprd
183 do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -flags +trell+qprd+mv0 -flags2 +ivlc -cmp 2 -subcmp 2 -mbd rd" "-vcodec mpeg2video -f mpeg2video"
184 do_video_decoding
186 # mpeg2
187 do_video_encoding mpeg2.mpg "-qscale 10" "-vcodec mpeg2video -idct int -dct int -f mpeg1video"
188 do_video_decoding "-idct int"
190 # mpeg2 encoding interlaced
191 do_video_encoding mpeg2i.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video -flags +ildct+ilme"
192 do_video_decoding
195 if [ -n "$do_mpeg2thread" ] ; then
196 # mpeg2 encoding interlaced
197 do_video_encoding mpeg2thread.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2"
198 do_video_decoding
200 # mpeg2 encoding interlaced using intra vlc
201 do_video_encoding mpeg2threadivlc.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2"
202 do_video_decoding
204 # mpeg2 encoding interlaced
205 file=${outfile}mpeg2reuse.mpg
206 do_ffmpeg $file -sameq -me_threshold 256 -mb_threshold 1024 -i ${outfile}mpeg2thread.mpg -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 $file
207 do_video_decoding
210 if [ -n "$do_msmpeg4v2" ] ; then
211 do_video_encoding msmpeg4v2.avi "-qscale 10" "-an -vcodec msmpeg4v2"
212 do_video_decoding
215 if [ -n "$do_msmpeg4" ] ; then
216 do_video_encoding msmpeg4.avi "-qscale 10" "-an -vcodec msmpeg4"
217 do_video_decoding
220 if [ -n "$do_wmv1" ] ; then
221 do_video_encoding wmv1.avi "-qscale 10" "-an -vcodec wmv1"
222 do_video_decoding
225 if [ -n "$do_wmv2" ] ; then
226 do_video_encoding wmv2.avi "-qscale 10" "-an -vcodec wmv2"
227 do_video_decoding
230 if [ -n "$do_h261" ] ; then
231 do_video_encoding h261.avi "-qscale 11" "-s 352x288 -an -vcodec h261"
232 do_video_decoding
235 if [ -n "$do_h263" ] ; then
236 do_video_encoding h263.avi "-qscale 10" "-s 352x288 -an -vcodec h263"
237 do_video_decoding
240 if [ -n "$do_h263p" ] ; then
241 do_video_encoding h263p.avi "-qscale 2 -flags +umv+aiv+aic" "-s 352x288 -an -vcodec h263p -ps 300"
242 do_video_decoding
245 if [ -n "$do_mpeg4" ] ; then
246 do_video_encoding odivx.mp4 "-flags +mv4 -mbd bits -qscale 10" "-an -vcodec mpeg4"
247 do_video_decoding
250 if [ -n "$do_huffyuv" ] ; then
251 do_video_encoding huffyuv.avi "" "-an -vcodec huffyuv -pix_fmt yuv422p"
252 do_video_decoding "" "-strict -2 -pix_fmt yuv420p"
255 if [ -n "$do_rc" ] ; then
256 do_video_encoding mpeg4-rc.avi "-b 400k -bf 2" "-an -vcodec mpeg4"
257 do_video_decoding
260 if [ -n "$do_mpeg4adv" ] ; then
261 do_video_encoding mpeg4-adv.avi "-qscale 9 -flags +mv4+part+aic+trell -mbd bits -ps 200" "-an -vcodec mpeg4"
262 do_video_decoding
264 do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -flags +mv4+trell+qprd+mv0 -cmp 2 -subcmp 2 -mbd rd" "-an -vcodec mpeg4"
265 do_video_decoding
267 do_video_encoding mpeg4-adap.avi "-b 550k -bf 2 -flags +mv4+trell+mv0 -cmp 1 -subcmp 2 -mbd rd -scplx_mask 0.3" "-an -vcodec mpeg4"
268 do_video_decoding
270 do_video_encoding mpeg4-Q.avi "-qscale 7 -flags +mv4+qpel -mbd 2 -bf 2 -cmp 1 -subcmp 2" "-an -vcodec mpeg4"
271 do_video_decoding
274 if [ -n "$do_mpeg4thread" ] ; then
275 do_video_encoding mpeg4-thread.avi "-b 500k -flags +mv4+part+aic+trell -mbd bits -ps 200 -bf 2" "-an -vcodec mpeg4 -threads 2"
276 do_video_decoding
279 if [ -n "$do_error" ] ; then
280 do_video_encoding error-mpeg4-adv.avi "-qscale 7 -flags +mv4+part+aic -mbd rd -ps 250 -error 10" "-an -vcodec mpeg4"
281 do_video_decoding
284 if [ -n "$do_mpeg4nr" ] ; then
285 do_video_encoding mpeg4-nr.avi "-qscale 8 -flags +mv4 -mbd rd -nr 200" "-an -vcodec mpeg4"
286 do_video_decoding
289 if [ -n "$do_mpeg1b" ] ; then
290 do_video_encoding mpeg1b.mpg "-qscale 8 -bf 3 -ps 200" "-an -vcodec mpeg1video -f mpeg1video"
291 do_video_decoding
294 if [ -n "$do_mjpeg" ] ; then
295 do_video_encoding mjpeg.avi "-qscale 10" "-an -vcodec mjpeg -pix_fmt yuvj420p"
296 do_video_decoding "" "-pix_fmt yuv420p"
299 if [ -n "$do_ljpeg" ] ; then
300 do_video_encoding ljpeg.avi "" "-an -vcodec ljpeg -strict -1"
301 do_video_decoding
304 if [ -n "$do_jpegls" ] ; then
305 do_video_encoding jpegls.avi "" "-an -vcodec jpegls -vtag MJPG"
306 do_video_decoding "" "-pix_fmt yuv420p"
309 if [ -n "$do_rv10" ] ; then
310 do_video_encoding rv10.rm "-qscale 10" "-an"
311 do_video_decoding
314 if [ -n "$do_rv20" ] ; then
315 do_video_encoding rv20.rm "-qscale 10" "-vcodec rv20 -an"
316 do_video_decoding
319 if [ -n "$do_asv1" ] ; then
320 do_video_encoding asv1.avi "-qscale 10" "-an -vcodec asv1"
321 do_video_decoding
324 if [ -n "$do_asv2" ] ; then
325 do_video_encoding asv2.avi "-qscale 10" "-an -vcodec asv2"
326 do_video_decoding
329 if [ -n "$do_flv" ] ; then
330 do_video_encoding flv.flv "-qscale 10" "-an -vcodec flv"
331 do_video_decoding
334 if [ -n "$do_ffv1" ] ; then
335 do_video_encoding ffv1.avi "-strict -2" "-an -vcodec ffv1"
336 do_video_decoding
339 if [ -n "$do_snow" ] ; then
340 do_video_encoding snow.avi "-strict -2" "-an -vcodec snow -qscale 2 -flags +qpel -me iter -dia_size 2 -cmp 12 -subcmp 12 -s 128x64"
341 do_video_decoding "" "-s 352x288"
344 if [ -n "$do_snowll" ] ; then
345 do_video_encoding snow53.avi "-strict -2" "-an -vcodec snow -qscale .001 -pred 1 -flags +mv4+qpel"
346 do_video_decoding
349 if [ -n "$do_dv" ] ; then
350 do_video_encoding dv.dv "-dct int" "-s pal -an"
351 do_video_decoding "" "-s cif"
354 if [ -n "$do_dv50" ] ; then
355 do_video_encoding dv50.dv "-dct int" "-s pal -pix_fmt yuv422p -an"
356 do_video_decoding "" "-s cif -pix_fmt yuv420p"
359 if [ -n "$do_svq1" ] ; then
360 do_video_encoding svq1.mov "" "-an -vcodec svq1 -qscale 3 -pix_fmt yuv410p"
361 do_video_decoding "" "-pix_fmt yuv420p"
364 if [ -n "$do_flashsv" ] ; then
365 do_video_encoding flashsv.flv "" "-an -vcodec flashsv "
366 do_video_decoding "" "-pix_fmt yuv420p"
369 if [ -n "$do_mp2" ] ; then
370 do_audio_encoding mp2.mp2 "-ar 44100"
371 do_audio_decoding
372 $tiny_psnr $pcm_dst $pcm_ref 2 1924 >> $logfile
375 if [ -n "$do_ac3" ] ; then
376 do_audio_encoding ac3.rm "" -vn
377 #do_audio_decoding
380 if [ -n "$do_g726" ] ; then
381 do_audio_encoding g726.wav "-ar 44100" "-ab 32k -ac 1 -ar 8000 -acodec g726"
382 do_audio_decoding
385 if [ -n "$do_adpcm_ima_wav" ] ; then
386 do_audio_encoding adpcm_ima.wav "-ar 44100" "-acodec adpcm_ima_wav"
387 do_audio_decoding
390 if [ -n "$do_adpcm_ima_qt" ] ; then
391 do_audio_encoding adpcm_qt.aiff "-ar 44100" "-acodec adpcm_ima_qt"
392 do_audio_decoding
395 if [ -n "$do_adpcm_ms" ] ; then
396 do_audio_encoding adpcm_ms.wav "-ar 44100" "-acodec adpcm_ms"
397 do_audio_decoding
400 if [ -n "$do_adpcm_yam" ] ; then
401 do_audio_encoding adpcm_yam.wav "-ar 44100" "-acodec adpcm_yamaha"
402 do_audio_decoding
405 if [ -n "$do_adpcm_swf" ] ; then
406 do_audio_encoding adpcm_swf.flv "-ar 44100" "-acodec adpcm_swf"
407 do_audio_decoding
410 if [ -n "$do_flac" ] ; then
411 do_audio_encoding flac.flac "-ar 44100" "-acodec flac -compression_level 2"
412 do_audio_decoding
415 if [ -n "$do_wma" ] ; then
416 # wmav1
417 do_audio_encoding wmav1.asf "-ar 44100" "-acodec wmav1"
418 do_ffmpeg_nomd5 $pcm_dst -i $file -f wav $pcm_dst
419 $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
420 # wmav2
421 do_audio_encoding wmav2.asf "-ar 44100" "-acodec wmav2"
422 do_ffmpeg_nomd5 $pcm_dst -i $file -f wav $pcm_dst
423 $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
426 #if [ -n "$do_vorbis" ] ; then
427 # vorbis
428 #disabled because it is broken
429 #do_audio_encoding vorbis.asf "-ar 44100" "-acodec vorbis"
430 #do_audio_decoding
433 # libavformat testing
435 if [ -n "$do_avi" ] ; then
436 do_libav avi
439 if [ -n "$do_asf" ] ; then
440 do_libav asf "-acodec mp2" "-r 25"
443 if [ -n "$do_rm" ] ; then
444 file=${outfile}libav.rm
445 do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $file
446 # broken
447 #do_ffmpeg_crc $file -i $file
450 if [ -n "$do_mpg" ] ; then
451 do_libav mpg
454 if [ -n "$do_ts" ] ; then
455 do_libav ts
458 if [ -n "$do_swf" ] ; then
459 do_libav swf -an
462 if [ -n "$do_ffm" ] ; then
463 do_libav ffm
466 if [ -n "$do_flv_fmt" ] ; then
467 do_libav flv -an
470 if [ -n "$do_mov" ] ; then
471 do_libav mov "-acodec pcm_alaw"
474 if [ -n "$do_dv_fmt" ] ; then
475 do_libav dv "-ar 48000 -r 25 -s pal -ac 2"
478 if [ -n "$do_gxf" ] ; then
479 do_libav gxf "-ar 48000 -r 25 -s pal -ac 1"
482 if [ -n "$do_nut" ] ; then
483 do_libav nut "-acodec mp2"
486 if [ -n "$do_mkv" ] ; then
487 do_libav mkv
491 # streamed images
492 # mjpeg
493 #file=${outfile}libav.mjpeg
494 #do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $file
495 #do_ffmpeg_crc $file -i $file
497 if [ -n "$do_pbmpipe" ] ; then
498 do_streamed_images pbm
501 if [ -n "$do_pgmpipe" ] ; then
502 do_streamed_images pgm
505 if [ -n "$do_ppmpipe" ] ; then
506 do_streamed_images ppm
509 if [ -n "$do_gif" ] ; then
510 file=${outfile}libav.gif
511 do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -pix_fmt rgb24 $file
512 #do_ffmpeg_crc $file -i $file
515 if [ -n "$do_yuv4mpeg" ] ; then
516 file=${outfile}libav.y4m
517 do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $file
518 #do_ffmpeg_crc $file -i $file
521 # image formats
523 if [ -n "$do_pgm" ] ; then
524 do_image_formats pgm
527 if [ -n "$do_ppm" ] ; then
528 do_image_formats ppm
531 if [ -n "$do_bmp" ] ; then
532 do_image_formats bmp
535 if [ -n "$do_tga" ] ; then
536 do_image_formats tga
539 if [ -n "$do_tiff" ] ; then
540 do_image_formats tiff "-pix_fmt rgb24"
543 if [ -n "$do_sgi" ] ; then
544 do_image_formats sgi
547 if [ -n "$do_jpg" ] ; then
548 do_image_formats jpg "-flags +bitexact -dct fastint -idct simple -pix_fmt yuvj420p" "-f image2"
551 # audio only
553 if [ -n "$do_wav" ] ; then
554 do_audio_only wav
557 if [ -n "$do_alaw" ] ; then
558 do_audio_only al
561 if [ -n "$do_mulaw" ] ; then
562 do_audio_only ul
565 if [ -n "$do_au" ] ; then
566 do_audio_only au
569 if [ -n "$do_mmf" ] ; then
570 do_audio_only mmf
573 if [ -n "$do_aiff" ] ; then
574 do_audio_only aif
577 if [ -n "$do_voc" ] ; then
578 do_audio_only voc
581 if [ -n "$do_ogg" ] ; then
582 do_audio_only ogg
585 # pix_fmt conversions
587 if [ -n "$do_pixfmt" ] ; then
588 conversions="yuv420p yuv422p yuv444p yuyv422 yuv410p yuv411p yuvj420p \
589 yuvj422p yuvj444p rgb24 bgr24 rgb32 rgb565 rgb555 gray monow \
590 monob pal8 yuv440p yuvj440p"
591 for pix_fmt in $conversions ; do
592 file=${outfile}libav-${pix_fmt}.yuv
593 do_ffmpeg_nocheck $file -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \
594 -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
595 do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
596 -f rawvideo -s 352x288 -pix_fmt yuv444p $file
597 done
600 rm -f "$bench" "$bench2"