forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBe12d32fTahinli6 days ago3982 commits

hevc-speed-sweep.sh36 lines, 2.2 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# hevc-speed-sweep.sh: speed and rate-distortion of ec-h265 sequence encodes under env overrides.
3# Usage: scripts/hevc-speed-sweep.sh <label> [VAR=val ...]
4# Encodes 3 synthetic 720p 10-bit clips at QP 22/27/32/37 (keyint 8, 4 threads), writes
5# $D/<label>.<clip>.tsv (bytes, psnr_y, psnr_yuv) and prints fps. Compare labels with bdrate.py.
6# Env: BITDEPTH (10), CLIPS (a b c), N (32).
7set -e
8here=$(cd "$(dirname "$0")/.." && pwd)
9label=$1; shift
10D=${D:-$HOME/.cache/hevcfast-data2}; mkdir -p "$D"
11N=${N:-32}; BD=${BITDEPTH:-10}; W=1280; H=720
12pix=yuv420p; [ $BD = 10 ] && pix=yuv420p10le
13src_a="testsrc2=size=${W}x${H}:rate=30,scroll=h=0.003:v=0.004,noise=alls=4:allf=t"
14src_b="mandelbrot=size=${W}x${H}:rate=30"
15src_c="gradients=size=${W}x${H}:rate=30:speed=0.02:n=4,noise=alls=5:allf=t"
16for c in ${CLIPS:-a b c}; do
17 f=$D/$c$BD.yuv
18 [ -s $f ] || { eval s=\$src_$c; ffmpeg -loglevel error -y -f lavfi -i "$s" -frames:v $N -pix_fmt $pix -f rawvideo $f; }
19done
20(cd "$here" && cargo build --release -q -p ec-h265 --example hevc_gop)
21BIN=${CARGO_TARGET_DIR:-$here/target}/release/examples/hevc_gop
22echo "host=$(hostname) load=$(cut -d' ' -f1-3 /proc/loadavg)"
23for c in ${CLIPS:-a b c}; do
24 f=$D/$c$BD.yuv; out=$D/$label.$c.tsv; : > $out; tt=0; tc=0
25 for qp in 22 27 32 37; do
26 TIMEFORMAT='%U %S'; { time env "$@" EC_H265_BITDEPTH=$BD EC_H265_THREADS=4 EC_H265_TIMING=1 $BIN encode $f $W $H 8 $qp $D/o.hevc $D/r.yuv >/dev/null 2>$D/t.log; } 2>$D/cpu.log
27 cpu=$(awk '{print $1+$2}' $D/cpu.log); tc=$(awk "BEGIN{print ${tc:-0}+$cpu}")
28 t=$(cut -d' ' -f2 $D/t.log | tr -d s); tt=$(awk "BEGIN{print $tt+$t}")
29 l=$(PIX=$pix $here/scripts/ffmpeg-psnr.sh $f $D/r.yuv $W $H)
30 py=$(echo "$l" | sed -n 's/.*psnr_y=\([^ ]*\).*/\1/p'); pyuv=$(echo "$l" | sed -n 's/.*psnr_yuv=\([^ ]*\).*/\1/p')
31 printf '%s\t%s\t%s\n' $(stat -c %s $D/o.hevc) $py $pyuv >> $out
32 done
33 fps=$(awk "BEGIN{printf \"%.2f\", 4*$N/$tt}")
34 bd=""; [ "$label" != default ] && [ -s $D/default.$c.tsv ] && bd=$(python3 -I $here/scripts/bdrate.py --metric yuv $D/default.$c.tsv $out | tr '\n' ' ')
35 echo "$label clip=$c fps=$fps cpu_ms_per_frame=$(awk "BEGIN{printf \"%.0f\", 1000*$tc/(4*$N)}") $bd"
36done