scale_clip_test.tpl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. [+ AutoGen5 template c +]
  2. /*
  3. ** Copyright (C) 1999-2012 Erik de Castro Lopo <[email protected]>
  4. **
  5. ** This program is free software; you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation; either version 2 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #include "sfconfig.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <math.h>
  24. #include <inttypes.h>
  25. #if HAVE_UNISTD_H
  26. #include <unistd.h>
  27. #else
  28. #include "sf_unistd.h"
  29. #endif
  30. #include <sndfile.h>
  31. #include "utils.h"
  32. #ifndef M_PI
  33. #define M_PI 3.14159265358979323846264338
  34. #endif
  35. #define HALF_BUFFER_SIZE (1 << 12)
  36. #define BUFFER_SIZE (2 * HALF_BUFFER_SIZE)
  37. #define SINE_AMP 1.1
  38. #define MAX_ERROR 0.0202
  39. [+ FOR float_type +]
  40. [+ FOR data_type
  41. +]static void [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) ;
  42. [+ ENDFOR data_type
  43. +][+ ENDFOR float_type +]
  44. [+ FOR float_type +]
  45. [+ FOR int_type
  46. +]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) ;
  47. [+ ENDFOR int_type
  48. +][+ ENDFOR float_type +]
  49. [+ FOR int_type +]
  50. [+ FOR float_type
  51. +]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) ;
  52. [+ ENDFOR float_type
  53. +][+ ENDFOR int_type +]
  54. typedef union
  55. { double dbl [BUFFER_SIZE] ;
  56. float flt [BUFFER_SIZE] ;
  57. int i [BUFFER_SIZE] ;
  58. short s [BUFFER_SIZE] ;
  59. } BUFFER ;
  60. /* Data buffer. */
  61. static BUFFER buffer_out ;
  62. static BUFFER buffer_in ;
  63. int
  64. main (void)
  65. {
  66. flt_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ;
  67. flt_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ;
  68. dbl_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ;
  69. dbl_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ;
  70. /*
  71. ** Now use SF_FORMAT_AU where possible because it allows both
  72. ** big and little endian files.
  73. */
  74. flt_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ;
  75. flt_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ;
  76. flt_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ;
  77. flt_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ;
  78. flt_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
  79. flt_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
  80. dbl_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ;
  81. dbl_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ;
  82. dbl_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ;
  83. dbl_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ;
  84. dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
  85. dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
  86. flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
  87. flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
  88. dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
  89. dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
  90. short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
  91. int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
  92. short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
  93. int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
  94. return 0 ;
  95. } /* main */
  96. /*============================================================================================
  97. ** Here are the test functions.
  98. */
  99. [+ FOR float_type +]
  100. [+ FOR data_type
  101. +]static void
  102. [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval)
  103. { SNDFILE *file ;
  104. SF_INFO sfinfo ;
  105. int k ;
  106. [+ (get "float_type_name") +] *data_out, *data_in ;
  107. double diff, clip_max_diff ;
  108. print_test_name ("[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +]", filename) ;
  109. data_out = buffer_out.[+ (get "float_short_name") +] ;
  110. data_in = buffer_in.[+ (get "float_short_name") +] ;
  111. for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
  112. { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ;
  113. data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ;
  114. } ;
  115. sfinfo.samplerate = 44100 ;
  116. sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
  117. sfinfo.channels = 1 ;
  118. sfinfo.format = filetype ;
  119. /*
  120. ** Write two versions of the data:
  121. ** normalized and clipped
  122. ** un-normalized and clipped.
  123. */
  124. file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
  125. sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
  126. test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, HALF_BUFFER_SIZE, __LINE__) ;
  127. sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;
  128. test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
  129. sf_close (file) ;
  130. memset (&buffer_in, 0, sizeof (buffer_in)) ;
  131. file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
  132. sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
  133. if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
  134. { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
  135. exit (1) ;
  136. } ;
  137. if (sfinfo.frames != BUFFER_SIZE)
  138. { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ;
  139. exit (1) ;
  140. } ;
  141. if (sfinfo.channels != 1)
  142. { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
  143. exit (1) ;
  144. } ;
  145. check_log_buffer_or_die (file, __LINE__) ;
  146. test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, HALF_BUFFER_SIZE, __LINE__) ;
  147. sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;
  148. test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ;
  149. sf_close (file) ;
  150. /* Check normalized version. */
  151. clip_max_diff = 0.0 ;
  152. for (k = 0 ; k < HALF_BUFFER_SIZE ; k++)
  153. { if (fabs (data_in [k]) > 1.0)
  154. { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ;
  155. exit (1) ;
  156. } ;
  157. if (data_out [k] * data_in [k] < 0.0)
  158. { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ;
  159. exit (1) ;
  160. } ;
  161. if (fabs (data_out [k]) > 1.0)
  162. continue ;
  163. diff = fabs (data_out [k] - data_in [k]) ;
  164. if (diff > clip_max_diff)
  165. clip_max_diff = diff ;
  166. } ;
  167. if (clip_max_diff < 1e-20)
  168. { printf ("\n\nLine %d: Clipping difference (%e) too small (normalized).\n\n", __LINE__, clip_max_diff) ;
  169. exit (1) ;
  170. } ;
  171. if (clip_max_diff > [+ (get "error_val") +])
  172. { printf ("\n\nLine %d: Clipping difference (%e) too large (normalized).\n\n", __LINE__, clip_max_diff) ;
  173. exit (1) ;
  174. } ;
  175. /* Check the un-normalized data. */
  176. clip_max_diff = 0.0 ;
  177. for (k = HALF_BUFFER_SIZE ; k < BUFFER_SIZE ; k++)
  178. { if (fabs (data_in [k]) > maxval)
  179. { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ;
  180. exit (1) ;
  181. } ;
  182. if (data_out [k] * data_in [k] < 0.0)
  183. { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ;
  184. exit (1) ;
  185. } ;
  186. if (fabs (data_out [k]) > maxval)
  187. continue ;
  188. diff = fabs (data_out [k] - data_in [k]) ;
  189. if (diff > clip_max_diff)
  190. clip_max_diff = diff ;
  191. } ;
  192. if (clip_max_diff < 1e-20)
  193. { printf ("\n\nLine %d: Clipping difference (%e) too small (un-normalized).\n\n", __LINE__, clip_max_diff) ;
  194. exit (1) ;
  195. } ;
  196. if (clip_max_diff > 1.0)
  197. { printf ("\n\nLine %d: Clipping difference (%e) too large (un-normalised).\n\n", __LINE__, clip_max_diff) ;
  198. exit (1) ;
  199. } ;
  200. printf ("ok\n") ;
  201. unlink (filename) ;
  202. } /* [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] */
  203. [+ ENDFOR data_type
  204. +]
  205. [+ ENDFOR float_type +]
  206. /*==============================================================================
  207. */
  208. [+ FOR float_type +]
  209. [+ FOR int_type
  210. +]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype)
  211. { SNDFILE *file ;
  212. SF_INFO sfinfo ;
  213. [+ (get "float_type_name") +] *data_out ;
  214. [+ (get "int_type_name") +] *data_in, max_value ;
  215. int k ;
  216. print_test_name ("[+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test", filename) ;
  217. data_out = buffer_out.[+ (get "float_short_name") +] ;
  218. data_in = buffer_in.[+ (get "int_short_name") +] ;
  219. for (k = 0 ; k < BUFFER_SIZE ; k++)
  220. data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ;
  221. data_out [BUFFER_SIZE / 8] = 1.0 ;
  222. data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ;
  223. data_out [5 * BUFFER_SIZE / 8] = 1.0 ;
  224. data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ;
  225. memset (&sfinfo, 0, sizeof (sfinfo)) ;
  226. sfinfo.samplerate = 44100 ;
  227. sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
  228. sfinfo.channels = 1 ;
  229. sfinfo.format = filetype ;
  230. /* Save unclipped data to the file. */
  231. file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
  232. test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
  233. sf_close (file) ;
  234. memset (&sfinfo, 0, sizeof (sfinfo)) ;
  235. file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
  236. sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
  237. sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
  238. if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
  239. { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
  240. exit (1) ;
  241. } ;
  242. if (sfinfo.frames != BUFFER_SIZE)
  243. { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ;
  244. exit (1) ;
  245. } ;
  246. if (sfinfo.channels != 1)
  247. { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
  248. exit (1) ;
  249. } ;
  250. check_log_buffer_or_die (file, __LINE__) ;
  251. sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
  252. test_read_[+ (get "int_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
  253. /*-sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;-*/
  254. sf_close (file) ;
  255. /* Check the first half. */
  256. max_value = 0 ;
  257. for (k = 0 ; k < sfinfo.frames ; k++)
  258. { /* Check if data_out has different sign from data_in. */
  259. if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0))
  260. { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ;
  261. exit (1) ;
  262. } ;
  263. max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ;
  264. } ;
  265. unlink (filename) ;
  266. puts ("ok") ;
  267. } /* [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test */
  268. [+ ENDFOR int_type
  269. +][+ ENDFOR float_type +]
  270. /*==============================================================================
  271. */
  272. [+ FOR int_type +]
  273. [+ FOR float_type
  274. +]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype)
  275. { SNDFILE *file ;
  276. SF_INFO sfinfo ;
  277. [+ (get "int_type_name") +] *data_out ;
  278. [+ (get "float_type_name") +] *data_in, max_value ;
  279. int k ;
  280. print_test_name ("[+ (get "int_type_name") +]_[+ (get "float_short_name") +]_clip_write_test", filename) ;
  281. data_out = buffer_out.[+ (get "int_short_name") +] ;
  282. data_in = buffer_in.[+ (get "float_short_name") +] ;
  283. for (k = 0 ; k < BUFFER_SIZE ; k++)
  284. data_out [k] = [+ (get "float_to_int") +] ([+ (get "int_max_value") +] * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
  285. memset (&sfinfo, 0, sizeof (sfinfo)) ;
  286. sfinfo.samplerate = 44100 ;
  287. sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
  288. sfinfo.channels = 1 ;
  289. sfinfo.format = filetype ;
  290. file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
  291. test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
  292. sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
  293. test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
  294. sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
  295. test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
  296. sf_close (file) ;
  297. memset (&sfinfo, 0, sizeof (sfinfo)) ;
  298. file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
  299. sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
  300. if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
  301. { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
  302. exit (1) ;
  303. } ;
  304. if (sfinfo.frames != 3 * BUFFER_SIZE)
  305. { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, 3 * BUFFER_SIZE, sfinfo.frames) ;
  306. exit (1) ;
  307. } ;
  308. if (sfinfo.channels != 1)
  309. { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
  310. exit (1) ;
  311. } ;
  312. check_log_buffer_or_die (file, __LINE__) ;
  313. /* Check the first section. */
  314. test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
  315. max_value = 0.0 ;
  316. for (k = 0 ; k < BUFFER_SIZE ; k++)
  317. max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
  318. if (max_value < 1000.0)
  319. { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
  320. exit (1) ;
  321. } ;
  322. /* Check the second section. */
  323. test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
  324. max_value = 0.0 ;
  325. for (k = 0 ; k < BUFFER_SIZE ; k++)
  326. max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
  327. if (max_value > 1.0)
  328. { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
  329. exit (1) ;
  330. } ;
  331. /* Check the third section. */
  332. test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
  333. max_value = 0.0 ;
  334. for (k = 0 ; k < BUFFER_SIZE ; k++)
  335. max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
  336. if (max_value < 1000.0)
  337. { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
  338. exit (1) ;
  339. } ;
  340. sf_close (file) ;
  341. unlink (filename) ;
  342. puts ("ok") ;
  343. } /* [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test */
  344. [+ ENDFOR float_type
  345. +][+ ENDFOR int_type +]