0c7d34bea332098417d2b402bb7d760e14bf42a2
[ffmpeg.git] / 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 threads=${6:-1}
13 cpuflags=${8:-all}
14 target_samples=$9
15
16 datadir="./tests/data"
17 target_datadir="${target_path}/${datadir}"
18
19 this="$test.$test_ref"
20 outfile="$datadir/$test_ref/"
21
22  # various files
23 ffmpeg="$target_exec ${target_path}/ffmpeg${PROGSUF}"
24 raw_src="${target_path}/$raw_src_dir/%02d.pgm"
25 raw_dst="$datadir/$this.out.yuv"
26 pcm_src="$target_datadir/asynth1.sw"
27 pcm_src_1ch="$target_datadir/asynth-16000-1.wav"
28 pcm_ref_1ch="$datadir/$test_ref-16000-1.ref.wav"
29 crcfile="$datadir/$this.crc"
30 target_crcfile="$target_datadir/$this.crc"
31
32 cleanfiles="$raw_dst $crcfile"
33 trap 'rm -f -- $cleanfiles' EXIT
34
35 mkdir -p "$datadir"
36 mkdir -p "$outfile"
37
38 [ "${V-0}" -gt 0 ] && echov=echov || echov=:
39
40 echov(){
41     echo "$@" >&3
42 }
43
44 . $(dirname $0)/md5.sh
45
46 AVCONV_OPTS="-nostdin -nostats -y -cpuflags $cpuflags"
47 COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
48 DEC_OPTS="$COMMON_OPTS -threads $threads"
49 ENC_OPTS="$COMMON_OPTS -threads $threads -dct fastint"
50
51 run_avconv()
52 {
53     $echov $ffmpeg $AVCONV_OPTS $*
54     $ffmpeg $AVCONV_OPTS $*
55 }
56
57 do_avconv()
58 {
59     f="$1"
60     shift
61     set -- $* ${target_path}/$f
62     run_avconv $*
63     do_md5sum $f
64     echo $(wc -c $f)
65 }
66
67 do_avconv_nomd5()
68 {
69     f="$1"
70     shift
71     set -- $* ${target_path}/$f
72     run_avconv $*
73     if [ $f = $raw_dst ] ; then
74         $tiny_psnr $f $raw_ref
75     elif [ $f = $pcm_dst ] ; then
76         $tiny_psnr $f $pcm_ref 2
77     else
78         echo $(wc -c $f)
79     fi
80 }
81
82 do_avconv_crc()
83 {
84     f="$1"
85     shift
86     run_avconv $* -f crc "$target_crcfile"
87     echo "$f $(cat $crcfile)"
88 }