4xm: remove unneeded check for remaining unused data.
[libav.git] / tests / regression-funcs.sh
CommitLineData
f94e56cf
SS
1#!/bin/sh
2#
6291d7e4 3# common regression functions for avconv
f94e56cf
SS
4#
5#
6
7test="${1#regtest-}"
8test_ref=$2
9raw_src_dir=$3
801b571e
MR
10target_exec=$4
11target_path=$5
7851eb68 12threads=${6:-1}
f94e56cf
SS
13
14datadir="./tests/data"
15target_datadir="${target_path}/${datadir}"
16
17this="$test.$test_ref"
cc3e2472 18outfile="$datadir/$test_ref/"
f94e56cf
SS
19
20# various files
6291d7e4 21avconv="$target_exec ${target_path}/avconv"
f94e56cf 22tiny_psnr="tests/tiny_psnr"
f94e56cf
SS
23raw_src="${target_path}/$raw_src_dir/%02d.pgm"
24raw_dst="$datadir/$this.out.yuv"
25raw_ref="$datadir/$test_ref.ref.yuv"
26pcm_src="$target_datadir/asynth1.sw"
27pcm_dst="$datadir/$this.out.wav"
28pcm_ref="$datadir/$test_ref.ref.wav"
29crcfile="$datadir/$this.crc"
30target_crcfile="$target_datadir/$this.crc"
31
d4a7df42 32cleanfiles="$raw_dst $pcm_dst $crcfile"
a4e6fa86
MR
33trap 'rm -f -- $cleanfiles' EXIT
34
c676895f 35mkdir -p "$datadir"
cc3e2472 36mkdir -p "$outfile"
c4795e80
MR
37
38[ "${V-0}" -gt 0 ] && echov=echov || echov=:
16cd99bb 39
c4795e80
MR
40echov(){
41 echo "$@" >&3
42}
43
fc8cb398 44. $(dirname $0)/md5.sh
f94e56cf 45
0836d48a 46AVCONV_OPTS="-nostats -y"
eeadaa6b
MR
47COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact"
48DEC_OPTS="$COMMON_OPTS -threads $threads"
6da57043 49ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
f94e56cf 50
6291d7e4 51run_avconv()
f4b1e21a 52{
6291d7e4
AK
53 $echov $avconv $AVCONV_OPTS $*
54 $avconv $AVCONV_OPTS $*
f4b1e21a
MR
55}
56
6291d7e4 57do_avconv()
f94e56cf
SS
58{
59 f="$1"
60 shift
61 set -- $* ${target_path}/$f
6291d7e4 62 run_avconv $*
ea57502c 63 do_md5sum $f
f94e56cf 64 if [ $f = $raw_dst ] ; then
ea57502c 65 $tiny_psnr $f $raw_ref
f94e56cf 66 elif [ $f = $pcm_dst ] ; then
ea57502c 67 $tiny_psnr $f $pcm_ref 2
f94e56cf 68 else
ea57502c 69 wc -c $f
f94e56cf 70 fi
f94e56cf
SS
71}
72
6291d7e4 73do_avconv_nomd5()
f94e56cf
SS
74{
75 f="$1"
76 shift
77 set -- $* ${target_path}/$f
6291d7e4 78 run_avconv $*
f94e56cf 79 if [ $f = $raw_dst ] ; then
ea57502c 80 $tiny_psnr $f $raw_ref
f94e56cf 81 elif [ $f = $pcm_dst ] ; then
ea57502c 82 $tiny_psnr $f $pcm_ref 2
f94e56cf 83 else
ea57502c 84 wc -c $f
f94e56cf 85 fi
f94e56cf
SS
86}
87
6291d7e4 88do_avconv_crc()
f94e56cf
SS
89{
90 f="$1"
91 shift
6291d7e4 92 run_avconv $* -f crc "$target_crcfile"
ea57502c 93 echo "$f $(cat $crcfile)"
f94e56cf
SS
94}
95
f94e56cf
SS
96do_video_decoding()
97{
6cd9d0f7 98 do_avconv $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS -vsync 0 $2
f94e56cf
SS
99}
100
101do_video_encoding()
102{
103 file=${outfile}$1
6291d7e4 104 do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2
f94e56cf
SS
105}
106
107do_audio_encoding()
108{
109 file=${outfile}$1
6291d7e4 110 do_avconv $file $DEC_OPTS -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2
f94e56cf
SS
111}
112
113do_audio_decoding()
114{
6cd9d0f7 115 do_avconv $pcm_dst $DEC_OPTS -i $target_path/$file -sample_fmt s16 -f wav
f94e56cf 116}