ffmpeg / tests / lavfi-regression.sh @ ce2e4ae3
History | View | Annotate | Download (3.2 KB)
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 |
for elt1 in $1; do |
19 |
for elt2 in $2; do |
20 |
[ $elt1 = $elt2 ] && res="$res $elt1 " |
21 |
done |
22 |
done |
23 |
|
24 |
echo $res |
25 |
) |
26 |
|
27 |
# Returns the elements present in $1 but not in $2. |
28 |
get_exclusive_elements() ( |
29 |
for elt1 in $1; do |
30 |
common="" |
31 |
for elt2 in $2; do |
32 |
[ $elt1 = $elt2 ] && common="true" && break; |
33 |
done |
34 |
[ -z "$common" ] && res="$res $elt1" |
35 |
done |
36 |
|
37 |
echo $res |
38 |
) |
39 |
|
40 |
do_lavfi() { |
41 |
test_name=$1 |
42 |
eval test=\$do_$test_name |
43 |
vfilters="slicify=random,$2" |
44 |
|
45 |
if [ -n "$test" ] ; then |
46 |
do_video_encoding ${test_name}.nut "" "-vcodec rawvideo -vf $vfilters" |
47 |
fi |
48 |
} |
49 |
|
50 |
do_lavfi "crop" "crop=100:100" |
51 |
do_lavfi "crop_scale" "crop=100:100,scale=400:-1" |
52 |
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" |
53 |
do_lavfi "crop_vflip" "crop=100:100,vflip" |
54 |
do_lavfi "null" "null" |
55 |
do_lavfi "scale200" "scale=200:200" |
56 |
do_lavfi "scale500" "scale=500:500" |
57 |
do_lavfi "vflip" "vflip" |
58 |
do_lavfi "vflip_crop" "vflip,crop=100:100" |
59 |
do_lavfi "vflip_vflip" "vflip,vflip" |
60 |
|
61 |
# all these filters have exactly one input and exactly one output |
62 |
filters_args=" |
63 |
crop=100:100:100:100 |
64 |
null |
65 |
pad=500:400:20:20 |
66 |
scale=200:100 |
67 |
vflip |
68 |
" |
69 |
|
70 |
if [ -n "$do_lavfi_pix_fmts" ]; then |
71 |
# exclude pixel formats which are not supported as input |
72 |
excluded_pix_fmts="$(ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^\..\.' | cut -d' ' -f2)" |
73 |
|
74 |
scale_out_pix_fmts=$(tools/lavfi-showfiltfmts scale | grep "^OUTPUT" | cut -d: -f2) |
75 |
scale_out_pix_fmts=$(get_exclusive_elements "$scale_out_pix_fmts" "$excluded_pix_fmts") |
76 |
|
77 |
for filter_args in $filters_args; do |
78 |
filter=$(echo $filter_args | sed -e 's/\([^=]\+\)=.*/\1/') |
79 |
in_pix_fmts=$(tools/lavfi-showfiltfmts $filter | grep "^INPUT" | cut -d: -f2) |
80 |
pix_fmts=$(get_common_elements "$in_pix_fmts" "$scale_out_pix_fmts") |
81 |
|
82 |
for pix_fmt in $pix_fmts; do |
83 |
do_video_encoding "${pix_fmt}-${filter}.nut" "" \ |
84 |
"-vf slicify=random,format=$pix_fmt,$filter_args -vcodec rawvideo -pix_fmt $pix_fmt" |
85 |
done |
86 |
done |
87 |
fi |
88 |
|
89 |
if [ -n "$do_lavfi_pixdesc" ]; then |
90 |
pix_fmts="$($ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^IO' | cut -d' ' -f2)" |
91 |
|
92 |
ref_file=tests/ref/lavfi/lavfi_pixdesc |
93 |
rm -f $ref_file |
94 |
res_file=$logfile |
95 |
|
96 |
for pix_fmt in $pix_fmts; do |
97 |
# print to the reference logfile |
98 |
logfile=$ref_file |
99 |
do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \ |
100 |
"-vf slicify=random,format=$pix_fmt -vcodec rawvideo -pix_fmt $pix_fmt" |
101 |
|
102 |
# print to the result logfile |
103 |
logfile=$res_file |
104 |
do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \ |
105 |
"-vf slicify=random,format=$pix_fmt,pixdesctest -vcodec rawvideo -pix_fmt $pix_fmt" |
106 |
done |
107 |
fi |
108 |
|
109 |
# TODO: add tests for |
110 |
# direct rendering, |
111 |
# chains with feedback loops |
112 |
|
113 |
rm -f "$bench" "$bench2" |