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