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

Side by Side Diff: tools/ab_compare_libvpx.sh

Issue 1393: Deduplicate code in ab_compare.sh.
Patch Set: Deduplicate code in ab_compare.sh. Created 2 years, 3 months 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 | « tools/ab_compare_jpeg.sh ('k') | tools/ab_compare_x264.sh » ('j') | 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) LIBVPX_ROOT="$OPTARG";;
10 E) VPXENC="$OPTARG";;
11 D) VPXDEC="$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 $LIBVPX_ROOT ] || [ ! -d $LIBVPX_ROOT ]; then
29 echo "Please set LIBVPX_ROOT to the location of your libvpx 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 "$VPXENC" ]; then
38 export VPXENC=$LIBVPX_ROOT/vpxenc
39 fi
40
41 if [ -z "$VPXDEC" ]; then
42 export VPXDEC=$LIBVPX_ROOT/vpxdec
43 fi
44
45 if [ ! -x "$Y4M2PNG" ]; then
46 echo "Y4M2PNG not found at '$Y4M2PNG'."
47 exit 1
48 fi
49
50 if [ ! -x "$VPXENC" ]; then
51 echo "vpx encoder not found at '$VPXENC'."
52 exit 1
53 fi
54
55 if [ ! -x "$VPXDEC" ]; then
56 echo "vpx decoder not found at '$VPXDEC'."
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 libvpx, 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 VPX_FILE=$BASENAME-$QUALITY.$CODEC.tmp
79 $VPXENC --codec=$CODEC --good --cpu-used=0 -y --min-q=$QUALITY --max-q=$QUALIT Y --kf-max-dist=$KEYINT -o $VPX_FILE $FILE 2> /dev/null
80 VPX_SIZE=$(wc -c $VPX_FILE | awk '{ print $1 }')
81 if (($VPX_SIZE > $SIZE)); then
82 MAX_QUALITY=$QUALITY
83 MAX_QUALITY_SIZE=$VPX_SIZE
84 else
85 MIN_QUALITY=$QUALITY
86 MIN_QUALITY_SIZE=$VPX_SIZE
87 fi
88 done
89
90 if [ $MIN_QUALITY -eq 63 ]; then
91 $VPXENC --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 $VPXENC --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 VPX_SIZE=$MAX_QUALITY_SIZE
102 BEST_QUALITY=$MAX_QUALITY
103 else
104 BEST_QUALITY=$MIN_QUALITY
105 VPX_SIZE=$MIN_QUALITY_SIZE
106 fi
107
108 BEST_FILE=$BASENAME-$BEST_QUALITY.$CODEC
109 $VPXDEC --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 | « tools/ab_compare_jpeg.sh ('k') | tools/ab_compare_x264.sh » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld