Adding support for VTM to rd_collect.sh.
authorJustin Nickelsburg <nickelsburg99@gmail.com>
Tue, 9 Jul 2019 21:38:48 +0000 (17:38 -0400)
committerNathan E. Egge <negge@dgql.org>
Wed, 24 Jul 2019 03:00:18 +0000 (23:00 -0400)
tools/rd_collect.sh
tools/rd_collect_vtm.sh [new file with mode: 0755]

index 1c90f7b..dd7c50f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 set -e
 
-CODECS="<daala|libaom|libaom-rt|vp8|vp9|x264|x265|libjpeg|mozjpeg|theora|webp|bpg|rav1e|svt-av1>"
+CODECS="<daala|libaom|libaom-rt|vp8|vp9|x264|x265|libjpeg|mozjpeg|theora|webp|bpg|rav1e|svt-av1|vtm>"
 
 if [ $# == 0 ]; then
   echo "usage: DAALA_ROOT=<build_dir> $0 $CODECS *.y4m"
@@ -404,6 +404,28 @@ case $CODEC in
 
     export RD_COLLECT_SUB=$(dirname $0)/rd_collect_svtav1.sh
     ;;
+  vtm)
+    if [ -z $VTM_ROOT ] || [ ! -d $VTM_ROOT ]; then
+      echo "Please set VTM_ROOT to the location of your VTM git clone"
+      exit 1
+    fi
+
+    if [ -z "$VTM" ]; then
+      export VTM="$VTM_ROOT/bin/EncoderAppStatic"
+    fi
+
+    if [ ! -x "$VTM" ]; then
+      echo "Executable not found VTM=$VTM"
+      echo "Do you have the right VTM_ROOT=$VTM_ROOT"
+      exit 1
+    fi
+
+    if [ -z "$QPS" ]; then
+      QPS="20 32 43 55 63"
+    fi
+
+    export RD_COLLECT_SUB=$(dirname $0)/rd_collect_vtm.sh
+    ;;
   *)
     echo "Unknown codec: $CODEC"
     exit 1
@@ -527,12 +549,6 @@ if [ -z "$CORES" ]; then
   #echo "CORES not set, using $CORES"
 fi
 
-case $CODEC in
-  libaom | libaom-rt | daala | rav1e | svt-av1 | vp8 | vp9 | x264 | x265 | jpeg | mozjpeg | theora | webp)
-    FILES=$(find -L "$@" -type f -name "*.y4m")
-    for f in $FILES; do for q in $QPS; do printf "%s\0" $f $q; done; done | xargs -0 -n2 -P$CORES $RD_COLLECT_SUB
-    for f in $FILES; do cat $(basename $f)-$CODEC-*.out | sort -n > $(basename $f)-$CODEC.out && rm $(basename $f)-$CODEC-*.out; done
-    ;;
-  *)
-    find -L "$@" -type f -name "*.y4m" -print0 | xargs -0 -n1 -P$CORES $RD_COLLECT_SUB
-esac
+FILES=$(find -L "$@" -type f -name "*.y4m")
+for f in $FILES; do for q in $QPS; do printf "%s\0" $f $q; done; done | xargs -0 -n2 -P$CORES $RD_COLLECT_SUB
+for f in $FILES; do cat $(basename $f)-$CODEC-*.out | sort -n > $(basename $f)-$CODEC.out && rm $(basename $f)-$CODEC-*.out; done
diff --git a/tools/rd_collect_vtm.sh b/tools/rd_collect_vtm.sh
new file mode 100755 (executable)
index 0000000..c37a54f
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -e
+
+if [ -z $RD_COLLECT_SUB ]; then
+  echo "Please use: $(dirname $0)/rd_collect.sh vtm *.y4m"
+  exit 1
+fi
+
+FILE=$1
+QP=$2
+
+BASENAME=$(basename $FILE)-$CODEC-$QP
+rm $BASENAME.out 2> /dev/null || true
+echo $BASENAME
+
+WIDTH=$(head -1 $FILE | cut -d\  -f 2 | tr -d 'W')
+HEIGHT=$(head -1 $FILE | cut -d\  -f 3 | tr -d 'H')
+FRAMES=$(grep FRAME $FILE | wc -l)
+FPS=$(ffmpeg -i $FILE 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p")
+
+QSTR="-wdt $WIDTH -hgt $HEIGHT -f $FRAMES -fr $FPS -c $VTM_ROOT/cfg/encoder_randomaccess_vtm.cfg -q $QP --OutputBitDepth=8"
+
+$Y4M2YUV -o $BASENAME.yuv $FILE
+$VTM $EXTRA_OPTS $QSTR -o $BASENAME-out.yuv -b $BASENAME.vvc -i $BASENAME.yuv > $BASENAME-enc.out
+$YUV2YUV4MPEG $BASENAME-out -w$WIDTH -h$HEIGHT
+SIZE=$(wc -c $BASENAME.vvc | awk '{ print $1 }')
+$DUMP_PSNR $FILE $BASENAME-out.y4m > $BASENAME-psnr.out 2> /dev/null
+FRAMES=$(cat $BASENAME-psnr.out | grep ^0 | wc -l)
+PIXELS=$(($WIDTH*$HEIGHT*$FRAMES))
+PSNR=$(cat $BASENAME-psnr.out | grep Total | tr -s ' ' | cut -d\  -f $((4+$PLANE*2)))
+PSNRHVS=$($DUMP_PSNRHVS $FILE $BASENAME-out.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\  -f $((4+$PLANE*2)))
+SSIM=$($DUMP_SSIM $FILE $BASENAME-out.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\  -f $((4+$PLANE*2)))
+FASTSSIM=$($DUMP_FASTSSIM -c $FILE $BASENAME-out.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\  -f $((4+$PLANE*2)))
+CIEDE=$($DUMP_CIEDE $FILE $BASENAME-out.yuv 2> /dev/null | grep Total | cut -d' ' -f2-)
+rm $BASENAME-out.yuv $BASENAME.vvc $BASENAME.yuv $BASENAME-enc.out $BASENAME-psnr.out $BASENAME-out.y4m
+echo $QP $PIXELS $SIZE $PSNR $PSNRHVS $SSIM $FASTSSIM $CIEDE >> $BASENAME.out
+#tail -1 $BASENAME.out