test_compression.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh -e
  2. # FLAC - Free Lossless Audio Codec
  3. # Copyright (C) 2012-2016 Xiph.Org Foundation
  4. #
  5. # This file is part the FLAC project. FLAC is comprised of several
  6. # components distributed under different licenses. The codec libraries
  7. # are distributed under Xiph.Org's BSD-like license (see the file
  8. # COPYING.Xiph in this distribution). All other programs, libraries, and
  9. # plugins are distributed under the GPL (see COPYING.GPL). The documentation
  10. # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
  11. # FLAC distribution contains at the top the terms under which it may be
  12. # distributed.
  13. #
  14. # Since this particular file is relevant to all components of FLAC,
  15. # it may be distributed under the Xiph.Org license, which is the least
  16. # restrictive of those mentioned above. See the file COPYING.Xiph in this
  17. # distribution.
  18. . ./common.sh
  19. PATH=`pwd`/../src/flac:$PATH
  20. echo "Using FLAC binary :" $(which flac)
  21. date=`date "+%Y%m%dT%H%M%S"`
  22. fname="comp${date}.flac"
  23. last_k=0
  24. last_size=$(wc -c < noisy-sine.wav)
  25. echo "Original file size ${last_size} bytes."
  26. for k in 0 1 2 3 4 5 6 7 8 ; do
  27. flac${EXE} -${k} --silent noisy-sine.wav -o ${fname}
  28. size=$(wc -c < ${fname})
  29. echo "Compression level ${k}, file size ${size} bytes."
  30. if test ${last_size} -lt ${size} ; then
  31. echo "Error : Compression ${last_k} size ${last_size} >= compression ${k} size ${size}."
  32. exit 1
  33. fi
  34. # Need this because OSX's 'wc -c' returns a number with leading whitespace.
  35. last_size=$((${size}+10))
  36. last_k=${k}
  37. rm -f ${fname}
  38. done