]> git.sesse.net Git - ffmpeg/blob - tests/regression-funcs.sh
fate: allow specifying relative path to config file in fate.sh
[ffmpeg] / tests / regression-funcs.sh
1 #!/bin/sh
2 #
3 # common regression functions for ffmpeg
4 #
5 #
6
7 test="${1#regtest-}"
8 test_ref=$2
9 raw_src_dir=$3
10 target_exec=$4
11 target_path=$5
12
13 datadir="./tests/data"
14 target_datadir="${target_path}/${datadir}"
15
16 this="$test.$test_ref"
17 logdir="$datadir/regression/$test_ref"
18 logfile="$logdir/$test"
19 outfile="$datadir/$test_ref/"
20 errfile="$datadir/$this.err"
21
22 # various files
23 ffmpeg="$target_exec ${target_path}/ffmpeg"
24 tiny_psnr="tests/tiny_psnr"
25 benchfile="$datadir/$this.bench"
26 bench="$datadir/$this.bench.tmp"
27 bench2="$datadir/$this.bench2.tmp"
28 raw_src="${target_path}/$raw_src_dir/%02d.pgm"
29 raw_dst="$datadir/$this.out.yuv"
30 raw_ref="$datadir/$test_ref.ref.yuv"
31 pcm_src="$target_datadir/asynth1.sw"
32 pcm_dst="$datadir/$this.out.wav"
33 pcm_ref="$datadir/$test_ref.ref.wav"
34 crcfile="$datadir/$this.crc"
35 target_crcfile="$target_datadir/$this.crc"
36
37 cleanfiles="$raw_dst $pcm_dst $crcfile $bench $bench2"
38 trap 'rm -f -- $cleanfiles' EXIT
39
40 mkdir -p "$datadir"
41 mkdir -p "$outfile"
42 mkdir -p "$logdir"
43
44 [ "${V-0}" -gt 0 ] && echov=echo || echov=:
45 [ "${V-0}" -gt 1 ] || exec 2>$errfile
46
47 . $(dirname $0)/md5.sh
48
49 FFMPEG_OPTS="-v 0 -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact"
50
51 do_ffmpeg()
52 {
53     f="$1"
54     shift
55     set -- $* ${target_path}/$f
56     $echov $ffmpeg $FFMPEG_OPTS $*
57     $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
58     do_md5sum $f >> $logfile
59     if [ $f = $raw_dst ] ; then
60         $tiny_psnr $f $raw_ref >> $logfile
61     elif [ $f = $pcm_dst ] ; then
62         $tiny_psnr $f $pcm_ref 2 >> $logfile
63     else
64         wc -c $f >> $logfile
65     fi
66     expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
67     echo $(cat $bench2) $f >> $benchfile
68 }
69
70 do_ffmpeg_nomd5()
71 {
72     f="$1"
73     shift
74     set -- $* ${target_path}/$f
75     $echov $ffmpeg $FFMPEG_OPTS $*
76     $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
77     if [ $f = $raw_dst ] ; then
78         $tiny_psnr $f $raw_ref >> $logfile
79     elif [ $f = $pcm_dst ] ; then
80         $tiny_psnr $f $pcm_ref 2 >> $logfile
81     else
82         wc -c $f >> $logfile
83     fi
84     expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
85     echo $(cat $bench2) $f >> $benchfile
86 }
87
88 do_ffmpeg_crc()
89 {
90     f="$1"
91     shift
92     $echov $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
93     $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
94     echo "$f $(cat $crcfile)" >> $logfile
95 }
96
97 do_ffmpeg_nocheck()
98 {
99     f="$1"
100     shift
101     $echov $ffmpeg $FFMPEG_OPTS $*
102     $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
103     expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
104     echo $(cat $bench2) $f >> $benchfile
105 }
106
107 do_video_decoding()
108 {
109     do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2
110 }
111
112 do_video_encoding()
113 {
114     file=${outfile}$1
115     do_ffmpeg $file $2 -f image2 -vcodec pgmyuv -i $raw_src $3
116 }
117
118 do_audio_encoding()
119 {
120     file=${outfile}$1
121     do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $3
122 }
123
124 do_audio_decoding()
125 {
126     do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav
127 }