forked from xiph/rd_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics_gather.sh
executable file
·296 lines (241 loc) · 9.13 KB
/
metrics_gather.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/bash
set -e
export LD_LIBRARY_PATH=/usr/local/lib/
#3GB RAM limit
ulimit -v 3000000
if [ -z "$WORK_ROOT" ]; then
export WORK_ROOT=/home/ec2-user
fi
cd "$WORK_ROOT"
if [ -z "$DAALATOOL_ROOT" ]; then
export DAALATOOL_ROOT="$WORK_ROOT/daalatool/"
fi
export X264="$WORK_ROOT/x264/x264"
export X265="$WORK_ROOT/x265/build/linux/x265"
export VPXENC="$WORK_ROOT/$CODEC/vpxenc"
export VPXDEC="$WORK_ROOT/$CODEC/vpxdec"
if [ -z "$AOMENC" ]; then
export AOMENC="$WORK_ROOT/$CODEC/aomenc"
fi
if [ -z "$AOMDEC" ]; then
export AOMDEC="$WORK_ROOT/$CODEC/aomdec"
fi
if [ -z "$THORENC" ]; then
export THORENC="$WORK_ROOT/$CODEC/build/Thorenc"
fi
if [ -z "$THORDIR" ]; then
export THORDIR="$(dirname $THORENC)/../"
fi
if [ -z "$THORDEC" ]; then
export THORDEC="$(dirname $THORENC)/Thordec"
fi
if [ -z "$ENCODER_EXAMPLE" ]; then
export ENCODER_EXAMPLE="$WORK_ROOT/daala/examples/encoder_example"
fi
export YUV2YUV4MPEG="$DAALATOOL_ROOT/tools/yuv2yuv4mpeg"
if [ -z "$DUMP_VIDEO" ]; then
export DUMP_VIDEO="$WORK_ROOT/daala/examples/dump_video"
fi
if [ -z "$DUMP_PSNR" ]; then
export DUMP_PSNR="$DAALATOOL_ROOT/tools/dump_psnr"
fi
if [ -z "$DUMP_PSNRHVS" ]; then
export DUMP_PSNRHVS="$DAALATOOL_ROOT/tools/dump_psnrhvs"
fi
if [ -z "$DUMP_SSIM" ]; then
export DUMP_SSIM="$DAALATOOL_ROOT/tools/dump_ssim"
fi
if [ -z "$DUMP_FASTSSIM" ]; then
export DUMP_FASTSSIM="$DAALATOOL_ROOT/tools/dump_fastssim"
fi
if [ -z "$DUMP_MSSSIM" ]; then
export DUMP_MSSSIM="$DAALATOOL_ROOT/tools/dump_msssim"
fi
if [ -z "$DUMP_CIEDE" ]; then
export DUMP_CIEDE="$DAALATOOL_ROOT/tools/dump_ciede2000.py"
fi
if [ -z "$VMAF_ROOT" ]; then
export VMAF_ROOT="$DAALATOOL_ROOT/../vmaf"
fi
if [ -z "$VMAFOSSEXEC" ]; then
export VMAFOSSEXEC="$VMAF_ROOT/wrapper/vmafossexec"
fi
if [ -z "$YUV2YUV4MPEG" ]; then
export YUV2YUV4MPEG="$DAALATOOL_ROOT/tools/yuv2yuv4mpeg"
fi
if [ -z "$CODEC" ]; then
export CODEC=daala
fi
if [ -z "$x" ]; then
echo Missing quality setting
exit 1
fi
if [ -e pid ]; then
kill -9 -$(cat pid) || true
fi
echo $$ > pid
FILE=$1
BASENAME="$(basename $FILE)-$x"
rm "$BASENAME.out" 2> /dev/null || true
WIDTH="$(head -1 $FILE | cut -d\ -f 2 | tr -d 'W')"
HEIGHT="$(head -1 $FILE | cut -d\ -f 3 | tr -d 'H')"
CHROMA="$(head -1 $FILE | cut -d\ -f 7 | tr -d 'C')"
DEPTH=8
case $CHROMA in
444p10)
DEPTH=10
;;
420p10)
DEPTH=10
;;
esac
# used for libvpx vbr
RATE=$(echo $x*$WIDTH*$HEIGHT*30/1000 | bc)
KFINT=1000
TIMEROUT=$BASENAME-enctime.out
TIMERDECOUT=$BASENAME-dectime.out
TIMER='time -v --output='"$TIMEROUT"
TIMERDEC='time -v --output='"$TIMERDECOUT"
AOMDEC_OPTS=
case $CODEC in
daala)
$(OD_LOG_MODULES='encoder:10' OD_DUMP_IMAGES_SUFFIX="$BASENAME" $TIMER "$ENCODER_EXAMPLE" -k $KFINT -v "$x" $EXTRA_OPTIONS "$FILE" -o "$BASENAME.ogv" > "$BASENAME-stdout.txt" 2> "$BASENAME-enc.out")
if [ ! -f "$BASENAME.ogv" ]
then
echo Failed to produce "$BASENAME.ogv"
cat "$BASENAME-enc.out"
exit 1
fi
SIZE=$(stat -c %s "$BASENAME.ogv")
#mv "00000000out-$BASENAME.y4m" "$BASENAME.y4m"
rm -f "00000000out-$BASENAME.y4m"
"$DUMP_VIDEO" "$BASENAME.ogv" -o "$BASENAME.y4m"
;;
x264)
$($TIMER $X264 --dump-yuv $BASENAME.yuv --preset placebo --min-keyint $KFINT --keyint $KFINT --no-scenecut --crf=$x -o $BASENAME.x264 $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$YUV2YUV4MPEG $BASENAME -w$WIDTH -h$HEIGHT -an0 -ad0 -c420mpeg2
SIZE=$(stat -c %s $BASENAME.x264)
;;
x265)
$($TIMER $X265 -r $BASENAME.y4m --preset slow --frame-threads 1 --min-keyint $KFINT --keyint $KFINT --no-scenecut --crf=$x -o $BASENAME.x265 $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
SIZE=$(stat -c %s $BASENAME.x265)
;;
x265-rt)
$($TIMER $X265 -r $BASENAME.y4m --preset slow --tune zerolatency --rc-lookahead 0 --bframes 0 --frame-threads 1 --min-keyint $KFINT --keyint $KFINT --no-scenecut --crf=$x --csv $BASENAME.csv -o $BASENAME.x265 $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
SIZE=$(stat -c %s $BASENAME.x265)
;;
vp8)
$($TIMER $VPXENC --codec=$CODEC --threads=1 --cpu-used=0 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --end-usage=cq --target-bitrate=100000 --cq-level=$x -o $BASENAME.vpx $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$VPXDEC --codec=$CODEC -o $BASENAME.y4m $BASENAME.vpx
SIZE=$(stat -c %s $BASENAME.vpx)
;;
vp9)
$($TIMER $VPXENC --codec=$CODEC --ivf --frame-parallel=0 --tile-columns=0 --auto-alt-ref=2 --cpu-used=0 --passes=2 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --lag-in-frames=25 --end-usage=q --cq-level=$x -o $BASENAME.vpx $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$VPXDEC --codec=$CODEC -o $BASENAME.y4m $BASENAME.vpx
SIZE=$(stat -c %s $BASENAME.vpx)
;;
vp9-rt)
$($TIMER $VPXENC --codec=vp9 --ivf --frame-parallel=0 --tile-columns=0 --cpu-used=0 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT -p 1 --lag-in-frames=0 --end-usage=q --cq-level=$x -o $BASENAME.vpx $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$VPXDEC --codec=vp9 -o $BASENAME.y4m $BASENAME.vpx
SIZE=$(stat -c %s $BASENAME.vpx)
;;
vp10)
$($TIMER $VPXENC --codec=$CODEC --ivf --frame-parallel=0 --tile-columns=0 --auto-alt-ref=2 --cpu-used=0 --passes=2 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --lag-in-frames=25 --end-usage=q --cq-level=$x -o $BASENAME.vpx $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$VPXDEC --codec=$CODEC -o $BASENAME.y4m $BASENAME.vpx
SIZE=$(stat -c %s $BASENAME.vpx)
;;
vp10-rt)
$($TIMER $VPXENC --codec=vp10 --ivf --frame-parallel=0 --tile-columns=0 --cpu-used=0 --passes=1 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --lag-in-frames=0 --end-usage=q --cq-level=$x -o $BASENAME.vpx $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
$VPXDEC --codec=vp10 -o $BASENAME.y4m $BASENAME.vpx
SIZE=$(stat -c %s $BASENAME.vpx)
;;
av1)
$($TIMER $AOMENC --codec=$CODEC --ivf --frame-parallel=0 --tile-columns=0 --auto-alt-ref=2 --cpu-used=0 --passes=2 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --lag-in-frames=25 --end-usage=q --cq-level=$x -o $BASENAME.ivf $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
if $AOMDEC --help 2>&1 | grep output-bit-depth > /dev/null; then
AOMDEC_OPTS=--output-bit-depth=$DEPTH
fi
$($TIMERDEC $AOMDEC --codec=$CODEC $AOMDEC_OPTS -o $BASENAME.y4m $BASENAME.ivf)
SIZE=$(stat -c %s $BASENAME.ivf)
;;
av1-rt)
$($TIMER $AOMENC --codec=av1 --ivf --frame-parallel=0 --tile-columns=0 --cpu-used=0 --passes=1 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFINT --lag-in-frames=0 --end-usage=q --cq-level=$x -o $BASENAME.ivf $EXTRA_OPTIONS $FILE > "$BASENAME-stdout.txt")
if $AOMDEC --help 2>&1 | grep output-bit-depth > /dev/null; then
AOMDEC_OPTS=--output-bit-depth=$DEPTH
fi
$($TIMERDEC $AOMDEC --codec=av1 $AOMDEC_OPTS -o $BASENAME.y4m $BASENAME.ivf)
SIZE=$(stat -c %s $BASENAME.ivf)
;;
thor)
$($TIMER $THORENC -qp $x -cf "$THORDIR/config_HDB16_high_efficiency.txt" -if $FILE -of $BASENAME.thor $EXTRA_OPTIONS > $BASENAME-enc.out)
SIZE=$(stat -c %s $BASENAME.thor)
# using reconstruction is currently broken with HDB
$THORDEC $BASENAME.thor $BASENAME.yuv > "$BASENAME-stdout.txt"
$YUV2YUV4MPEG $BASENAME -w$WIDTH -h$HEIGHT
;;
thor-rt)
$($TIMER $THORENC -qp $x -cf "$THORDIR/config_LDB_high_efficiency.txt" -if $FILE -of $BASENAME.thor -rf $BASENAME.y4m $EXTRA_OPTIONS > $BASENAME-enc.out)
SIZE=$(stat -c %s $BASENAME.thor)
;;
esac
"$DUMP_PSNR" -a "$FILE" "$BASENAME.y4m" > "$BASENAME-psnr.out"
FRAMES=$(cat "$BASENAME-psnr.out" | grep ^0 | wc -l)
PIXELS=$(($WIDTH*$HEIGHT*$FRAMES))
echo "$x" "$PIXELS" "$SIZE"
PSNR=$(cat "$BASENAME-psnr.out" | grep Total)
echo "$PSNR"
APSNR=$(cat "$BASENAME-psnr.out" | grep Frame-averaged)
PSNRHVS=$("$DUMP_PSNRHVS" "$FILE" "$BASENAME.y4m" 2> /dev/null | grep Total)
echo "$PSNRHVS"
SSIM=$("$DUMP_SSIM" "$FILE" "$BASENAME.y4m" 2> /dev/null | grep Total)
echo "$SSIM"
FASTSSIM=$("$DUMP_FASTSSIM" -c "$FILE" "$BASENAME.y4m" 2> /dev/null | grep Total)
echo "$FASTSSIM"
CIEDE=$("$DUMP_CIEDE" "$FILE" "$BASENAME.y4m" 2> /dev/null | grep Total) || true
if [ -z "$CIEDE" ]; then
# CIEDE2000 doesn't yet support 4:4:4
echo Total: 0
else
echo "$CIEDE"
fi
echo "$APSNR"
MSSSIM=$("$DUMP_MSSSIM" "$FILE" "$BASENAME.y4m" 2> /dev/null | grep Total)
echo "$MSSSIM"
if [ -e "$TIMEROUT" ]; then
ENCTIME=$(awk '/User/ { s=$4 } END { printf "%.2f", s }' "$TIMEROUT")
else
ENCTIME=0
fi
echo "$ENCTIME"
if [ -f "$VMAFOSSEXEC" ]; then
rm -f ref dis
mkfifo ref
mkfifo dis
FORMAT=yuv420p
case $CHROMA in
420p10)
FORMAT=yuv444p10le
;;
444p10)
FORMAT=yuv444p10le
;;
444)
FORMAT=yuv444p
;;
esac
"$DAALATOOL_ROOT/tools/y4m2yuv" "$FILE" -o ref &
"$DAALATOOL_ROOT/tools/y4m2yuv" "$BASENAME.y4m" -o dis &
VMAF=$("$VMAFOSSEXEC" $FORMAT $WIDTH $HEIGHT ref dis "$VMAF_ROOT/resource/model/nflxall_vmafv4.pkl" | tail -n 1)
echo "$VMAF"
else
echo 0 0 0 0
fi
if [ -e "$TIMERDECOUT" ]; then
DECTIME=$(awk '/User/ { s=$4 } END { printf "%.2f", s }' "$TIMERDECOUT")
else
DECTIME=0
fi
echo "$DECTIME"
if [ ! "$NO_DELETE" ]; then
rm -f "$BASENAME.y4m" "$BASENAME.yuv" "$BASENAME.ogv" "$BASENAME.x264" "$BASENAME.x265" "$BASENAME.vpx" "$BASENAME.ivf" "$TIMEROUT" "$BASENAME-enc.out" "$BASENAME-psnr.out" "$BASENAME.thor" 2> /dev/null
fi
rm -f pid