3ab118207c1e4eafb9399549c2ba9c589029af3f
[ffmpeg.git] / tests / lavfi-regression.sh
1 #!/bin/sh
2 #
3 # automatic regression test for libavfilter
4 #
5 #
6 #set -x
7
8 set -e
9
10 . $(dirname $0)/regression-funcs.sh
11
12 eval do_$test=y
13
14 rm -f "$logfile"
15 rm -f "$benchfile"
16
17 get_common_elements() (
18     l1=$1
19     l2=$2
20     for elt1 in $1; do
21         for elt2 in $2; do
22             [ $elt1 = $elt2 ] && res="$res $elt1 "
23         done
24     done
25
26     echo $res
27 )
28
29 do_lavfi() {
30     test_name=$1
31     eval test=\$do_$test_name
32     vfilters="slicify=random,$2"
33
34     if [ -n "$test" ] ; then
35         do_video_encoding ${test_name}.nut "" "-vcodec rawvideo -vf $vfilters"
36     fi
37 }
38
39 do_lavfi "crop"               "crop=100:100"
40 do_lavfi "crop_scale"         "crop=100:100,scale=400:-1"
41 do_lavfi "crop_scale_vflip"   "null,null,crop=200:200,crop=20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=100:100,vflip,scale=200:200,null,vflip,crop=100:100,null"
42 do_lavfi "crop_vflip"         "crop=100:100,vflip"
43 do_lavfi "null"               "null"
44 do_lavfi "scale200"           "scale=200:200"
45 do_lavfi "scale500"           "scale=500:500"
46 do_lavfi "vflip"              "vflip"
47 do_lavfi "vflip_crop"         "vflip,crop=100:100"
48 do_lavfi "vflip_vflip"        "vflip,vflip"
49
50 # all these filters have exactly one input and exactly one output
51 filters_args="
52 crop=100:100:100:100
53 null
54 pad=500:400:20:20
55 scale=200:100
56 vflip
57 "
58
59 if [ -n "$do_lavfi_pix_fmts" ]; then
60     scale_out_pix_fmts=$(tools/lavfi-showfiltfmts scale | grep "^OUTPUT" | cut -d: -f2)
61
62     for filter_args in $filters_args; do
63         filter=$(echo $filter_args | sed -e 's/\([^=]\+\)=.*/\1/')
64         in_pix_fmts=$(tools/lavfi-showfiltfmts $filter | grep "^INPUT" | cut -d: -f2)
65         pix_fmts=$(get_common_elements "$in_pix_fmts" "$scale_out_pix_fmts")
66
67         for pix_fmt in $pix_fmts; do
68             do_video_encoding "${pix_fmt}-${filter}.nut" "" \
69                 "-vf slicify=random,format=$pix_fmt,$filter_args -vcodec rawvideo -pix_fmt $pix_fmt"
70         done
71     done
72 fi
73
74 # TODO: add tests for
75 # direct rendering,
76 # chains with feedback loops
77
78 rm -f "$bench" "$bench2"