test_flac.sh 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  1. #!/bin/sh -e
  2. # FLAC - Free Lossless Audio Codec
  3. # Copyright (C) 2001-2009 Josh Coalson
  4. # Copyright (C) 2011-2023 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. # we use '.' as decimal separator in --skip/--until tests
  21. export LANG=C LC_ALL=C
  22. dddie="die ERROR: creating files with dd"
  23. PATH="$(pwd)/../src/flac:$PATH"
  24. PATH="$(pwd)/../src/metaflac:$PATH"
  25. PATH="$(pwd)/../src/test_streams:$PATH"
  26. PATH="$(pwd)/../objs/$BUILD/bin:$PATH"
  27. flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
  28. run_flac ()
  29. {
  30. if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
  31. echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log
  32. valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* 4>>test_flac.valgrind.log
  33. else
  34. flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $*
  35. fi
  36. }
  37. run_metaflac ()
  38. {
  39. if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
  40. echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_flac.valgrind.log
  41. valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_flac.valgrind.log
  42. else
  43. metaflac${EXE} $*
  44. fi
  45. }
  46. md5cmp ()
  47. {
  48. n=$( ( [ -f "$1" ] && [ -f "$2" ] && metaflac${EXE} --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l)
  49. [ "$n" != "" ] && [ $n = 1 ]
  50. }
  51. echo "Checking for --ogg support in flac..."
  52. if flac${EXE} --ogg $TOTTALY_SILENT --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
  53. has_ogg=yes;
  54. echo "flac --ogg works"
  55. else
  56. has_ogg=no;
  57. echo "flac --ogg doesn't work"
  58. fi
  59. echo "Generating streams..."
  60. if [ ! -f wacky1.wav ] ; then
  61. test_streams || die "ERROR during test_streams"
  62. fi
  63. ############################################################################
  64. # test that flac doesn't automatically overwrite files unless -f is used
  65. ############################################################################
  66. echo "Try encoding to a file that exists; should fail"
  67. cp wacky1.wav exist.wav
  68. touch exist.flac
  69. if run_flac -0 exist.wav ; then
  70. die "ERROR: it should have failed but didn't"
  71. else
  72. echo "OK, it failed as it should"
  73. fi
  74. echo "Try encoding with -f to a file that exists; should succeed"
  75. if run_flac -0 --force exist.wav ; then
  76. echo "OK, it succeeded as it should"
  77. else
  78. die "ERROR: it should have succeeded but didn't"
  79. fi
  80. echo "Try decoding to a file that exists; should fail"
  81. if run_flac -d exist.flac ; then
  82. die "ERROR: it should have failed but didn't"
  83. else
  84. echo "OK, it failed as it should"
  85. fi
  86. echo "Try decoding with -f to a file that exists; should succeed"
  87. if run_flac -d -f exist.flac ; then
  88. echo "OK, it succeeded as it should"
  89. else
  90. die "ERROR: it should have succeeded but didn't"
  91. fi
  92. rm -f exist.wav exist.flac
  93. ############################################################################
  94. # test fractional block sizes
  95. ############################################################################
  96. test_fractional ()
  97. {
  98. blocksize=$1
  99. samples=$2
  100. dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie
  101. echo $ECHO_N "fractional block size test (blocksize=$blocksize samples=$samples) encode... " $ECHO_C
  102. run_flac --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=$blocksize --no-padding --lax -o pbs.flac pbs.raw || die "ERROR"
  103. echo $ECHO_N "decode... " $ECHO_C
  104. run_flac --force --decode --force-raw-format --endian=little --sign=signed -o pbs.cmp pbs.flac || die "ERROR"
  105. echo $ECHO_N "compare... " $ECHO_C
  106. cmp pbs.raw pbs.cmp || die "ERROR: file mismatch"
  107. echo "OK"
  108. rm -f pbs.raw pbs.flac pbs.cmp
  109. }
  110. # The special significance of 2048 is it's the # of samples that flac calls
  111. # FLAC__stream_encoder_process() on.
  112. #
  113. # We're trying to make sure the 1-sample overread logic in the stream encoder
  114. # (used for last-block checking) works; these values probe around common
  115. # multiples of the flac sample chunk size (2048) and the blocksize.
  116. for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do
  117. test_fractional 33 $samples
  118. done
  119. for samples in 254 255 256 257 258 510 511 512 513 514 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
  120. test_fractional 256 $samples
  121. done
  122. for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
  123. test_fractional 2048 $samples
  124. done
  125. for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 4606 4607 4608 4609 4610 8190 8191 8192 8193 8194 16382 16383 16384 16385 16386 ; do
  126. test_fractional 4608 $samples
  127. done
  128. ############################################################################
  129. # basic 'round-trip' tests of various kinds of streams
  130. ############################################################################
  131. rt_test_raw ()
  132. {
  133. f="$1"
  134. extra="$2"
  135. channels="$(echo $f | awk -F- '{print $2}')"
  136. bps="$(echo $f | awk -F- '{print $3}')"
  137. sign="$(echo $f | awk -F- '{print $4}')"
  138. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  139. run_flac --force --verify --force-raw-format --endian=little --sign=$sign --sample-rate=44100 --bps=$bps --channels=$channels --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  140. echo $ECHO_N "decode... " $ECHO_C
  141. run_flac --force --decode --force-raw-format --endian=little --sign=$sign -o rt.raw $extra rt.flac || die "ERROR"
  142. echo $ECHO_N "compare... " $ECHO_C
  143. cmp $f rt.raw || die "ERROR: file mismatch"
  144. echo "OK"
  145. rm -f rt.flac rt.raw
  146. }
  147. rt_test_wav ()
  148. {
  149. f="$1"
  150. extra="$2"
  151. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  152. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  153. echo $ECHO_N "decode... " $ECHO_C
  154. run_flac --force --decode --channel-map=none -o rt.wav $extra rt.flac || die "ERROR"
  155. echo $ECHO_N "compare... " $ECHO_C
  156. cmp $f rt.wav || die "ERROR: file mismatch"
  157. echo "OK"
  158. rm -f rt.flac rt.wav
  159. }
  160. rt_test_wav_autokf ()
  161. {
  162. f="$1"
  163. extra="$2"
  164. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  165. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  166. echo $ECHO_N "decode... " $ECHO_C
  167. run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR"
  168. echo $ECHO_N "compare... " $ECHO_C
  169. cmp $f rt.wav || die "ERROR: file mismatch"
  170. echo "OK"
  171. rm -f rt.flac rt.wav
  172. }
  173. rt_test_w64 ()
  174. {
  175. f="$1"
  176. extra="$2"
  177. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  178. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  179. echo $ECHO_N "decode... " $ECHO_C
  180. run_flac --force --decode --channel-map=none -o rt.w64 $extra rt.flac || die "ERROR"
  181. echo $ECHO_N "compare... " $ECHO_C
  182. cmp $f rt.w64 || die "ERROR: file mismatch"
  183. echo "OK"
  184. rm -f rt.flac rt.w64
  185. }
  186. rt_test_w64_autokf ()
  187. {
  188. f="$1"
  189. extra="$2"
  190. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  191. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  192. echo $ECHO_N "decode... " $ECHO_C
  193. run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR"
  194. echo $ECHO_N "compare... " $ECHO_C
  195. cmp $f rt.w64 || die "ERROR: file mismatch"
  196. echo "OK"
  197. rm -f rt.flac rt.w64
  198. }
  199. rt_test_rf64 ()
  200. {
  201. f="$1"
  202. extra="$2"
  203. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  204. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  205. echo $ECHO_N "decode... " $ECHO_C
  206. run_flac --force --decode --channel-map=none -o rt.rf64 $extra rt.flac || die "ERROR"
  207. echo $ECHO_N "compare... " $ECHO_C
  208. cmp $f rt.rf64 || die "ERROR: file mismatch"
  209. echo "OK"
  210. rm -f rt.flac rt.rf64
  211. }
  212. rt_test_rf64_autokf ()
  213. {
  214. f="$1"
  215. extra="$2"
  216. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  217. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  218. echo $ECHO_N "decode... " $ECHO_C
  219. run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR"
  220. echo $ECHO_N "compare... " $ECHO_C
  221. cmp $f rt.rf64 || die "ERROR: file mismatch"
  222. echo "OK"
  223. rm -f rt.flac rt.rf64
  224. }
  225. rt_test_aiff ()
  226. {
  227. f="$1"
  228. extra="$2"
  229. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  230. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  231. echo $ECHO_N "decode... " $ECHO_C
  232. run_flac --force --decode --channel-map=none -o rt.aiff $extra rt.flac || die "ERROR"
  233. echo $ECHO_N "compare... " $ECHO_C
  234. cmp $f rt.aiff || die "ERROR: file mismatch"
  235. echo "OK"
  236. rm -f rt.flac rt.aiff
  237. }
  238. rt_test_autokf ()
  239. {
  240. f="$1"
  241. extra="$2"
  242. echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
  243. run_flac --force --verify --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  244. echo $ECHO_N "decode... " $ECHO_C
  245. run_flac --force --decode $extra rt.flac || die "ERROR"
  246. echo $ECHO_N "compare... " $ECHO_C
  247. cmp $f $3 || die "ERROR: file mismatch"
  248. echo "OK"
  249. rm -f rt.flac $3
  250. }
  251. # assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
  252. rt_test_flac ()
  253. {
  254. f="$1"
  255. extra="$2"
  256. echo $ECHO_N "round-trip test ($f->flac->flac->wav) encode... " $ECHO_C
  257. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
  258. echo $ECHO_N "re-encode... " $ECHO_C
  259. run_flac --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
  260. echo $ECHO_N "decode... " $ECHO_C
  261. run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.flac || die "ERROR"
  262. echo $ECHO_N "compare... " $ECHO_C
  263. cmp $f rt.wav || die "ERROR: file mismatch"
  264. echo "OK"
  265. rm -f rt.wav rt.flac rt2.flac
  266. }
  267. # assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
  268. rt_test_ogg_flac ()
  269. {
  270. f="$1"
  271. extra="$2"
  272. echo $ECHO_N "round-trip test ($f->oggflac->oggflac->wav) encode... " $ECHO_C
  273. run_flac --force --verify --channel-map=none --no-padding --lax -o rt.oga --ogg $extra $f || die "ERROR"
  274. echo $ECHO_N "re-encode... " $ECHO_C
  275. run_flac --force --verify --lax -o rt2.oga --ogg rt.oga || die "ERROR"
  276. echo $ECHO_N "decode... " $ECHO_C
  277. run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.oga || die "ERROR"
  278. echo $ECHO_N "compare... " $ECHO_C
  279. cmp $f rt.wav || die "ERROR: file mismatch"
  280. echo "OK"
  281. rm -f rt.wav rt.oga rt2.oga
  282. }
  283. for f in rt-*.raw ; do
  284. rt_test_raw $f
  285. done
  286. for f in rt-*.wav ; do
  287. rt_test_wav $f
  288. done
  289. for f in rt-*.w64 ; do
  290. rt_test_w64 $f
  291. done
  292. for f in rt-*.rf64 ; do
  293. rt_test_rf64 $f
  294. done
  295. for f in rt-*.aiff ; do
  296. rt_test_aiff $f
  297. done
  298. for f in rt-*.wav ; do
  299. rt_test_flac $f
  300. done
  301. if [ $has_ogg = yes ] ; then
  302. for f in rt-*.wav ; do
  303. rt_test_ogg_flac $f
  304. done
  305. fi
  306. ############################################################################
  307. # test --skip and --until
  308. ############################################################################
  309. #
  310. # first make some chopped-up raw files
  311. #
  312. echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
  313. dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
  314. dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
  315. dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
  316. dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
  317. dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
  318. dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
  319. dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
  320. dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
  321. dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
  322. dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
  323. dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
  324. dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
  325. dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
  326. dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
  327. dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
  328. dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
  329. wav_eopt="--force --verify --no-padding --lax"
  330. wav_dopt="--force --decode"
  331. raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
  332. raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
  333. #
  334. # convert them to WAVE/AIFF/Ogg FLAC files
  335. #
  336. convert_to_wav ()
  337. {
  338. run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
  339. run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
  340. }
  341. convert_to_wav 50c "$raw_eopt" "$wav_dopt"
  342. convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
  343. convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
  344. convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
  345. convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
  346. convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
  347. convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
  348. convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
  349. convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
  350. convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
  351. convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
  352. convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
  353. convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
  354. convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
  355. convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
  356. convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
  357. convert_to_aiff ()
  358. {
  359. run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
  360. run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
  361. }
  362. convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
  363. convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
  364. convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
  365. convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
  366. convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
  367. convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
  368. convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
  369. convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
  370. convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
  371. convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
  372. convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
  373. convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
  374. convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
  375. convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
  376. convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
  377. convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
  378. convert_to_ogg ()
  379. {
  380. run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
  381. }
  382. if [ $has_ogg = yes ] ; then
  383. convert_to_ogg 50c
  384. convert_to_ogg 50c.skip10
  385. convert_to_ogg 50c.skip11
  386. convert_to_ogg 50c.skip20
  387. convert_to_ogg 50c.skip30
  388. convert_to_ogg 50c.skip40
  389. convert_to_ogg 50c.until10
  390. convert_to_ogg 50c.until20
  391. convert_to_ogg 50c.until30
  392. convert_to_ogg 50c.until39
  393. convert_to_ogg 50c.until40
  394. convert_to_ogg 50c.skip10.until30
  395. convert_to_ogg 50c.skip10.until39
  396. convert_to_ogg 50c.skip10.until40
  397. convert_to_ogg 50c.skip20.until30
  398. convert_to_ogg 50c.skip20.until40
  399. fi
  400. test_skip_until ()
  401. {
  402. in_fmt=$1
  403. out_fmt=$2
  404. [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
  405. [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
  406. if [ $in_fmt = raw ] ; then
  407. eopt="$raw_eopt"
  408. dopt="$raw_dopt"
  409. else
  410. eopt="$wav_eopt"
  411. dopt="$wav_dopt"
  412. fi
  413. if [ $in_fmt = flac -o $in_fmt = ogg ] && [ $out_fmt = flac -o $out_fmt = ogg ]; then
  414. CMP=md5cmp
  415. else
  416. CMP=cmp
  417. fi
  418. if [ $out_fmt = ogg ] ; then
  419. eopt="--ogg $eopt"
  420. fi
  421. #
  422. # test --skip when encoding
  423. #
  424. desc="($in_fmt<->$out_fmt)"
  425. echo $ECHO_N "testing --skip=# (encode) $desc... " $ECHO_C
  426. run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  427. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
  428. $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
  429. rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
  430. echo OK
  431. echo $ECHO_N "testing --skip=mm:ss (encode) $desc... " $ECHO_C
  432. run_flac $eopt --skip=0:01 -o z50c.skip0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  433. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.$in_fmt z50c.skip0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
  434. $CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
  435. rm -f z50c.skip0_01.$out_fmt z50c.skip0_01.$in_fmt
  436. echo OK
  437. echo $ECHO_N "testing --skip=mm:ss.sss (encode) $desc... " $ECHO_C
  438. run_flac $eopt --skip=0:01.1001 -o z50c.skip0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  439. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.1001.$in_fmt z50c.skip0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
  440. $CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
  441. rm -f z50c.skip0_01.1001.$out_fmt z50c.skip0_01.1001.$in_fmt
  442. echo OK
  443. #
  444. # test --skip when decoding
  445. #
  446. if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
  447. echo $ECHO_N "testing --skip=# (decode) $desc... " $ECHO_C
  448. run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  449. $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
  450. rm -f z50c.skip10.$in_fmt
  451. echo OK
  452. echo $ECHO_N "testing --skip=mm:ss (decode) $desc... " $ECHO_C
  453. run_flac $dopt --skip=0:01 -o z50c.skip0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  454. $CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
  455. rm -f z50c.skip0_01.$in_fmt
  456. echo OK
  457. echo $ECHO_N "testing --skip=mm:ss.sss (decode) $desc... " $ECHO_C
  458. run_flac $dopt --skip=0:01.1001 -o z50c.skip0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  459. $CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
  460. rm -f z50c.skip0_01.1001.$in_fmt
  461. echo OK
  462. rm -f z50c.$out_fmt
  463. #
  464. # test --until when encoding
  465. #
  466. echo $ECHO_N "testing --until=# (encode) $desc... " $ECHO_C
  467. run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  468. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
  469. $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
  470. rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
  471. echo OK
  472. echo $ECHO_N "testing --until=mm:ss (encode) $desc... " $ECHO_C
  473. run_flac $eopt --until=0:04 -o z50c.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  474. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_04.$in_fmt z50c.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc"
  475. $CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
  476. rm -f z50c.until0_04.$out_fmt z50c.until0_04.$in_fmt
  477. echo OK
  478. echo $ECHO_N "testing --until=mm:ss.sss (encode) $desc... " $ECHO_C
  479. run_flac $eopt --until=0:03.9001 -o z50c.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  480. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_03.9001.$in_fmt z50c.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
  481. $CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
  482. rm -f z50c.until0_03.9001.$out_fmt z50c.until0_03.9001.$in_fmt
  483. echo OK
  484. echo $ECHO_N "testing --until=-# (encode) $desc... " $ECHO_C
  485. run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  486. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
  487. $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
  488. rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
  489. echo OK
  490. echo $ECHO_N "testing --until=-mm:ss (encode) $desc... " $ECHO_C
  491. run_flac $eopt --until=-0:01 -o z50c.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  492. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.$in_fmt z50c.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
  493. $CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
  494. rm -f z50c.until-0_01.$out_fmt z50c.until-0_01.$in_fmt
  495. echo OK
  496. echo $ECHO_N "testing --until=-mm:ss.sss (encode) $desc... " $ECHO_C
  497. run_flac $eopt --until=-0:01.1001 -o z50c.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  498. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.1001.$in_fmt z50c.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
  499. $CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
  500. rm -f z50c.until-0_01.1001.$out_fmt z50c.until-0_01.1001.$in_fmt
  501. echo OK
  502. #
  503. # test --until when decoding
  504. #
  505. if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
  506. echo $ECHO_N "testing --until=# (decode) $desc... " $ECHO_C
  507. run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  508. $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
  509. rm -f z50c.until40.$in_fmt
  510. echo OK
  511. echo $ECHO_N "testing --until=mm:ss (decode) $desc... " $ECHO_C
  512. run_flac $dopt --until=0:04 -o z50c.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  513. $CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
  514. rm -f z50c.until0_04.$in_fmt
  515. echo OK
  516. echo $ECHO_N "testing --until=mm:ss.sss (decode) $desc... " $ECHO_C
  517. run_flac $dopt --until=0:03.9001 -o z50c.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  518. $CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
  519. rm -f z50c.until0_03.9001.$in_fmt
  520. echo OK
  521. echo $ECHO_N "testing --until=-# (decode) $desc... " $ECHO_C
  522. run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  523. $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
  524. rm -f z50c.until-10.$in_fmt
  525. echo OK
  526. echo $ECHO_N "testing --until=-mm:ss (decode) $desc... " $ECHO_C
  527. run_flac $dopt --until=-0:01 -o z50c.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  528. $CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
  529. rm -f z50c.until-0_01.$in_fmt
  530. echo OK
  531. echo $ECHO_N "testing --until=-mm:ss.sss (decode) $desc... " $ECHO_C
  532. run_flac $dopt --until=-0:01.1001 -o z50c.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  533. $CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
  534. rm -f z50c.until-0_01.1001.$in_fmt
  535. echo OK
  536. rm -f z50c.$out_fmt
  537. #
  538. # test --skip and --until when encoding
  539. #
  540. echo $ECHO_N "testing --skip=10 --until=# (encode) $desc... " $ECHO_C
  541. run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  542. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
  543. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
  544. rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
  545. echo OK
  546. echo $ECHO_N "testing --skip=10 --until=mm:ss (encode) $desc... " $ECHO_C
  547. run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  548. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_04.$in_fmt z50c.skip10.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc"
  549. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
  550. rm -f z50c.skip10.until0_04.$out_fmt z50c.skip10.until0_04.$in_fmt
  551. echo OK
  552. echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (encode) $desc... " $ECHO_C
  553. run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  554. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_03.9001.$in_fmt z50c.skip10.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
  555. $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) $desc"
  556. rm -f z50c.skip10.until0_03.9001.$out_fmt z50c.skip10.until0_03.9001.$in_fmt
  557. echo OK
  558. echo $ECHO_N "testing --skip=10 --until=+# (encode) $desc... " $ECHO_C
  559. run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  560. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
  561. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
  562. rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
  563. echo OK
  564. echo $ECHO_N "testing --skip=10 --until=+mm:ss (encode) $desc... " $ECHO_C
  565. run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0_03.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  566. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_03.$in_fmt z50c.skip10.until+0_03.$out_fmt || die "ERROR decoding FLAC file $desc"
  567. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+0_03.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) $desc"
  568. rm -f z50c.skip10.until+0_03.$out_fmt z50c.skip10.until+0_03.$in_fmt
  569. echo OK
  570. echo $ECHO_N "testing --skip=10 --until=+mm:ss.sss (encode) $desc... " $ECHO_C
  571. run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0_02.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  572. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_02.9001.$in_fmt z50c.skip10.until+0_02.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
  573. $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until+0_02.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode) $desc"
  574. rm -f z50c.skip10.until+0_02.9001.$out_fmt z50c.skip10.until+0_02.9001.$in_fmt
  575. echo OK
  576. echo $ECHO_N "testing --skip=10 --until=-# (encode) $desc... " $ECHO_C
  577. run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  578. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
  579. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
  580. rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
  581. echo OK
  582. echo $ECHO_N "testing --skip=10 --until=-mm:ss (encode) $desc... " $ECHO_C
  583. run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  584. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.$in_fmt z50c.skip10.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
  585. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) $desc"
  586. rm -f z50c.skip10.until-0_01.$out_fmt z50c.skip10.until-0_01.$in_fmt
  587. echo OK
  588. echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (encode) $desc... " $ECHO_C
  589. run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  590. [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.1001.$in_fmt z50c.skip10.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
  591. $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode) $desc"
  592. rm -f z50c.skip10.until-0_01.1001.$out_fmt z50c.skip10.until-0_01.1001.$in_fmt
  593. echo OK
  594. #
  595. # test --skip and --until when decoding
  596. #
  597. if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
  598. echo $ECHO_N "testing --skip=10 --until=# (decode) $desc... " $ECHO_C
  599. run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  600. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
  601. rm -f z50c.skip10.until40.$in_fmt
  602. echo OK
  603. echo $ECHO_N "testing --skip=10 --until=mm:ss (decode) $desc... " $ECHO_C
  604. run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  605. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
  606. rm -f z50c.skip10.until0_04.$in_fmt
  607. echo OK
  608. echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (decode) $desc... " $ECHO_C
  609. run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  610. $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) $desc"
  611. rm -f z50c.skip10.until0_03.9001.$in_fmt
  612. echo OK
  613. echo $ECHO_N "testing --skip=10 --until=-# (decode) $desc... " $ECHO_C
  614. run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  615. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
  616. rm -f z50c.skip10.until-10.$in_fmt
  617. echo OK
  618. echo $ECHO_N "testing --skip=10 --until=-mm:ss (decode) $desc... " $ECHO_C
  619. run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  620. $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) $desc"
  621. rm -f z50c.skip10.until-0_01.$in_fmt
  622. echo OK
  623. echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (decode) $desc... " $ECHO_C
  624. run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
  625. $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode) $desc"
  626. rm -f z50c.skip10.until-0_01.1001.$in_fmt
  627. echo OK
  628. rm -f z50c.$out_fmt
  629. }
  630. test_skip_until raw flac
  631. test_skip_until wav flac
  632. test_skip_until aiff flac
  633. test_skip_until flac flac
  634. #@@@if [ $has_ogg = yes ] ; then
  635. #@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
  636. #@@@ test_skip_until ogg flac
  637. #@@@fi
  638. if [ $has_ogg = yes ] ; then
  639. test_skip_until raw ogg
  640. test_skip_until wav ogg
  641. test_skip_until aiff ogg
  642. #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
  643. #@@@test_skip_until flac ogg
  644. #@@@test_skip_until ogg ogg
  645. fi
  646. echo "testing seek extremes:"
  647. run_flac --verify --force --no-padding --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 noise.raw || die "ERROR generating FLAC file"
  648. if [ $is_win = no ] ; then
  649. total_noise_cdda_samples="$(run_metaflac --show-total-samples noise.flac)"
  650. [ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
  651. else
  652. # some flavors of cygwin don't seem to treat the \x0d as a word
  653. # separator, so we hard code it. we'll just have to fix it later
  654. # if we change the way noise.flac is made.
  655. total_noise_cdda_samples=393216
  656. fi
  657. echo $ECHO_N "testing --skip=0... " $ECHO_C
  658. run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
  659. echo OK
  660. for delta in 2 1 ; do
  661. n=$((total_noise_cdda_samples - delta))
  662. echo $ECHO_N "testing --skip=$n... " $ECHO_C
  663. run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
  664. echo OK
  665. done
  666. rm noise.flac z.wav
  667. ############################################################################
  668. # test --input-size
  669. ############################################################################
  670. #@@@ cat will not work on old cygwin, need to fix
  671. if [ $is_win = no ] ; then
  672. echo $ECHO_N "testing --input-size=50 --skip=10... " $ECHO_C
  673. run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - < 50c.raw || die "ERROR generating FLAC file"
  674. run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
  675. cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
  676. rm -f z50c.skip10.raw z50c.skip10.flac
  677. echo OK
  678. fi
  679. ############################################################################
  680. # test --output-prefix
  681. ############################################################################
  682. in_dir=./tmp_in
  683. out_dir=./tmp_out
  684. mkdir $in_dir $out_dir || die "ERROR failed to create temp directories"
  685. cp 50c.raw 50c.flac $in_dir
  686. #
  687. # test --output-prefix when encoding
  688. #
  689. echo $ECHO_N "testing --output-prefix=$out_dir/ (encode)... " $ECHO_C
  690. run_flac $raw_eopt --output-prefix=$out_dir/ $in_dir/50c.raw || die "ERROR generating FLAC file in $out_dir (encode)"
  691. [ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (encode)"
  692. run_flac $raw_dopt $out_dir/50c.flac || die "ERROR decoding FLAC file (encode)"
  693. [ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (encode)"
  694. cmp 50c.raw $out_dir/50c.raw || die "ERROR: file mismatch for --output-prefix=$out_dir (encode)"
  695. rm -f $out_dir/50c.flac $out_dir/50c.raw
  696. echo OK
  697. #
  698. # test --ouput-prefix when decoding
  699. #
  700. echo $ECHO_N "testing --output-prefix=$out_dir/ (decode)... " $ECHO_C
  701. run_flac $raw_dopt --output-prefix=$out_dir/ $in_dir/50c.flac || die "ERROR deocding FLAC file in $out_dir (decode)"
  702. [ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (decode)"
  703. run_flac $raw_eopt $out_dir/50c.raw || die "ERROR generating FLAC file (decode)"
  704. [ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (decode)"
  705. cmp 50c.flac $out_dir/50c.flac || die "ERROR: file mismatch for --output-prefix=$out_dir (decode)"
  706. rm -f $out_dir/50c.flac $out_dir/50c.raw
  707. echo OK
  708. rm -rf $in_dir $out_dir
  709. ############################################################################
  710. # test --cue
  711. ############################################################################
  712. #
  713. # create the cue sheet
  714. #
  715. cuesheet=cuetest.cue
  716. cat > $cuesheet << EOF
  717. CATALOG 1234567890123
  718. FILE "blah" WAVE
  719. TRACK 01 AUDIO
  720. INDEX 01 0
  721. INDEX 02 10
  722. INDEX 03 20
  723. TRACK 02 AUDIO
  724. INDEX 01 30
  725. TRACK 04 AUDIO
  726. INDEX 01 40
  727. EOF
  728. test_cue ()
  729. {
  730. in_fmt=$1
  731. out_fmt=$2
  732. [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
  733. [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
  734. if [ $in_fmt = raw ] ; then
  735. eopt="$raw_eopt"
  736. dopt="$raw_dopt"
  737. else
  738. eopt="$wav_eopt"
  739. dopt="$wav_dopt"
  740. fi
  741. if [ $in_fmt = flac -o $in_fmt = ogg ] && [ $out_fmt = flac -o $out_fmt = ogg ]; then
  742. CMP=md5cmp
  743. else
  744. CMP=cmp
  745. fi
  746. if [ $out_fmt = ogg ] ; then
  747. eopt="--ogg $eopt"
  748. fi
  749. desc="($in_fmt<->$out_fmt)"
  750. #
  751. # for this we need just need just one FLAC file; --cue only works while decoding
  752. #
  753. run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
  754. # To make it easy to translate from cue point to sample numbers, the
  755. # file has a sample rate of 10 Hz and a cuesheet like so:
  756. #
  757. # TRACK 01, INDEX 01 : 0:00.00 -> sample 0
  758. # TRACK 01, INDEX 02 : 0:01.00 -> sample 10
  759. # TRACK 01, INDEX 03 : 0:02.00 -> sample 20
  760. # TRACK 02, INDEX 01 : 0:03.00 -> sample 30
  761. # TRACK 04, INDEX 01 : 0:04.00 -> sample 40
  762. #
  763. echo $ECHO_N "testing --cue=- $desc... " $ECHO_C
  764. run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  765. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
  766. rm -f z50c.cued.$in_fmt
  767. echo OK
  768. echo $ECHO_N "testing --cue=1.0 $desc... " $ECHO_C
  769. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  770. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
  771. rm -f z50c.cued.$in_fmt
  772. echo OK
  773. echo $ECHO_N "testing --cue=1.0- $desc... " $ECHO_C
  774. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  775. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
  776. rm -f z50c.cued.$in_fmt
  777. echo OK
  778. echo $ECHO_N "testing --cue=1.1 $desc... " $ECHO_C
  779. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  780. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
  781. rm -f z50c.cued.$in_fmt
  782. echo OK
  783. echo $ECHO_N "testing --cue=1.1- $desc... " $ECHO_C
  784. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  785. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
  786. rm -f z50c.cued.$in_fmt
  787. echo OK
  788. echo $ECHO_N "testing --cue=1.2 $desc... " $ECHO_C
  789. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  790. $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
  791. rm -f z50c.cued.$in_fmt
  792. echo OK
  793. echo $ECHO_N "testing --cue=1.2- $desc... " $ECHO_C
  794. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  795. $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
  796. rm -f z50c.cued.$in_fmt
  797. echo OK
  798. echo $ECHO_N "testing --cue=1.4 $desc... " $ECHO_C
  799. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  800. $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
  801. rm -f z50c.cued.$in_fmt
  802. echo OK
  803. echo $ECHO_N "testing --cue=1.4- $desc... " $ECHO_C
  804. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  805. $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
  806. rm -f z50c.cued.$in_fmt
  807. echo OK
  808. echo $ECHO_N "testing --cue=-5.0 $desc... " $ECHO_C
  809. run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  810. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
  811. rm -f z50c.cued.$in_fmt
  812. echo OK
  813. echo $ECHO_N "testing --cue=-4.1 $desc... " $ECHO_C
  814. run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  815. $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
  816. rm -f z50c.cued.$in_fmt
  817. echo OK
  818. echo $ECHO_N "testing --cue=-3.1 $desc... " $ECHO_C
  819. run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  820. $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
  821. rm -f z50c.cued.$in_fmt
  822. echo OK
  823. echo $ECHO_N "testing --cue=-1.4 $desc... " $ECHO_C
  824. run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  825. $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
  826. rm -f z50c.cued.$in_fmt
  827. echo OK
  828. echo $ECHO_N "testing --cue=1.0-5.0 $desc... " $ECHO_C
  829. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  830. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
  831. rm -f z50c.cued.$in_fmt
  832. echo OK
  833. echo $ECHO_N "testing --cue=1.1-5.0 $desc... " $ECHO_C
  834. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  835. $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
  836. rm -f z50c.cued.$in_fmt
  837. echo OK
  838. echo $ECHO_N "testing --cue=1.2-4.1 $desc... " $ECHO_C
  839. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  840. $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
  841. rm -f z50c.cued.$in_fmt
  842. echo OK
  843. echo $ECHO_N "testing --cue=1.4-2.0 $desc... " $ECHO_C
  844. run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
  845. $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
  846. rm -f z50c.cued.$in_fmt
  847. echo OK
  848. rm -f z50c.cue.$out_fmt
  849. }
  850. test_cue raw flac
  851. test_cue wav flac
  852. test_cue aiff flac
  853. test_cue flac flac
  854. #@@@if [ $has_ogg = yes ] ; then
  855. #@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
  856. #@@@ test_cue ogg flac
  857. #@@@fi
  858. if [ $has_ogg = yes ] ; then
  859. test_cue raw ogg
  860. test_cue wav ogg
  861. test_cue aiff ogg
  862. #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
  863. #@@@test_cue flac ogg
  864. #@@@test_cue ogg ogg
  865. fi
  866. ############################################################################
  867. # test 'fixup' code that happens when a FLAC file with total_samples == 0
  868. # in the STREAMINFO block is converted to WAVE or AIFF, requiring the
  869. # decoder go back and fix up the chunk headers
  870. ############################################################################
  871. echo $ECHO_N "WAVE fixup test... " $ECHO_C
  872. echo $ECHO_N "prepare... " $ECHO_C
  873. convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
  874. echo $ECHO_N "encode... " $ECHO_C
  875. # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
  876. # binary-mode stdin problem, so we use an undocumented option to metaflac to
  877. # set the total sample count to 0
  878. if [ $is_win = yes ] ; then
  879. run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
  880. run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
  881. else
  882. run_flac $raw_eopt - -c < noise.raw > fixup.flac || die "ERROR generating FLAC file"
  883. fi
  884. echo $ECHO_N "decode... " $ECHO_C
  885. run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
  886. echo $ECHO_N "compare... " $ECHO_C
  887. cmp noise.wav fixup.wav || die "ERROR: file mismatch"
  888. echo OK
  889. rm -f noise.wav fixup.wav fixup.flac
  890. echo $ECHO_N "AIFF fixup test... " $ECHO_C
  891. echo $ECHO_N "prepare... " $ECHO_C
  892. convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
  893. echo $ECHO_N "encode... " $ECHO_C
  894. # the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
  895. # binary-mode stdin problem, so we use an undocumented option to metaflac to
  896. # set the total sample count to 0
  897. if [ $is_win = yes ] ; then
  898. run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
  899. run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
  900. else
  901. run_flac $raw_eopt - -c < noise.raw > fixup.flac || die "ERROR generating FLAC file"
  902. fi
  903. echo $ECHO_N "decode... " $ECHO_C
  904. run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
  905. echo $ECHO_N "compare... " $ECHO_C
  906. cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
  907. echo OK
  908. rm -f noise.aiff fixup.aiff fixup.flac
  909. ############################################################################
  910. # multi-file tests
  911. ############################################################################
  912. echo "Generating multiple input files from noise..."
  913. multifile_format_decode="--endian=big --sign=signed"
  914. multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding"
  915. short_noise_cdda_samples=$((total_noise_cdda_samples / 8))
  916. run_flac --verify --force --force-raw-format $multifile_format_encode --until=$short_noise_cdda_samples -o shortnoise.flac noise.raw || die "ERROR generating FLAC file"
  917. run_flac --decode --force shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
  918. run_flac --decode --force shortnoise.flac || die "ERROR generating WAVE file"
  919. run_flac --decode --force shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
  920. cp shortnoise.flac file0.flac
  921. cp shortnoise.flac file1.flac
  922. cp shortnoise.flac file2.flac
  923. rm -f shortnoise.flac
  924. cp shortnoise.wav file0.wav
  925. cp shortnoise.wav file1.wav
  926. cp shortnoise.wav file2.wav
  927. rm -f shortnoise.wav
  928. cp shortnoise.aiff file0.aiff
  929. cp shortnoise.aiff file1.aiff
  930. cp shortnoise.aiff file2.aiff
  931. rm -f shortnoise.aiff
  932. cp shortnoise.raw file0.raw
  933. cp shortnoise.raw file1.raw
  934. cp shortnoise.raw file2.raw
  935. rm -f shortnoise.raw
  936. test_multifile ()
  937. {
  938. input_type=$1
  939. streamtype=$2
  940. encode_options="$3"
  941. extra_encode_options=""
  942. extra_decode_options=""
  943. if [ $input_type = "raw" ] ; then
  944. extra_encode_options="--force-raw-format $multifile_format_encode"
  945. extra_decode_options="--force-raw-format $multifile_format_decode"
  946. else
  947. if [ $input_type = "aiff" ] ; then
  948. extra_decode_options="--force-aiff-format"
  949. fi
  950. fi
  951. if [ $streamtype = ogg ] ; then
  952. suffix=oga
  953. encode_options="$encode_options --ogg"
  954. else
  955. suffix=flac
  956. fi
  957. if [ $input_type = flac ] || [ $input_type = ogg ] ; then
  958. CMP=md5cmp
  959. else
  960. CMP=cmp
  961. fi
  962. for n in 0 1 2 ; do
  963. cp file$n.$input_type file${n}x.$input_type
  964. done
  965. run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
  966. run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
  967. for n in 0 1 2 ; do
  968. $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
  969. done
  970. for n in 0 1 2 ; do
  971. rm -f file${n}x.$suffix file${n}x.$input_type
  972. done
  973. }
  974. input_types="raw wav aiff flac"
  975. #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
  976. #@@@if [ $has_ogg = yes ] ; then
  977. #@@@ input_types="$input_types ogg"
  978. #@@@fi
  979. for input_type in $input_types ; do
  980. echo "Testing multiple $input_type files without verify..."
  981. test_multifile $input_type flac ""
  982. echo "Testing multiple $input_type files with verify..."
  983. test_multifile $input_type flac "--verify"
  984. if [ $has_ogg = yes ] ; then
  985. echo "Testing multiple $input_type files with --ogg, without verify..."
  986. test_multifile $input_type ogg ""
  987. echo "Testing multiple $input_type files with --ogg, with verify..."
  988. test_multifile $input_type ogg "--verify"
  989. echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
  990. test_multifile $input_type ogg "--serial-number=321 --verify"
  991. fi
  992. done
  993. ############################################################################
  994. # test --keep-foreign-metadata
  995. ############################################################################
  996. echo "Testing --keep-foreign-metadata..."
  997. rt_test_wav wacky1.wav '--keep-foreign-metadata'
  998. rt_test_wav wacky2.wav '--keep-foreign-metadata'
  999. rt_test_w64 wacky1.w64 '--keep-foreign-metadata'
  1000. rt_test_w64 wacky2.w64 '--keep-foreign-metadata'
  1001. rt_test_rf64 wacky1.rf64 '--keep-foreign-metadata'
  1002. rt_test_rf64 wacky2.rf64 '--keep-foreign-metadata'
  1003. rt_test_wav_autokf wacky1.wav '--keep-foreign-metadata'
  1004. rt_test_wav_autokf wacky2.wav '--keep-foreign-metadata'
  1005. rt_test_w64_autokf wacky1.w64 '--keep-foreign-metadata'
  1006. rt_test_w64_autokf wacky2.w64 '--keep-foreign-metadata'
  1007. rt_test_rf64_autokf wacky1.rf64 '--keep-foreign-metadata'
  1008. rt_test_rf64_autokf wacky2.rf64 '--keep-foreign-metadata'
  1009. testdatadir=${top_srcdir}/test/foreign-metadata-test-files
  1010. rt_test_autokf "$testdatadir/BWF-WaveFmtEx.wav" '--keep-foreign-metadata' 'rt.wav'
  1011. rt_test_autokf "$testdatadir/AIFF-ID3.aiff" '--keep-foreign-metadata' 'rt.aiff'
  1012. rt_test_autokf "$testdatadir/AIFF-C-sowt-tag.aifc" '--keep-foreign-metadata' 'rt.aifc'
  1013. rt_test_autokf "$testdatadir/AIFF-C-sowt-compression-type-name.aifc" '--keep-foreign-metadata' 'rt.aifc'
  1014. rt_test_autokf "$testdatadir/24bit-WaveFmtPCM.wav" '--keep-foreign-metadata' 'rt.wav'
  1015. ############################################################################
  1016. # test the metadata-handling properties of flac-to-flac encoding
  1017. ############################################################################
  1018. echo "Testing the metadata-handling properties of flac-to-flac encoding..."
  1019. testdatadir=${top_srcdir}/test/flac-to-flac-metadata-test-files
  1020. filter ()
  1021. {
  1022. # minor danger, changing vendor strings might change the length of the
  1023. # VORBIS_COMMENT block, but if we add "^ length: " to the patterns,
  1024. # we lose info about PADDING size that we need
  1025. grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//'
  1026. }
  1027. flac2flac ()
  1028. {
  1029. file="$testdatadir/$1"
  1030. case="$testdatadir/$2"
  1031. args="$3"
  1032. expect="$case-expect.meta"
  1033. echo $ECHO_N "$2... " $ECHO_C
  1034. # The 'make distcheck' target needs this.
  1035. chmod u+w $file
  1036. run_flac -f -o out.flac $args $file || die "ERROR encoding FLAC file"
  1037. run_metaflac --list out.flac | filter > out1.meta || die "ERROR listing metadata of output FLAC file"
  1038. # Ignore lengths which can be affected by the version string.
  1039. sed "s/length:.*/length: XXX/" out1.meta > out.meta
  1040. diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
  1041. echo OK
  1042. }
  1043. #filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: '
  1044. # case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
  1045. flac2flac input-SCVAUP.flac case00a ""
  1046. # case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
  1047. flac2flac input-SCVPAP.flac case01a ""
  1048. # case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
  1049. flac2flac input-SCVPAP.flac case01b "--no-padding"
  1050. # case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
  1051. flac2flac input-SCVPAP.flac case01c "-P 1234"
  1052. # case 01d: on file with no PADDING blocks, use -P setting
  1053. flac2flac input-SCVA.flac case01d "-P 1234"
  1054. # case 01e: on file with no PADDING blocks and no -P given, use default padding
  1055. flac2flac input-SCVA.flac case01e ""
  1056. # case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
  1057. flac2flac input-SCPAP.flac case02a ""
  1058. # case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
  1059. flac2flac input-SCPAP.flac case02b "--tag=artist=0"
  1060. # case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
  1061. flac2flac input-SCVAUP.flac case02c "--tag=artist=0"
  1062. # case 03a: on file with no CUESHEET block and --cuesheet specified, add it
  1063. flac2flac input-SVAUP.flac case03a "--cuesheet=$testdatadir/input0.cue"
  1064. # case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
  1065. flac2flac input-SCVAUP.flac case03b "--cuesheet=$testdatadir/input0.cue"
  1066. # case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
  1067. flac2flac input-SCVAUP.flac case03c "--skip=1"
  1068. # case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
  1069. flac2flac input-VA.flac case04a "--no-padding --no-seektable"
  1070. # case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
  1071. flac2flac input-VA.flac case04b "--no-padding -S 5x"
  1072. # case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
  1073. flac2flac input-VA.flac case04c "--no-padding"
  1074. # case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
  1075. flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
  1076. # case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
  1077. flac2flac input-SCVA.flac case04e "--no-padding -S 5x"
  1078. # case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
  1079. #(already covered by case03c)
  1080. ############################################################################
  1081. # test limiting minimum bitrate
  1082. ############################################################################
  1083. echo $ECHO_N "Testing --limit-min-bitrate" $ECHO_C
  1084. run_flac -f -o out.flac --no-padding --no-seektable --limit-min-bitrate "$testdatadir/input-VA.flac"
  1085. size=$(wc -c < out.flac)
  1086. if [ "$size" -lt "1022" ]; then
  1087. die "ERROR: filesize of flac file encoded with --limit-min-bitrate is smaller than expected"
  1088. fi
  1089. echo OK
  1090. ############################################################################
  1091. # test overflow of total samples field in STREAMINFO
  1092. ############################################################################
  1093. test_total_samples_overflow ()
  1094. {
  1095. total_samples=$1
  1096. expected_stored_total_samples=$2
  1097. echo $ECHO_N "total_samples overflow test (samples=$total_samples) encode... " $ECHO_C
  1098. head -c $total_samples /dev/zero | run_flac --force --verify --sign=signed --sample-rate=96000 -b 16384 --channels=1 --endian=little --bps=8 -o big-$total_samples.flac - || die "ERROR"
  1099. echo $ECHO_N "decode... " $ECHO_C
  1100. run_flac -t big-$total_samples.flac || die "ERROR"
  1101. echo $ECHO_N "check... " $ECHO_C
  1102. run_metaflac --show-total-samples big-$total_samples.flac > big-$total_samples.cmp1
  1103. echo $expected_stored_total_samples > big-$total_samples.cmp2
  1104. diff -q -w big-$total_samples.cmp1 big-$total_samples.cmp2 || die "ERROR"
  1105. echo "OK"
  1106. rm -f big-$total_samples.flac big-$total_samples.cmp1 big-$total_samples.cmp2
  1107. }
  1108. if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
  1109. test_total_samples_overflow 68719476735 68719476735
  1110. test_total_samples_overflow 68719476736 0
  1111. test_total_samples_overflow 68719476737 0
  1112. fi
  1113. ############################################################################
  1114. # test handling of UTF-8 filenames
  1115. ############################################################################
  1116. test_utf8_handling ()
  1117. {
  1118. echo $ECHO_N "Test decoding from $1... " $ECHO_C
  1119. run_flac -d $testdatadir/$1 -o out.wav
  1120. if [ -f out.wav ] ; then
  1121. echo "OK"
  1122. else
  1123. die "Decoding failed"
  1124. fi
  1125. echo $ECHO_N "Test encoding to $1... " $ECHO_C
  1126. run_flac out.wav -o $1
  1127. if [ -f $1 ] ; then
  1128. echo "OK"
  1129. else
  1130. die "Encoding failed"
  1131. fi
  1132. rm -f $1 out.wav
  1133. }
  1134. if [ "$WIN32BUSYBOX" != "yes" ]; then
  1135. test_utf8_handling שלום.flac
  1136. test_utf8_handling 🤔.flac
  1137. test_utf8_handling Prøve.flac
  1138. fi
  1139. rm -f out.flac out.meta out1.meta
  1140. #@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
  1141. cd ..