Statistics
| Branch: | Revision:

ffmpeg / tests / regression-funcs.sh @ cc3e2472

History | View | Annotate | Download (3.12 KB)

1 f94e56cf Stefano Sabatini
#!/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
outfile_prefix=$4
11
target_exec=$5
12
target_path=$6
13
14
datadir="./tests/data"
15
target_datadir="${target_path}/${datadir}"
16
17
this="$test.$test_ref"
18
logfile="$datadir/$this.regression"
19 cc3e2472 Måns Rullgård
outfile="$datadir/$test_ref/"
20 16cd99bb Måns Rullgård
errfile="$datadir/$this.err"
21 f94e56cf Stefano Sabatini
22
# various files
23 43cfefaf Måns Rullgård
ffmpeg="$target_exec ${target_path}/ffmpeg"
24 f94e56cf Stefano Sabatini
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 c676895f Måns Rullgård
mkdir -p "$datadir"
38 cc3e2472 Måns Rullgård
mkdir -p "$outfile"
39 c676895f Måns Rullgård
40 16cd99bb Måns Rullgård
[ "${V-0}" -gt 0 ] && echov=echo || echov=:
41
[ "${V-0}" -gt 1 ] || exec 2>$errfile
42
43 3d147064 Diego Biurrun
if [ X"$(echo | md5sum 2> /dev/null)" != X ]; then
44 f94e56cf Stefano Sabatini
    do_md5sum() { md5sum -b $1; }
45 3d147064 Diego Biurrun
elif [ X"$(echo | md5 2> /dev/null)" != X ]; then
46 f94e56cf Stefano Sabatini
    do_md5sum() { md5 $1 | sed 's#MD5 (\(.*\)) = \(.*\)#\2 *\1#'; }
47
elif [ -x /sbin/md5 ]; then
48
    do_md5sum() { /sbin/md5 -r $1 | sed 's# \**\./# *./#'; }
49
else
50
    do_md5sum() { echo No md5sum program found; }
51
fi
52
53
FFMPEG_OPTS="-v 0 -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact"
54
55
do_ffmpeg()
56
{
57
    f="$1"
58
    shift
59
    set -- $* ${target_path}/$f
60 16cd99bb Måns Rullgård
    $echov $ffmpeg $FFMPEG_OPTS $*
61 f94e56cf Stefano Sabatini
    $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
62
    do_md5sum $f >> $logfile
63
    if [ $f = $raw_dst ] ; then
64
        $tiny_psnr $f $raw_ref >> $logfile
65
    elif [ $f = $pcm_dst ] ; then
66
        $tiny_psnr $f $pcm_ref 2 >> $logfile
67
    else
68
        wc -c $f >> $logfile
69
    fi
70 3d147064 Diego Biurrun
    expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
71
    echo $(cat $bench2) $f >> $benchfile
72 f94e56cf Stefano Sabatini
}
73
74
do_ffmpeg_nomd5()
75
{
76
    f="$1"
77
    shift
78
    set -- $* ${target_path}/$f
79 16cd99bb Måns Rullgård
    $echov $ffmpeg $FFMPEG_OPTS $*
80 f94e56cf Stefano Sabatini
    $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
81
    if [ $f = $raw_dst ] ; then
82
        $tiny_psnr $f $raw_ref >> $logfile
83
    elif [ $f = $pcm_dst ] ; then
84
        $tiny_psnr $f $pcm_ref 2 >> $logfile
85
    else
86
        wc -c $f >> $logfile
87
    fi
88 3d147064 Diego Biurrun
    expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
89
    echo $(cat $bench2) $f >> $benchfile
90 f94e56cf Stefano Sabatini
}
91
92
do_ffmpeg_crc()
93
{
94
    f="$1"
95
    shift
96 16cd99bb Måns Rullgård
    $echov $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
97 f94e56cf Stefano Sabatini
    $ffmpeg $FFMPEG_OPTS $* -f crc "$target_crcfile"
98 3d147064 Diego Biurrun
    echo "$f $(cat $crcfile)" >> $logfile
99 f94e56cf Stefano Sabatini
    rm -f "$crcfile"
100
}
101
102
do_ffmpeg_nocheck()
103
{
104
    f="$1"
105
    shift
106 16cd99bb Måns Rullgård
    $echov $ffmpeg $FFMPEG_OPTS $*
107 f94e56cf Stefano Sabatini
    $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench
108 3d147064 Diego Biurrun
    expr "$(cat $bench)" : '.*utime=\(.*s\)' > $bench2
109
    echo $(cat $bench2) $f >> $benchfile
110 f94e56cf Stefano Sabatini
}
111
112
do_video_decoding()
113
{
114
    do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2
115
    rm -f $raw_dst
116
}
117
118
do_video_encoding()
119
{
120
    file=${outfile}$1
121
    do_ffmpeg $file $2 -f image2 -vcodec pgmyuv -i $raw_src $3
122
}
123
124
do_audio_encoding()
125
{
126
    file=${outfile}$1
127
    do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $3
128
}
129
130
do_audio_decoding()
131
{
132
    do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav
133
}