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