fate: simplify variable setting filter.mak
[ffmpeg.git] / tests / regression-funcs.sh
1 #!/bin/sh
2 #
3 # common regression functions for avconv
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 threads=${6:-1}
13 cpuflags=${8:-all}
14
15 datadir="./tests/data"
16 target_datadir="${target_path}/${datadir}"
17
18 this="$test.$test_ref"
19 outfile="$datadir/$test_ref/"
20
21 # various files
22 avconv="$target_exec ${target_path}/avconv"
23 raw_src="${target_path}/$raw_src_dir/%02d.pgm"
24 raw_dst="$datadir/$this.out.yuv"
25 pcm_src="$target_datadir/asynth1.sw"
26 crcfile="$datadir/$this.crc"
27 target_crcfile="$target_datadir/$this.crc"
28
29 cleanfiles="$raw_dst $crcfile"
30 trap 'rm -f -- $cleanfiles' EXIT
31
32 mkdir -p "$datadir"
33 mkdir -p "$outfile"
34
35 [ "${V-0}" -gt 0 ] && echov=echov || echov=:
36
37 echov(){
38     echo "$@" >&3
39 }
40
41 . $(dirname $0)/md5.sh
42
43 AVCONV_OPTS="-nostats -y -cpuflags $cpuflags"
44 COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact"
45 DEC_OPTS="$COMMON_OPTS -threads $threads"
46 ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
47
48 run_avconv()
49 {
50     $echov $avconv $AVCONV_OPTS $*
51     $avconv $AVCONV_OPTS $*
52 }
53
54 do_avconv()
55 {
56     f="$1"
57     shift
58     set -- $* ${target_path}/$f
59     run_avconv $*
60     do_md5sum $f
61     echo $(wc -c $f)
62 }
63
64 do_avconv_crc()
65 {
66     f="$1"
67     shift
68     run_avconv $* -f crc "$target_crcfile"
69     echo "$f $(cat $crcfile)"
70 }