VirtualBox

source: vbox/trunk/src/libs/libvorbis-1.3.7/test/test.c@ 99132

Last change on this file since 99132 was 96468, checked in by vboxsync, 2 years ago

libs/libvorbis-1.3.7: Re-exporting, hopefully this time everything is there. bugref:10275

File size: 2.8 KB
Line 
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
9 * by the Xiph.Org Foundation https://xiph.org/ *
10 * *
11 ********************************************************************
12
13 function: vorbis coded test suite using vorbisfile
14
15 ********************************************************************/
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <math.h>
20
21#include "util.h"
22#include "write_read.h"
23
24#define DATA_LEN 2048
25
26#define MAX(a,b) ((a) > (b) ? (a) : (b))
27
28
29static int check_output (const float * data_in, unsigned len, float allowable);
30
31int
32main(void){
33 static float data_out [DATA_LEN] ;
34 static float data_in [DATA_LEN] ;
35
36 /* Do safest and most used sample rates first. */
37 int sample_rates [] = { 44100, 48000, 32000, 22050, 16000, 96000 } ;
38 unsigned k ;
39 int errors = 0 ;
40 int ch;
41
42 gen_windowed_sine (data_out, ARRAY_LEN (data_out), 0.95);
43
44 for(ch=1;ch<=8;ch++){
45 float q=-.05;
46 printf("\nTesting %d channel%s\n\n",ch,ch==1?"":"s");
47 while(q<1.){
48 for (k = 0 ; k < ARRAY_LEN (sample_rates); k ++) {
49 char filename [64] ;
50 snprintf (filename, sizeof (filename), "vorbis_%dch_q%.1f_%u.ogg", ch,q*10,sample_rates [k]);
51
52 printf (" %-20s : ", filename);
53 fflush (stdout);
54
55 /* Set to know value. */
56 set_data_in (data_in, ARRAY_LEN (data_in), 3.141);
57
58 write_vorbis_data_or_die (filename, sample_rates [k], q, data_out, ARRAY_LEN (data_out),ch);
59 read_vorbis_data_or_die (filename, sample_rates [k], data_in, ARRAY_LEN (data_in));
60
61 if (check_output (data_in, ARRAY_LEN (data_in), (.15f - .1f*q)) != 0)
62 errors ++ ;
63 else {
64 puts ("ok");
65 remove (filename);
66 }
67 }
68 q+=.1;
69 }
70 }
71
72 if (errors)
73 exit (1);
74
75 return 0;
76}
77
78static int
79check_output (const float * data_in, unsigned len, float allowable)
80{
81 float max_abs = 0.0 ;
82 unsigned k ;
83
84 for (k = 0 ; k < len ; k++) {
85 float temp = fabs (data_in [k]);
86 max_abs = MAX (max_abs, temp);
87 }
88
89 if (max_abs < 0.95-allowable) {
90 printf ("Error : max_abs (%f) too small.\n", max_abs);
91 return 1 ;
92 } else if (max_abs > .95+allowable) {
93 printf ("Error : max_abs (%f) too big.\n", max_abs);
94 return 1 ;
95 }
96
97 return 0 ;
98}
99
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette