Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(480103)

Unified Diff: tools/ab_compare_libaom.sh

Issue 1557: add ab_compare_libaom.sh
Patch Set: Add ab_compare_libaom.sh. Created 11 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/ab_compare_libaom.sh
diff --git a/tools/ab_compare_libaom.sh b/tools/ab_compare_libaom.sh
new file mode 100755
index 0000000000000000000000000000000000000000..4135133912524555ffc093e849d0ec418cacd36e
--- /dev/null
+++ b/tools/ab_compare_libaom.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+set -e
+
+while getopts 's:c:k:r:E:D:d:Y:y:n:' OPTIONS; do
+ case $OPTIONS in
+ s) SIZE="$OPTARG";;
+ c) CODEC="$OPTARG";;
+ k) KEYINT="$OPTARG";;
+ r) LIBAOM_ROOT="$OPTARG";;
+ E) AOMENC="$OPTARG";;
+ D) AOMDEC="$OPTARG";;
+ d) DAALA_ROOT="$OPTARG";;
+ Y) Y4M2PNG="$OPTARG";;
+ y) YUV2YUV4MPEG="$OPTARG";;
+ n) FRAMES="$OPTARG";;
+ esac
+done
+shift $(($OPTIND - 1))
+
+if [ -z $CODEC ]; then
+ CODEC=vp8
+fi
+
+if [ -z $DAALA_ROOT ]; then
+ DAALA_ROOT=.
+fi
+
+if [ -z $LIBAOM_ROOT ] || [ ! -d $LIBAOM_ROOT ]; then
+ echo "Please set LIBAOM_ROOT to the location of your libaom git clone"
+ exit 1
+fi
+
+if [ -z "$Y4M2PNG" ]; then
+ Y4M2PNG=$DAALA_ROOT/tools/y4m2png
+fi
+
+if [ -z "$AOMENC" ]; then
+ export AOMENC=$LIBAOM_ROOT/aomenc
+fi
+
+if [ -z "$AOMDEC" ]; then
+ export AOMDEC=$LIBAOM_ROOT/aomdec
+fi
+
+if [ ! -x "$Y4M2PNG" ]; then
+ echo "Y4M2PNG not found at '$Y4M2PNG'."
+ exit 1
+fi
+
+if [ ! -x "$AOMENC" ]; then
+ echo "aom encoder not found at '$AOMENC'."
+ exit 1
+fi
+
+if [ ! -x "$AOMDEC" ]; then
+ echo "aom decoder not found at '$AOMDEC'."
+ exit 1
+fi
+
+if [ -z "$FRAMES" ]; then
+ FRAMES=1
+fi
+
+if [ -z "$KEYINT" ]; then
+ KEYINT=256;
+fi
+
+FILE=$1
+echo $FILE
+BASENAME=$(basename $FILE)
+# With libaom, the lowest quantizer number yields the highest quality and
+# vice versa. Here, MAX_QUALITY produces the best looking image, so it's the
+# lowest number.
+MAX_QUALITY=3
+MIN_QUALITY=63
+while (( $MIN_QUALITY - $MAX_QUALITY > 1 )); do
+ QUALITY=$(( ($MIN_QUALITY + $MAX_QUALITY) / 2 ))
+ AOM_FILE=$BASENAME-$QUALITY.$CODEC.tmp
+ $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=$QUALITY -o $BASENAME.ivf $EXTRA_OPTIONS $FILE 2> $BASENAME-$QUALITY.$CODEC.tmp > /dev/null -o $AOM_FILE $FILE 2> /dev/null
+ AOM_SIZE=$(wc -c $AOM_FILE | awk '{ print $1 }')
+ if (($AOM_SIZE > $SIZE)); then
+ MAX_QUALITY=$QUALITY
+ MAX_QUALITY_SIZE=$AOM_SIZE
+ else
+ MIN_QUALITY=$QUALITY
+ MIN_QUALITY_SIZE=$AOM_SIZE
+ fi
+done
+
+if [ $MIN_QUALITY -eq 63 ]; then
+ $AOMENC --codec=$CODEC --good --cpu-used=0 -y --kf-max-dist=$KEYINT --min-q=$MIN_QUALITY --max-q=$MIN_QUALITY -o $BASENAME-$MIN_QUALITY.$CODEC.tmp $FILE 2> /dev/null
+ MIN_QUALITY_SIZE=$(stat -c %s $BASENAME-$MIN_QUALITY.$CODEC.tmp)
+fi
+
+if [ $MAX_QUALITY -eq 3 ]; then
+ $AOMENC --codec=$CODEC --good --cpu-used=0 -y --kf-max-dist=$KEYINT --min-q=$MAX_QUALITY --max-q=$MAX_QUALITY -o $BASENAME-$MAX_QUALITY.$CODEC.tmp $FILE 2> /dev/null
+ MAX_QUALITY_SIZE=$(stat -c %s $BASENAME-$MAX_QUALITY.$CODEC.tmp)
+fi
+
+if (( $MAX_QUALITY_SIZE - $SIZE < $SIZE - $MIN_QUALITY_SIZE )); then
+ AOM_SIZE=$MAX_QUALITY_SIZE
+ BEST_QUALITY=$MAX_QUALITY
+else
+ BEST_QUALITY=$MIN_QUALITY
+ AOM_SIZE=$MIN_QUALITY_SIZE
+fi
+
+BEST_FILE=$BASENAME-$BEST_QUALITY.$CODEC
+$AOMDEC --codec=$CODEC -o $BEST_FILE.y4m $BEST_FILE.tmp
+mv $BEST_FILE.tmp $BEST_FILE
+
+if [ $FRAMES -eq 1 ]; then
+ $Y4M2PNG -o $BEST_FILE.png $BEST_FILE.y4m
+ rm $BEST_FILE.y4m
+fi
+
+rm $BASENAME-*.$CODEC.tmp
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld