test_streams.sh 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #!/bin/sh -e
  2. # FLAC - Free Lossless Audio Codec
  3. # Copyright (C) 2001-2009 Josh Coalson
  4. # Copyright (C) 2011-2016 Xiph.Org Foundation
  5. #
  6. # This file is part the FLAC project. FLAC is comprised of several
  7. # components distributed under different licenses. The codec libraries
  8. # are distributed under Xiph.Org's BSD-like license (see the file
  9. # COPYING.Xiph in this distribution). All other programs, libraries, and
  10. # plugins are distributed under the GPL (see COPYING.GPL). The documentation
  11. # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
  12. # FLAC distribution contains at the top the terms under which it may be
  13. # distributed.
  14. #
  15. # Since this particular file is relevant to all components of FLAC,
  16. # it may be distributed under the Xiph.Org license, which is the least
  17. # restrictive of those mentioned above. See the file COPYING.Xiph in this
  18. # distribution.
  19. . ./common.sh
  20. PATH=../src/flac:$PATH
  21. PATH=../src/test_streams:$PATH
  22. PATH=../objs/$BUILD/bin:$PATH
  23. if [ x"$FLAC__TEST_LEVEL" = x ] ; then
  24. FLAC__TEST_LEVEL=1
  25. fi
  26. flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
  27. run_flac ()
  28. {
  29. if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
  30. echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_streams.valgrind.log
  31. valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_streams.valgrind.log
  32. else
  33. flac${EXE} --no-error-on-compression-fail $*
  34. fi
  35. }
  36. echo "Generating streams..."
  37. if [ ! -f wacky1.wav ] ; then
  38. test_streams || die "ERROR: missing files"
  39. fi
  40. #
  41. # single-file test routines
  42. #
  43. test_file ()
  44. {
  45. name=$1
  46. channels=$2
  47. bps=$3
  48. encode_options="$4"
  49. echo $ECHO_N "$name (--channels=$channels --bps=$bps $encode_options): encode..." $ECHO_C
  50. cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.raw"
  51. echo "### ENCODE $name #######################################################" >> ./streams.log
  52. echo "### cmd=$cmd" >> ./streams.log
  53. $cmd 2>>./streams.log || die "ERROR during encode of $name"
  54. echo $ECHO_N "decode..." $ECHO_C
  55. cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac"
  56. echo "### DECODE $name #######################################################" >> ./streams.log
  57. echo "### cmd=$cmd" >> ./streams.log
  58. $cmd 2>>./streams.log || die "ERROR during decode of $name"
  59. ls -1l $name.raw >> ./streams.log
  60. ls -1l $name.flac >> ./streams.log
  61. ls -1l $name.cmp >> ./streams.log
  62. echo $ECHO_N "compare..." $ECHO_C
  63. cmp $name.raw $name.cmp || die "ERROR during compare of $name"
  64. echo OK
  65. }
  66. test_file_piped ()
  67. {
  68. name=$1
  69. channels=$2
  70. bps=$3
  71. encode_options="$4"
  72. if [ `env | grep -ic '^comspec='` != 0 ] ; then
  73. is_win=yes
  74. else
  75. is_win=no
  76. fi
  77. echo $ECHO_N "$name: encode via pipes..." $ECHO_C
  78. if [ $is_win = yes ] ; then
  79. cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout $name.raw"
  80. echo "### ENCODE $name #######################################################" >> ./streams.log
  81. echo "### cmd=$cmd" >> ./streams.log
  82. $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
  83. else
  84. cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout -"
  85. echo "### ENCODE $name #######################################################" >> ./streams.log
  86. echo "### cmd=$cmd" >> ./streams.log
  87. cat $name.raw | $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name"
  88. fi
  89. echo $ECHO_N "decode via pipes..." $ECHO_C
  90. if [ $is_win = yes ] ; then
  91. cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac"
  92. echo "### DECODE $name #######################################################" >> ./streams.log
  93. echo "### cmd=$cmd" >> ./streams.log
  94. $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
  95. else
  96. cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -"
  97. echo "### DECODE $name #######################################################" >> ./streams.log
  98. echo "### cmd=$cmd" >> ./streams.log
  99. cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name"
  100. fi
  101. ls -1l $name.raw >> ./streams.log
  102. ls -1l $name.flac >> ./streams.log
  103. ls -1l $name.cmp >> ./streams.log
  104. echo $ECHO_N "compare..." $ECHO_C
  105. cmp $name.raw $name.cmp || die "ERROR during compare of $name"
  106. echo OK
  107. }
  108. if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
  109. max_lpc_order=32
  110. else
  111. max_lpc_order=16
  112. fi
  113. echo "Testing noise through pipes..."
  114. test_file_piped noise 1 8 "-0"
  115. echo "Testing small files..."
  116. test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
  117. test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
  118. test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
  119. test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p"
  120. for bps in 8 16 24 ; do
  121. echo "Testing $bps-bit full-scale deflection streams..."
  122. for b in 01 02 03 04 05 06 07 ; do
  123. test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p"
  124. done
  125. done
  126. echo "Testing 16-bit wasted-bits-per-sample streams..."
  127. for b in 01 ; do
  128. test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p"
  129. done
  130. for bps in 8 16 24 ; do
  131. echo "Testing $bps-bit sine wave streams..."
  132. for b in 00 ; do
  133. test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
  134. done
  135. for b in 01 ; do
  136. test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
  137. done
  138. for b in 02 03 04 ; do
  139. test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e"
  140. done
  141. for b in 10 11 ; do
  142. test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000"
  143. done
  144. for b in 12 ; do
  145. test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000"
  146. done
  147. for b in 13 14 15 16 17 18 19 ; do
  148. test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e"
  149. done
  150. done
  151. echo "Testing blocksize variations..."
  152. for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
  153. for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  154. for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do
  155. if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then
  156. test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable"
  157. fi
  158. done
  159. done
  160. done
  161. echo "Testing some frame header variations..."
  162. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order"
  163. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535"
  164. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
  165. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
  166. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
  167. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9"
  168. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90"
  169. test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000"
  170. echo "Testing option variations..."
  171. for f in 00 01 02 03 04 ; do
  172. for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
  173. if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  174. for opt in 0 1 2 4 5 6 8 ; do
  175. for extras in '' '-p' '-e' ; do
  176. if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  177. test_file sine16-$f 1 16 "-$opt $extras $disable"
  178. fi
  179. done
  180. done
  181. if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
  182. test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
  183. fi
  184. fi
  185. done
  186. done
  187. for f in 10 11 12 13 14 15 16 17 18 19 ; do
  188. for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
  189. if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  190. for opt in 0 1 2 4 5 6 8 ; do
  191. for extras in '' '-p' '-e' ; do
  192. if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  193. test_file sine16-$f 2 16 "-$opt $extras $disable"
  194. fi
  195. done
  196. done
  197. if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
  198. test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
  199. fi
  200. fi
  201. done
  202. done
  203. echo "Testing noise..."
  204. for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do
  205. if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  206. for channels in 1 2 4 8 ; do
  207. if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  208. for bps in 8 16 24 ; do
  209. for opt in 0 1 2 3 4 5 6 7 8 ; do
  210. for extras in '' '-p' '-e' ; do
  211. if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  212. for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do
  213. if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then
  214. test_file noise $channels $bps "-$opt $extras $blocksize $disable"
  215. fi
  216. done
  217. fi
  218. done
  219. done
  220. if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
  221. test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable"
  222. fi
  223. done
  224. fi
  225. done
  226. fi
  227. done