eb5dda18d5276b40e00d5dbd4687a63f77d26939
[libav.git] / tests / regression.sh
1 #!/bin/sh
2 #
3 # automatic regression test for ffmpeg
4 #
5 #
6 #set -x
7
8 set -e
9
10 datadir="./tests/data"
11
12 test="${1#regtest-}"
13 this="$test.$2"
14 logfile="$datadir/$this.regression"
15 outfile="$datadir/$4-"
16
17 eval do_$test=y
18
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"
32
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; }
39 fi
40
41 # create the data directory if it does not exist
42 mkdir -p $datadir
43
44 FFMPEG_OPTS="-y -flags +bitexact -dct fastint -idct simple"
45
46 do_ffmpeg()
47 {
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
61 fi
62 expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
63 echo `cat $bench2` $f >> $benchfile
64 }
65
66 do_ffmpeg_nomd5()
67 {
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
80 fi
81 expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
82 echo `cat $bench2` $f >> $benchfile
83 }
84
85 do_ffmpeg_crc()
86 {
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"
95 }
96
97 do_ffmpeg_nocheck()
98 {
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
107 }
108
109 do_video_decoding()
110 {
111 do_ffmpeg $raw_dst -y $1 -i $file -f rawvideo $2 $raw_dst
112 rm -f $raw_dst
113 }
114
115 do_video_encoding()
116 {
117 file=${outfile}$1
118 do_ffmpeg $file -y $2 -f image2 -vcodec pgmyuv -i $raw_src $3 $file
119 }
120
121 do_audio_encoding()
122 {
123 file=${outfile}$1
124 do_ffmpeg $file -y -ab 128k -ac 2 -f s16le -i $pcm_src $3 $file
125 }
126
127 do_audio_decoding()
128 {
129 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
130 }
131
132 do_libav()
133 {
134 file=${outfile}libav.$1
135 do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $2 $file
136 do_ffmpeg_crc $file -i $file $3
137 }
138
139 do_streamed_images()
140 {
141 file=${outfile}${1}pipe.$1
142 do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe $file
143 do_ffmpeg_crc $file -f image2pipe -i $file
144 }
145
146 do_image_formats()
147 {
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
153 }
154
155 do_audio_only()
156 {
157 file=${outfile}libav.$1
158 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
159 do_ffmpeg_crc $file -i $file
160 }
161
162 rm -f "$logfile"
163 rm -f "$benchfile"
164
165 # generate reference for quality check
166 if [ -n "$do_ref" ]; then
167 do_ffmpeg_nocheck $raw_ref -y -f image2 -vcodec pgmyuv -i $raw_src -an -f rawvideo $raw_ref
168 do_ffmpeg_nocheck $pcm_ref -y -ab 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav $pcm_ref
169 fi
170
171 if [ -n "$do_mpeg" ] ; then
172 # mpeg1
173 do_video_encoding mpeg1.mpg "-qscale 10" "-f mpeg1video"
174 do_video_decoding
175 fi
176
177 if [ -n "$do_mpeg2" ] ; then
178 # mpeg2
179 do_video_encoding mpeg2.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video"
180 do_video_decoding
181
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
185
186 # mpeg2
187 do_video_encoding mpeg2.mpg "-qscale 10" "-vcodec mpeg2video -idct int -dct int -f mpeg1video"
188 do_video_decoding "-idct int"
189
190 # mpeg2 encoding interlaced
191 do_video_encoding mpeg2i.mpg "-qscale 10" "-vcodec mpeg2video -f mpeg1video -flags +ildct+ilme"
192 do_video_decoding
193 fi
194
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
199
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
203
204 # mpeg2 encoding interlaced
205 file=${outfile}mpeg2reuse.mpg
206 do_ffmpeg $file -y -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
208 fi
209
210 if [ -n "$do_msmpeg4v2" ] ; then
211 do_video_encoding msmpeg4v2.avi "-qscale 10" "-an -vcodec msmpeg4v2"
212 do_video_decoding
213 fi
214
215 if [ -n "$do_msmpeg4" ] ; then
216 do_video_encoding msmpeg4.avi "-qscale 10" "-an -vcodec msmpeg4"
217 do_video_decoding
218 fi
219
220 if [ -n "$do_wmv1" ] ; then
221 do_video_encoding wmv1.avi "-qscale 10" "-an -vcodec wmv1"
222 do_video_decoding
223 fi
224
225 if [ -n "$do_wmv2" ] ; then
226 do_video_encoding wmv2.avi "-qscale 10" "-an -vcodec wmv2"
227 do_video_decoding
228 fi
229
230 if [ -n "$do_h261" ] ; then
231 do_video_encoding h261.avi "-qscale 11" "-s 352x288 -an -vcodec h261"
232 do_video_decoding
233 fi
234
235 if [ -n "$do_h263" ] ; then
236 do_video_encoding h263.avi "-qscale 10" "-s 352x288 -an -vcodec h263"
237 do_video_decoding
238 fi
239
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
243 fi
244
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
248 fi
249
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"
253 fi
254
255 if [ -n "$do_rc" ] ; then
256 do_video_encoding mpeg4-rc.avi "-b 400k -bf 2" "-an -vcodec mpeg4"
257 do_video_decoding
258 fi
259
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
263
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
266
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
269
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
272 fi
273
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
277 fi
278
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
282 fi
283
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
287 fi
288
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
292 fi
293
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"
297 fi
298
299 if [ -n "$do_ljpeg" ] ; then
300 do_video_encoding ljpeg.avi "" "-an -vcodec ljpeg -strict -1"
301 do_video_decoding
302 fi
303
304 if [ -n "$do_jpegls" ] ; then
305 do_video_encoding jpegls.avi "" "-an -vcodec jpegls -vtag MJPG"
306 do_video_decoding "" "-pix_fmt yuv420p"
307 fi
308
309 if [ -n "$do_rv10" ] ; then
310 do_video_encoding rv10.rm "-qscale 10" "-an"
311 do_video_decoding
312 fi
313
314 if [ -n "$do_rv20" ] ; then
315 do_video_encoding rv20.rm "-qscale 10" "-vcodec rv20 -an"
316 do_video_decoding
317 fi
318
319 if [ -n "$do_asv1" ] ; then
320 do_video_encoding asv1.avi "-qscale 10" "-an -vcodec asv1"
321 do_video_decoding
322 fi
323
324 if [ -n "$do_asv2" ] ; then
325 do_video_encoding asv2.avi "-qscale 10" "-an -vcodec asv2"
326 do_video_decoding
327 fi
328
329 if [ -n "$do_flv" ] ; then
330 do_video_encoding flv.flv "-qscale 10" "-an -vcodec flv"
331 do_video_decoding
332 fi
333
334 if [ -n "$do_ffv1" ] ; then
335 do_video_encoding ffv1.avi "-strict -2" "-an -vcodec ffv1"
336 do_video_decoding
337 fi
338
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"
342 fi
343
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
347 fi
348
349 if [ -n "$do_dv" ] ; then
350 do_video_encoding dv.dv "-dct int" "-s pal -an"
351 do_video_decoding "" "-s cif"
352 fi
353
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"
357 fi
358
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"
362 fi
363
364 if [ -n "$do_flashsv" ] ; then
365 do_video_encoding flashsv.flv "" "-an -vcodec flashsv "
366 do_video_decoding "" "-pix_fmt yuv420p"
367 fi
368
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
373 fi
374
375 if [ -n "$do_ac3" ] ; then
376 do_audio_encoding ac3.rm "" -vn
377 #do_audio_decoding
378 fi
379
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
383 fi
384
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
388 fi
389
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
393 fi
394
395 if [ -n "$do_adpcm_ms" ] ; then
396 do_audio_encoding adpcm_ms.wav "-ar 44100" "-acodec adpcm_ms"
397 do_audio_decoding
398 fi
399
400 if [ -n "$do_adpcm_yam" ] ; then
401 do_audio_encoding adpcm_yam.wav "-ar 44100" "-acodec adpcm_yamaha"
402 do_audio_decoding
403 fi
404
405 if [ -n "$do_adpcm_swf" ] ; then
406 do_audio_encoding adpcm_swf.flv "-ar 44100" "-acodec adpcm_swf"
407 do_audio_decoding
408 fi
409
410 if [ -n "$do_flac" ] ; then
411 do_audio_encoding flac.flac "-ar 44100" "-acodec flac -compression_level 2"
412 do_audio_decoding
413 fi
414
415 if [ -n "$do_wma" ] ; then
416 # wmav1
417 do_audio_encoding wmav1.asf "-ar 44100" "-acodec wmav1"
418 do_ffmpeg_nomd5 $pcm_dst -y -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 -y -i $file -f wav $pcm_dst
423 $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
424 fi
425
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
431 #fi
432
433 # libavformat testing
434
435 if [ -n "$do_avi" ] ; then
436 do_libav avi
437 fi
438
439 if [ -n "$do_asf" ] ; then
440 do_libav asf "-acodec mp2" "-r 25"
441 fi
442
443 if [ -n "$do_rm" ] ; then
444 file=${outfile}libav.rm
445 do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $file
446 # broken
447 #do_ffmpeg_crc $file -i $file
448 fi
449
450 if [ -n "$do_mpg" ] ; then
451 do_libav mpg
452 fi
453
454 if [ -n "$do_ts" ] ; then
455 do_libav ts
456 fi
457
458 if [ -n "$do_swf" ] ; then
459 do_libav swf -an
460 fi
461
462 if [ -n "$do_ffm" ] ; then
463 do_libav ffm
464 fi
465
466 if [ -n "$do_flv_fmt" ] ; then
467 do_libav flv -an
468 fi
469
470 if [ -n "$do_mov" ] ; then
471 do_libav mov "-acodec pcm_alaw"
472 fi
473
474 if [ -n "$do_dv_fmt" ] ; then
475 do_libav dv "-ar 48000 -r 25 -s pal -ac 2"
476 fi
477
478 if [ -n "$do_gxf" ] ; then
479 do_libav gxf "-ar 48000 -r 25 -s pal -ac 1"
480 fi
481
482 if [ -n "$do_nut" ] ; then
483 do_libav nut "-acodec mp2"
484 fi
485
486 if [ -n "$do_mkv" ] ; then
487 do_libav mkv
488 fi
489
490
491 # streamed images
492 # mjpeg
493 #file=${outfile}libav.mjpeg
494 #do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $file
495 #do_ffmpeg_crc $file -i $file
496
497 if [ -n "$do_pbmpipe" ] ; then
498 do_streamed_images pbm
499 fi
500
501 if [ -n "$do_pgmpipe" ] ; then
502 do_streamed_images pgm
503 fi
504
505 if [ -n "$do_ppmpipe" ] ; then
506 do_streamed_images ppm
507 fi
508
509 if [ -n "$do_gif" ] ; then
510 file=${outfile}libav.gif
511 do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -pix_fmt rgb24 $file
512 #do_ffmpeg_crc $file -i $file
513 fi
514
515 if [ -n "$do_yuv4mpeg" ] ; then
516 file=${outfile}libav.y4m
517 do_ffmpeg $file -t 1 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $file
518 #do_ffmpeg_crc $file -i $file
519 fi
520
521 # image formats
522
523 if [ -n "$do_pgm" ] ; then
524 do_image_formats pgm
525 fi
526
527 if [ -n "$do_ppm" ] ; then
528 do_image_formats ppm
529 fi
530
531 if [ -n "$do_bmp" ] ; then
532 do_image_formats bmp
533 fi
534
535 if [ -n "$do_tga" ] ; then
536 do_image_formats tga
537 fi
538
539 if [ -n "$do_tiff" ] ; then
540 do_image_formats tiff "-pix_fmt rgb24"
541 fi
542
543 if [ -n "$do_sgi" ] ; then
544 do_image_formats sgi
545 fi
546
547 if [ -n "$do_jpg" ] ; then
548 do_image_formats jpg "-flags +bitexact -dct fastint -idct simple -pix_fmt yuvj420p" "-f image2"
549 fi
550
551 # audio only
552
553 if [ -n "$do_wav" ] ; then
554 do_audio_only wav
555 fi
556
557 if [ -n "$do_alaw" ] ; then
558 do_audio_only al
559 fi
560
561 if [ -n "$do_mulaw" ] ; then
562 do_audio_only ul
563 fi
564
565 if [ -n "$do_au" ] ; then
566 do_audio_only au
567 fi
568
569 if [ -n "$do_mmf" ] ; then
570 do_audio_only mmf
571 fi
572
573 if [ -n "$do_aiff" ] ; then
574 do_audio_only aif
575 fi
576
577 if [ -n "$do_voc" ] ; then
578 do_audio_only voc
579 fi
580
581 if [ -n "$do_ogg" ] ; then
582 do_audio_only ogg
583 fi
584
585 # pix_fmt conversions
586
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 -y -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
598 fi
599
600 rm -f "$bench" "$bench2"