2
0

scale_clip_test.tpl 16 KB

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