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

Unified Diff: tools/ab_compare_daala.sh

Issue 1393: Deduplicate code in ab_compare.sh.
Patch Set: Deduplicate code in ab_compare.sh. Created 2 years, 3 months 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 | « tools/ab_compare.sh ('k') | tools/ab_compare_encode.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/ab_compare_daala.sh
diff --git a/tools/ab_compare_daala.sh b/tools/ab_compare_daala.sh
deleted file mode 100755
index 61d284786aee1164ba6ec9c1e6318ea1a50a1e34..0000000000000000000000000000000000000000
--- a/tools/ab_compare_daala.sh
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/bin/bash
-set -e
-
-while getopts 's:v:bk:d:E:D:y:n:' OPTIONS; do
- case $OPTIONS in
- s) SIZE="$OPTARG";;
- v) V="$OPTARG";;
- b) B_MODE='true';;
- k) KEYINT="$OPTARG";;
- # -b is whether or not we are running this script to produce images that
- # are for the secondary Daala in an a-b comparison, as opposed to the
- # first.
- d) DAALA_ROOT="$OPTARG";;
- E) ENCODER_EXAMPLE="$OPTARG";;
- D) DUMP_VIDEO="$OPTARG";;
- Y) Y4M2PNG="$OPTARG";;
- n) FRAMES="$OPTARG";;
- esac
-done
-shift $(($OPTIND - 1))
-
-if [[ -n "$V" && -n "$SIZE" ]]; then
- echo "Both quality setting and size specified."
- exit 1
-fi
-
-if [[ -z "$V" && -z "$SIZE" ]]; then
- echo "Neither quality setting and size specified."
- exit 1
-fi
-
-if [ -z "$DAALA_ROOT" ]; then
- DAALA_ROOT=.
-fi
-
-if [ -z "$ENCODER_EXAMPLE" ]; then
- ENCODER_EXAMPLE=$DAALA_ROOT/examples/encoder_example
-fi
-
-if [ -z "$DUMP_VIDEO" ]; then
- DUMP_VIDEO=$DAALA_ROOT/examples/dump_video
-fi
-
-if [ -z "$Y4M2PNG" ]; then
- Y4M2PNG=$DAALA_ROOT/tools/y4m2png
-fi
-
-if [ ! -x "$ENCODER_EXAMPLE" ]; then
- echo "Example encoder not found at '$ENCODER_EXAMPLE.'"
- exit 1
-fi
-
-if [ ! -x "$DUMP_VIDEO" ]; then
- echo "Video dumper not found at '$DUMP_VIDEO'."
- exit 1
-fi
-
-if [ ! -x "$Y4M2PNG" ]; then
- echo "Y4M2PNG not found at '$Y4M2PNG'."
- exit 1
-fi
-
-if [ -z "$FRAMES" ]; then
- FRAMES=1
-fi
-
-if [ -z "$KEYINT" ]; then
- KEYINT=256
-fi
-
-FILE=$1
-BASENAME=$(basename "$FILE")
-if [ -n "$V" ]; then
- echo "$FILE"
- $ENCODER_EXAMPLE -v $V "$FILE" -o "$BASENAME-$V.ogv" 2> /dev/null
- $DUMP_VIDEO -o "$BASENAME-$V.ogv.y4m" "$BASENAME-$V.ogv" 2> /dev/null
-
- if [ $FRAMES -eq 1 ]; then
- $Y4M2PNG -o "$BASENAME-$V.ogv.png" "$BASENAME-$V.ogv.y4m"
- rm "$BASENAME-$V.ogv.y4m"
- fi
-
-else
- # With Daala, 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=0
- MIN_QUALITY=511
- while (( $MIN_QUALITY - $MAX_QUALITY > 1 )); do
- QUALITY=$(( ($MIN_QUALITY + $MAX_QUALITY) / 2 ))
- if [ "$B_MODE" == 'true' ]; then
- OGV_FILE="$BASENAME-b-$QUALITY.ogv.tmp"
- else
- OGV_FILE="$BASENAME-$QUALITY.ogv.tmp"
- fi
- $ENCODER_EXAMPLE -v $QUALITY "$FILE" -k $KEYINT -o "$OGV_FILE" 2> /dev/null
- OGV_SIZE=$(wc -c "$OGV_FILE" | awk '{ print $1 }')
- if (($OGV_SIZE > $SIZE)); then
- MAX_QUALITY=$QUALITY
- MAX_QUALITY_SIZE=$OGV_SIZE
- else
- MIN_QUALITY=$QUALITY
- MIN_QUALITY_SIZE=$OGV_SIZE
- fi
- done
-
- if [ $MIN_QUALITY -eq 511 ]; then
- if [ "$B_MODE" == 'true' ]; then
- FILENAME="$BASENAME-b-$MIN_QUALITY.ogv.tmp"
- else
- FILENAME="$BASENAME-$MIN_QUALITY.ogv.tmp"
- fi
- $ENCODER_EXAMPLE -v $MIN_QUALITY "$FILE" -k $KEYINT -o "$FILENAME" 2> /dev/null
- MIN_QUALITY_SIZE=$(stat -c %s "$FILENAME")
- fi
-
- if [ $MAX_QUALITY -eq 0 ]; then
- if [ "$B_MODE" == 'true' ]; then
- FILENAME="$BASENAME-b-$MAX_QUALITY.ogv.tmp"
- else
- FILENAME="$BASENAME-$MAX_QUALITY.ogv.tmp"
- fi
- $ENCODER_EXAMPLE -v $QUALITY "$FILE" -k $KEYINT -o "$FILENAME" 2> /dev/null
- MAX_QUALITY_SIZE=$(stat -c %s "$FILENAME")
- fi
-
- if (( $MAX_QUALITY_SIZE - $SIZE < $SIZE - $MIN_QUALITY_SIZE )); then
- VPX_SIZE=$MAX_QUALITY_SIZE
- BEST_QUALITY=$MAX_QUALITY
- else
- BEST_QUALITY=$MIN_QUALITY
- VPX_SIZE=$MIN_QUALITY_SIZE
- fi
-
- if [ "$B_MODE" == 'true' ]; then
- BEST_FILE="$BASENAME-b-$BEST_QUALITY.ogv"
- else
- BEST_FILE="$BASENAME-$BEST_QUALITY.ogv"
- fi
-
- mv "$BEST_FILE.tmp" "$BEST_FILE"
- $DUMP_VIDEO -o "$BEST_FILE.y4m" "$BEST_FILE" 2>/dev/null
- if [ $FRAMES -eq 1 ]; then
- $Y4M2PNG -o "$BEST_FILE.png" "$BEST_FILE.y4m"
- rm "$BASENAME"-*.ogv.tmp "$BEST_FILE.y4m"
- else
- rm "$BASENAME"-*.ogv.tmp
- fi
-fi
« no previous file with comments | « tools/ab_compare.sh ('k') | tools/ab_compare_encode.sh » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld