Commit d1ade6c1 authored by Monty's avatar Monty

Make the 'make check' cover all the uncoupled codebooks


svn path=/trunk/vorbis/; revision=17023
parent 0ee3ca0f
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
static int check_output (const float * data_in, unsigned len); static int check_output (const float * data_in, unsigned len, float allowable);
int int
main(void){ main(void){
...@@ -38,28 +38,32 @@ main(void){ ...@@ -38,28 +38,32 @@ main(void){
int sample_rates [] = { 44100, 48000, 32000, 22050, 16000, 96000 } ; int sample_rates [] = { 44100, 48000, 32000, 22050, 16000, 96000 } ;
unsigned k ; unsigned k ;
int errors = 0 ; int errors = 0 ;
float q=-.05;
gen_windowed_sine (data_out, ARRAY_LEN (data_out), 0.95); gen_windowed_sine (data_out, ARRAY_LEN (data_out), 0.95);
for (k = 0 ; k < ARRAY_LEN (sample_rates); k ++) { while(q<1.){
char filename [64] ; for (k = 0 ; k < ARRAY_LEN (sample_rates); k ++) {
snprintf (filename, sizeof (filename), "vorbis_%u.ogg", sample_rates [k]); char filename [64] ;
snprintf (filename, sizeof (filename), "vorbis_q%.1f_%u.ogg", q*10,sample_rates [k]);
printf (" %-20s : ", filename); printf (" %-20s : ", filename);
fflush (stdout); fflush (stdout);
/* Set to know value. */ /* Set to know value. */
set_data_in (data_in, ARRAY_LEN (data_in), 3.141); set_data_in (data_in, ARRAY_LEN (data_in), 3.141);
write_vorbis_data_or_die (filename, sample_rates [k], data_out, ARRAY_LEN (data_out)); write_vorbis_data_or_die (filename, sample_rates [k], q, data_out, ARRAY_LEN (data_out));
read_vorbis_data_or_die (filename, sample_rates [k], data_in, ARRAY_LEN (data_in)); read_vorbis_data_or_die (filename, sample_rates [k], data_in, ARRAY_LEN (data_in));
if (check_output (data_in, ARRAY_LEN (data_in)) != 0) if (check_output (data_in, ARRAY_LEN (data_in), (.15f - .1f*q)) != 0)
errors ++ ; errors ++ ;
else { else {
puts ("ok"); puts ("ok");
remove (filename); remove (filename);
} }
}
q+=.1;
} }
if (errors) if (errors)
...@@ -69,7 +73,7 @@ main(void){ ...@@ -69,7 +73,7 @@ main(void){
} }
static int static int
check_output (const float * data_in, unsigned len) check_output (const float * data_in, unsigned len, float allowable)
{ {
float max_abs = 0.0 ; float max_abs = 0.0 ;
unsigned k ; unsigned k ;
...@@ -78,11 +82,11 @@ check_output (const float * data_in, unsigned len) ...@@ -78,11 +82,11 @@ check_output (const float * data_in, unsigned len)
float temp = fabs (data_in [k]); float temp = fabs (data_in [k]);
max_abs = MAX (max_abs, temp); max_abs = MAX (max_abs, temp);
} }
if (max_abs < 0.9) { if (max_abs < 0.95-allowable) {
printf ("Error : max_abs (%f) too small.\n", max_abs); printf ("Error : max_abs (%f) too small.\n", max_abs);
return 1 ; return 1 ;
} else if (max_abs > 1.0) { } else if (max_abs > .95+allowable) {
printf ("Error : max_abs (%f) too big.\n", max_abs); printf ("Error : max_abs (%f) too big.\n", max_abs);
return 1 ; return 1 ;
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/* The following function is basically a hacked version of the code in /* The following function is basically a hacked version of the code in
* examples/encoder_example.c */ * examples/encoder_example.c */
void void
write_vorbis_data_or_die (const char *filename, int srate, const float * data, int count) write_vorbis_data_or_die (const char *filename, int srate, float q, const float * data, int count)
{ {
FILE * file ; FILE * file ;
ogg_stream_state os; ogg_stream_state os;
...@@ -51,7 +51,7 @@ write_vorbis_data_or_die (const char *filename, int srate, const float * data, i ...@@ -51,7 +51,7 @@ write_vorbis_data_or_die (const char *filename, int srate, const float * data, i
vorbis_info_init (&vi); vorbis_info_init (&vi);
ret = vorbis_encode_init_vbr (&vi,1,srate,0.8); ret = vorbis_encode_init_vbr (&vi,1,srate,q);
if (ret) { if (ret) {
printf ("vorbis_encode_init_vbr return %d\n", ret) ; printf ("vorbis_encode_init_vbr return %d\n", ret) ;
exit (1) ; exit (1) ;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
/* Write supplied data to an Ogg/Vorbis file with specified filename at /* Write supplied data to an Ogg/Vorbis file with specified filename at
* specified sample rate. Assumes a single channel of audio. */ * specified sample rate. Assumes a single channel of audio. */
void write_vorbis_data_or_die (const char *filename, int srate, void write_vorbis_data_or_die (const char *filename, int srate, float q,
const float * data, int count) ; const float * data, int count) ;
/* Read given Ogg/Vorbis file into data specified data array. This /* Read given Ogg/Vorbis file into data specified data array. This
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment