[flac-dev] [PATCH] test_compression.sh
Jan Stary
hans at stare.cz
Wed Dec 3 23:49:24 PST 2014
On Dec 04 00:37:25, mvanb1 at gmail.com wrote:
> Op 03-12-14 om 23:27 schreef Jan Stary:
> > * Remove the $((${size}+10)). It's not needed, and it's a lie.
> > In fact, the actual test FAILs (369513 with -5 vs 369516 with -6),
> > but this +10 hides it!
>
> No, it is not. This is necessary due to the way FLAC works.
> There is some uncertainty between the prediction stage and the
> actual LPC stage due to quantization, and there is no way to
> change this. It is only 10 bytes anyway.
My bad, I thought it was a typo in what meant to be "+0",
due to the misleadimg MacOSX comment. Another diff below.
Jan
--- test_compression.sh.orig Wed Dec 3 22:53:11 2014
+++ test_compression.sh Thu Dec 4 08:47:27 2014
@@ -23,24 +23,25 @@ PATH=`pwd`/../src/flac:$PATH
echo "Using FLAC binary :" $(which flac)
-date=`date "+%Y%m%dT%H%M%S"`
-fname="comp${date}.flac"
+ofile=`mktemp`.$$
+ifile="noisy-sine.wav"
-last_k=0
-last_size=$(wc -c < noisy-sine.wav)
+prevcomp=0
+prevsize=`wc -c < $ifile`
+echo "Original file size $prevsize bytes."
-echo "Original file size ${last_size} bytes."
+for comp in 0 1 2 3 4 5 6 7 8 ; do
+ flac${EXE} -f -$comp --silent $ifile -o $ofile
+ size=`wc -c < $ofile`
+ echo Compression level $comp, file size $size bytes.
+ if test $prevsize -lt $size ; then
+ die "Error: level $prevcomp produces smaller file than $comp"
+ fi
+ # This is necessary due to the way FLAC works.
+ # There is some uncertainty between the prediction stage
+ # and the actual LPC stage due to quantization
+ prevsize=$(($size+10))
+ prevcomp=$comp
+done
-for k in 0 1 2 3 4 5 6 7 8 ; do
- flac${EXE} -${k} --silent noisy-sine.wav -o ${fname}
- size=$(wc -c < ${fname})
- echo "Compression level ${k}, file size ${size} bytes."
- if test ${last_size} -lt ${size} ; then
- echo "Error : Compression ${last_k} size ${last_size} >= compression ${k} size ${size}."
- exit 1
- fi
- # Need this because OSX's 'wc -c' returns a number with leading whitespace.
- last_size=$((${size}+10))
- last_k=${k}
- rm -f ${fname}
- done
+rm -f $ofile
More information about the flac-dev
mailing list