544da93408eb15979fc4a92222075408b92e5336
2 ** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #define SAMPLE_RATE 8000
35 const char * enc_name
;
36 const char * dec_name
;
45 { SF_FORMAT_RAW
| SF_FORMAT_ULAW
,
46 "checksum.ulaw", "cksum_ulaw.pcm16",
47 0x33aefae029e0c888LL
, 0x595cd6e47edd0cffLL
49 { SF_FORMAT_RAW
| SF_FORMAT_ALAW
,
50 "checksum.alaw", "cksum_alaw.pcm16",
51 0x48c798da3572d468LL
, 0x6837d74869af5bb6LL
53 { SF_FORMAT_RAW
| SF_FORMAT_GSM610
,
54 "checksum.gsm", "cksum_gsm.pcm16",
55 0x1b1f64ff2acf858fLL
, 0x504179dbadd4bce6LL
57 { SF_FORMAT_RAW
| SF_FORMAT_VOX_ADPCM
,
58 "checksum.vox", "cksum_vox.pcm16",
59 0xf1147fb3a298f4dfLL
, 0xfc9c0cb8b12cb0abLL
63 static void checksum_test (const CHECKSUM
* cksum
) ;
65 static float orig
[1 << 14] ;
66 static short data
[1 << 14] ;
72 gen_windowed_sine_float (orig
, ARRAY_LEN (orig
), 0.9) ;
74 for (k
= 0 ; k
< ARRAY_LEN (checksum_orig
) ; k
++)
75 checksum_test (&checksum_orig
[k
]) ;
80 /*==============================================================================
84 checksum_test (const CHECKSUM
* cksum
)
88 print_test_name (__func__
, cksum
->enc_name
) ;
90 info
.format
= cksum
->enc_fmt
;
92 info
.samplerate
= SAMPLE_RATE
;
94 file
= test_open_file_or_die (cksum
->enc_name
, SFM_WRITE
, &info
, 0, __LINE__
) ;
95 test_write_float_or_die (file
, 0, orig
, ARRAY_LEN (orig
), __LINE__
) ;
98 check_file_hash_or_die (cksum
->enc_name
, cksum
->enc_cksum
, __LINE__
) ;
101 /*------------------------------------------------------------------------*/
103 print_test_name (__func__
, cksum
->dec_name
) ;
105 info
.format
= cksum
->enc_fmt
;
107 info
.samplerate
= SAMPLE_RATE
;
109 file
= test_open_file_or_die (cksum
->enc_name
, SFM_READ
, &info
, 0, __LINE__
) ;
110 test_read_short_or_die (file
, 0, data
, ARRAY_LEN (data
), __LINE__
) ;
113 info
.format
= SF_ENDIAN_LITTLE
| SF_FORMAT_RAW
| SF_FORMAT_PCM_16
;
115 info
.samplerate
= SAMPLE_RATE
;
117 file
= test_open_file_or_die (cksum
->dec_name
, SFM_WRITE
, &info
, 0, __LINE__
) ;
118 test_write_short_or_die (file
, 0, data
, ARRAY_LEN (data
), __LINE__
) ;
121 check_file_hash_or_die (cksum
->dec_name
, cksum
->dec_cksum
, __LINE__
) ;
123 remove (cksum
->enc_name
) ;
124 remove (cksum
->dec_name
) ;
127 } /* checksum_test */