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

Side by Side 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
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 set -e
3
4 while getopts 's:c:k:r:E:D:d:Y:y:n:' OPTIONS; do
5 case $OPTIONS in
6 s) SIZE="$OPTARG";;
7 c) CODEC="$OPTARG";;
8 k) KEYINT="$OPTARG";;
9 r) LIBAOM_ROOT="$OPTARG";;
10 E) AOMENC="$OPTARG";;
11 D) AOMDEC="$OPTARG";;
12 d) DAALA_ROOT="$OPTARG";;
13 Y) Y4M2PNG="$OPTARG";;
14 y) YUV2YUV4MPEG="$OPTARG";;
15 n) FRAMES="$OPTARG";;
16 esac
17 done
18 shift $(($OPTIND - 1))
19
20 if [ -z $CODEC ]; then
21 CODEC=vp8
22 fi
23
24 if [ -z $DAALA_ROOT ]; then
25 DAALA_ROOT=.
26 fi
27
28 if [ -z $LIBAOM_ROOT ] || [ ! -d $LIBAOM_ROOT ]; then
29 echo "Please set LIBAOM_ROOT to the location of your libaom git clone"
30 exit 1
31 fi
32
33 if [ -z "$Y4M2PNG" ]; then
34 Y4M2PNG=$DAALA_ROOT/tools/y4m2png
35 fi
36
37 if [ -z "$AOMENC" ]; then
38 export AOMENC=$LIBAOM_ROOT/aomenc
39 fi
40
41 if [ -z "$AOMDEC" ]; then
42 export AOMDEC=$LIBAOM_ROOT/aomdec
43 fi
44
45 if [ ! -x "$Y4M2PNG" ]; then
46 echo "Y4M2PNG not found at '$Y4M2PNG'."
47 exit 1
48 fi
49
50 if [ ! -x "$AOMENC" ]; then
51 echo "aom encoder not found at '$AOMENC'."
52 exit 1
53 fi
54
55 if [ ! -x "$AOMDEC" ]; then
56 echo "aom decoder not found at '$AOMDEC'."
57 exit 1
58 fi
59
60 if [ -z "$FRAMES" ]; then
61 FRAMES=1
62 fi
63
64 if [ -z "$KEYINT" ]; then
65 KEYINT=256;
66 fi
67
68 FILE=$1
69 echo $FILE
70 BASENAME=$(basename $FILE)
71 # With libaom, the lowest quantizer number yields the highest quality and
72 # vice versa. Here, MAX_QUALITY produces the best looking image, so it's the
73 # lowest number.
74 MAX_QUALITY=3
75 MIN_QUALITY=63
76 while (( $MIN_QUALITY - $MAX_QUALITY > 1 )); do
77 QUALITY=$(( ($MIN_QUALITY + $MAX_QUALITY) / 2 ))
78 AOM_FILE=$BASENAME-$QUALITY.$CODEC.tmp
79 $AOMENC --codec=$CODEC --ivf --frame-parallel=0 --tile-columns=0 --auto-alt-re f=2 --cpu-used=0 --passes=2 --threads=1 --kf-min-dist=$KFINT --kf-max-dist=$KFIN T --lag-in-frames=25 --end-usage=q --cq-level=$QUALITY -o $BASENAME.ivf $EXTRA_O PTIONS $FILE 2> $BASENAME-$QUALITY.$CODEC.tmp > /dev/null -o $AOM_FILE $FILE 2> /dev/null
80 AOM_SIZE=$(wc -c $AOM_FILE | awk '{ print $1 }')
81 if (($AOM_SIZE > $SIZE)); then
82 MAX_QUALITY=$QUALITY
83 MAX_QUALITY_SIZE=$AOM_SIZE
84 else
85 MIN_QUALITY=$QUALITY
86 MIN_QUALITY_SIZE=$AOM_SIZE
87 fi
88 done
89
90 if [ $MIN_QUALITY -eq 63 ]; then
91 $AOMENC --codec=$CODEC --good --cpu-used=0 -y --kf-max-dist=$KEYINT --min-q=$M IN_QUALITY --max-q=$MIN_QUALITY -o $BASENAME-$MIN_QUALITY.$CODEC.tmp $FILE 2> /d ev/null
92 MIN_QUALITY_SIZE=$(stat -c %s $BASENAME-$MIN_QUALITY.$CODEC.tmp)
93 fi
94
95 if [ $MAX_QUALITY -eq 3 ]; then
96 $AOMENC --codec=$CODEC --good --cpu-used=0 -y --kf-max-dist=$KEYINT --min-q=$M AX_QUALITY --max-q=$MAX_QUALITY -o $BASENAME-$MAX_QUALITY.$CODEC.tmp $FILE 2> /d ev/null
97 MAX_QUALITY_SIZE=$(stat -c %s $BASENAME-$MAX_QUALITY.$CODEC.tmp)
98 fi
99
100 if (( $MAX_QUALITY_SIZE - $SIZE < $SIZE - $MIN_QUALITY_SIZE )); then
101 AOM_SIZE=$MAX_QUALITY_SIZE
102 BEST_QUALITY=$MAX_QUALITY
103 else
104 BEST_QUALITY=$MIN_QUALITY
105 AOM_SIZE=$MIN_QUALITY_SIZE
106 fi
107
108 BEST_FILE=$BASENAME-$BEST_QUALITY.$CODEC
109 $AOMDEC --codec=$CODEC -o $BEST_FILE.y4m $BEST_FILE.tmp
110 mv $BEST_FILE.tmp $BEST_FILE
111
112 if [ $FRAMES -eq 1 ]; then
113 $Y4M2PNG -o $BEST_FILE.png $BEST_FILE.y4m
114 rm $BEST_FILE.y4m
115 fi
116
117 rm $BASENAME-*.$CODEC.tmp
OLDNEW
« 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