added first version of regression tests - simply type 'make test' to test every codec...
[libav.git] / tests / regression.sh
CommitLineData
51133a7d
FB
1#!/bin/sh
2#
3# automatic regression test for ffmpeg
4#
5#
6#set -x
7set -e
8
9# tests to do
10if [ "$1" = "mpeg4" ] ; then
11 do_mpeg4=y
12elif [ "$1" = "mpeg" ] ; then
13 do_mpeg=y
14else
15 do_mpeg=y
16 do_msmpeg4=y
17 do_h263=y
18 do_mpeg4=y
19 do_mjpeg=y
20 #do_rv10=y #broken!
21 do_mp2=y
22 do_ac3=y
23fi
24
25
26# various files
27ffmpeg="../ffmpeg"
28outfile="/tmp/a-"
29reffile="$2"
30logfile="/tmp/ffmpeg.regression"
31benchfile="/tmp/ffmpeg.bench"
32raw_src="vsynth1/%d.pgm"
33raw_dst="/tmp/out.yuv"
34pcm_src="asynth1.sw"
35pcm_dst="/tmp/out.wav"
36
37function do_ffmpeg ()
38{
39 f="$1"
40 shift
41 echo $ffmpeg $*
42 $ffmpeg -benchmark $* > /tmp/bench.tmp
43 md5sum $f >> $logfile
44 expr match "`cat /tmp/bench.tmp`" '.*utime=\(.*s\)' > /tmp/bench2.tmp
45 echo `cat /tmp/bench2.tmp` $f >> $benchfile
46}
47
48
49echo "ffmpeg regression test" > $logfile
50echo "ffmpeg benchmarks" > $benchfile
51
52###################################
53if [ -n "$do_mpeg" ] ; then
54# mpeg1 encoding
55file=${outfile}mpeg1.mpg
56do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpegvideo $file
57
58# mpeg1 decoding
59do_ffmpeg $raw_dst -y -f mpegvideo -i $file -f rawvideo $raw_dst
60
61# mpeg2 decoding
62#do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
63# -f rawvideo /tmp/out-mpeg2.yuv
64fi
65
66###################################
67if [ -n "$do_msmpeg4" ] ; then
68# msmpeg4 encoding
69file=${outfile}msmpeg4.avi
70do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
71
72# msmpeg4 decoding
73do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
74fi
75
76###################################
77if [ -n "$do_h263" ] ; then
78# h263 encoding
79file=${outfile}h263.avi
80do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
81
82# h263p decoding
83do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
84fi
85
86###################################
87if [ -n "$do_mpeg4" ] ; then
88# mpeg4
89file=${outfile}odivx.avi
90do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
91
92# mpeg4 decoding
93do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
94fi
95
96###################################
97if [ -n "$do_mjpeg" ] ; then
98# mjpeg
99file=${outfile}mjpeg.avi
100do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
101
102# mjpeg decoding
103do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
104fi
105
106###################################
107if [ -n "$do_rv10" ] ; then
108# rv10 encoding
109file=${outfile}rv10.rm
110do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
111
112# rv10 decoding
113do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
114fi
115
116###################################
117if [ -n "$do_mp2" ] ; then
118# mp2 encoding
119file=${outfile}mp2.mp2
120do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
121
122# mp2 decoding
123do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
124fi
125
126###################################
127if [ -n "$do_ac3" ] ; then
128# ac3 encoding
129file=${outfile}ac3.rm
130do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
131
132# ac3 decoding
133do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
134fi
135
136
137if diff -u $logfile $reffile ; then
138 echo
139 echo Regression test succeeded.
140 exit 0
141else
142 echo
143 echo Regression test: Error.
144 exit 1
145fi