Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Vorbis
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
Vorbis
Commits
ed677ec7
Unverified
Commit
ed677ec7
authored
Jul 22, 2017
by
Philipp Schafft
🦁
Committed by
Ralph Giles
Jul 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: Removed tailing white-spaces in C code files
Signed-off-by:
Ralph Giles
<
giles@thaumas.net
>
parent
88502ee7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
164 additions
and
164 deletions
+164
-164
examples/decoder_example.c
examples/decoder_example.c
+33
-33
examples/seeking_example.c
examples/seeking_example.c
+3
-3
examples/vorbisfile_example.c
examples/vorbisfile_example.c
+3
-3
lib/psytune.c
lib/psytune.c
+32
-32
lib/synthesis.c
lib/synthesis.c
+1
-1
lib/tone.c
lib/tone.c
+2
-2
vq/bookutil.c
vq/bookutil.c
+14
-14
vq/distribution.c
vq/distribution.c
+16
-16
vq/huffbuild.c
vq/huffbuild.c
+8
-8
vq/latticebuild.c
vq/latticebuild.c
+5
-5
vq/latticetune.c
vq/latticetune.c
+8
-8
vq/metrics.c
vq/metrics.c
+13
-13
vq/vqgen.c
vq/vqgen.c
+26
-26
No files found.
examples/decoder_example.c
View file @
ed677ec7
...
...
@@ -74,7 +74,7 @@ int main(){
/********** Decode setup ************/
ogg_sync_init
(
&
oy
);
/* Now we can read pages */
while
(
1
){
/* we repeat if the bitstream is chained */
int
eos
=
0
;
int
i
;
...
...
@@ -88,60 +88,60 @@ int main(){
buffer
=
ogg_sync_buffer
(
&
oy
,
4096
);
bytes
=
fread
(
buffer
,
1
,
4096
,
stdin
);
ogg_sync_wrote
(
&
oy
,
bytes
);
/* Get the first page. */
if
(
ogg_sync_pageout
(
&
oy
,
&
og
)
!=
1
){
/* have we simply run out of data? If so, we're done. */
if
(
bytes
<
4096
)
break
;
/* error case. Must not be Vorbis data */
fprintf
(
stderr
,
"Input does not appear to be an Ogg bitstream.
\n
"
);
exit
(
1
);
}
/* Get the serial number and set up the rest of decode. */
/* serialno first; use it to set up a logical stream */
ogg_stream_init
(
&
os
,
ogg_page_serialno
(
&
og
));
/* extract the initial header from the first page and verify that the
Ogg bitstream is in fact Vorbis data */
/* I handle the initial header first instead of just having the code
read all three Vorbis headers at once because reading the initial
header is an easy way to identify a Vorbis bitstream and it's
useful to see that functionality seperated out. */
vorbis_info_init
(
&
vi
);
vorbis_comment_init
(
&
vc
);
if
(
ogg_stream_pagein
(
&
os
,
&
og
)
<
0
){
if
(
ogg_stream_pagein
(
&
os
,
&
og
)
<
0
){
/* error; stream version mismatch perhaps */
fprintf
(
stderr
,
"Error reading first page of Ogg bitstream data.
\n
"
);
exit
(
1
);
}
if
(
ogg_stream_packetout
(
&
os
,
&
op
)
!=
1
){
if
(
ogg_stream_packetout
(
&
os
,
&
op
)
!=
1
){
/* no page? must not be vorbis */
fprintf
(
stderr
,
"Error reading initial header packet.
\n
"
);
exit
(
1
);
}
if
(
vorbis_synthesis_headerin
(
&
vi
,
&
vc
,
&
op
)
<
0
){
if
(
vorbis_synthesis_headerin
(
&
vi
,
&
vc
,
&
op
)
<
0
){
/* error case; not a vorbis header */
fprintf
(
stderr
,
"This Ogg bitstream does not contain Vorbis "
"audio data.
\n
"
);
exit
(
1
);
}
/* At this point, we're sure we're Vorbis. We've set up the logical
(Ogg) bitstream decoder. Get the comment and codebook headers and
set up the Vorbis decoder */
/* The next two packets in order are the comment and codebook headers.
They're likely large and may span multiple pages. Thus we read
and submit data until we get our two packets, watching that no
pages are missing. If a page is missing, error out; losing a
header page is the only place where missing data is fatal. */
i
=
0
;
while
(
i
<
2
){
while
(
i
<
2
){
...
...
@@ -180,7 +180,7 @@ int main(){
}
ogg_sync_wrote
(
&
oy
,
bytes
);
}
/* Throw the comments plus a few lines about the bitstream we're
decoding */
{
...
...
@@ -192,7 +192,7 @@ int main(){
fprintf
(
stderr
,
"
\n
Bitstream is %d channel, %ldHz
\n
"
,
vi
.
channels
,
vi
.
rate
);
fprintf
(
stderr
,
"Encoded by: %s
\n\n
"
,
vc
.
vendor
);
}
convsize
=
4096
/
vi
.
channels
;
/* OK, got and parsed all three headers. Initialize the Vorbis
...
...
@@ -203,7 +203,7 @@ int main(){
proceed in parallel. We could init
multiple vorbis_block structures
for vd here */
/* The rest is just a straight decode loop until end of stream */
while
(
!
eos
){
while
(
!
eos
){
...
...
@@ -217,7 +217,7 @@ int main(){
this point */
while
(
1
){
result
=
ogg_stream_packetout
(
&
os
,
&
op
);
if
(
result
==
0
)
break
;
/* need more data */
if
(
result
<
0
){
/* missing or corrupt data at this page position */
/* no reason to complain; already complained above */
...
...
@@ -225,21 +225,21 @@ int main(){
/* we have a packet. Decode it */
float
**
pcm
;
int
samples
;
if
(
vorbis_synthesis
(
&
vb
,
&
op
)
==
0
)
/* test for success! */
vorbis_synthesis_blockin
(
&
vd
,
&
vb
);
/*
/*
**pcm is a multichannel float vector. In stereo, for
example, pcm[0] is left, and pcm[1] is right. samples is
the size of each channel. Convert the float values
(-1.<=range<=1.) to whatever PCM format and write it out */
while
((
samples
=
vorbis_synthesis_pcmout
(
&
vd
,
&
pcm
))
>
0
){
int
j
;
int
clipflag
=
0
;
int
bout
=
(
samples
<
convsize
?
samples
:
convsize
);
/* convert floats to 16 bit signed ints (host order) and
interleave */
for
(
i
=
0
;
i
<
vi
.
channels
;
i
++
){
...
...
@@ -264,17 +264,17 @@ int main(){
ptr
+=
vi
.
channels
;
}
}
if
(
clipflag
)
fprintf
(
stderr
,
"Clipping in frame %ld
\n
"
,(
long
)(
vd
.
sequence
));
fwrite
(
convbuffer
,
2
*
vi
.
channels
,
bout
,
stdout
);
vorbis_synthesis_read
(
&
vd
,
bout
);
/* tell libvorbis how
many samples we
actually consumed */
}
}
}
}
if
(
ogg_page_eos
(
&
og
))
eos
=
1
;
...
...
@@ -287,10 +287,10 @@ int main(){
if
(
bytes
==
0
)
eos
=
1
;
}
}
/* ogg_page and ogg_packet structs always point to storage in
libvorbis. They're never freed or manipulated directly */
vorbis_block_clear
(
&
vb
);
vorbis_dsp_clear
(
&
vd
);
}
else
{
...
...
@@ -299,7 +299,7 @@ int main(){
/* clean up this logical bitstream; before exit we see if we're
followed by another [chained] */
ogg_stream_clear
(
&
os
);
vorbis_comment_clear
(
&
vc
);
vorbis_info_clear
(
&
vi
);
/* must be called last */
...
...
@@ -307,7 +307,7 @@ int main(){
/* OK, clean up the framer */
ogg_sync_clear
(
&
oy
);
fprintf
(
stderr
,
"Done.
\n
"
);
return
(
0
);
}
examples/seeking_example.c
View file @
ed677ec7
...
...
@@ -213,7 +213,7 @@ int main(){
{
fprintf
(
stderr
,
"testing time page seeking to random places in %f seconds....
\n
"
,
timelength
);
for
(
i
=
0
;
i
<
1000
;
i
++
){
double
val
=
(
double
)
rand
()
/
RAND_MAX
*
timelength
;
fprintf
(
stderr
,
"
\r\t
%d [time position %f]... "
,
i
,
val
);
...
...
@@ -232,7 +232,7 @@ int main(){
{
fprintf
(
stderr
,
"testing time exact seeking to random places in %f seconds....
\n
"
,
timelength
);
for
(
i
=
0
;
i
<
1000
;
i
++
){
double
val
=
(
double
)
rand
()
/
RAND_MAX
*
timelength
;
fprintf
(
stderr
,
"
\r\t
%d [time position %f]... "
,
i
,
val
);
...
...
@@ -251,7 +251,7 @@ int main(){
}
}
fprintf
(
stderr
,
"
\r
\n
OK.
\n\n
"
);
...
...
examples/vorbisfile_example.c
View file @
ed677ec7
...
...
@@ -37,7 +37,7 @@ int main(){
int
current_section
;
#ifdef _WIN32
/* We need to set stdin/stdout to binary mode. Damn windows. */
/* Beware the evil ifdef. We avoid these where we can, but this one we
/* Beware the evil ifdef. We avoid these where we can, but this one we
cannot. Don't add any more, you'll probably go to hell if you do. */
_setmode
(
_fileno
(
stdin
),
_O_BINARY
);
_setmode
(
_fileno
(
stdout
),
_O_BINARY
);
...
...
@@ -62,7 +62,7 @@ int main(){
(
long
)
ov_pcm_total
(
&
vf
,
-
1
));
fprintf
(
stderr
,
"Encoded by: %s
\n\n
"
,
ov_comment
(
&
vf
,
-
1
)
->
vendor
);
}
while
(
!
eof
){
long
ret
=
ov_read
(
&
vf
,
pcmout
,
sizeof
(
pcmout
),
0
,
2
,
1
,
&
current_section
);
if
(
ret
==
0
)
{
...
...
@@ -85,7 +85,7 @@ int main(){
/* cleanup */
ov_clear
(
&
vf
);
fprintf
(
stderr
,
"Done.
\n
"
);
return
(
0
);
}
lib/psytune.c
View file @
ed677ec7
...
...
@@ -40,11 +40,11 @@
static
vorbis_info_psy_global
_psy_set0G
=
{
0
,
/* decaydBpms */
8
,
/* lines per eighth octave */
/* thresh sample period, preecho clamp trigger threshhold, range, minenergy */
256
,
{
26
.
f
,
26
.
f
,
26
.
f
,
30
.
f
},
{
-
90
.
f
,
-
90
.
f
,
-
90
.
f
,
-
90
.
f
},
-
90
.
f
,
-
6
.
f
,
-
6
.
f
,
0
,
0
.,
...
...
@@ -67,7 +67,7 @@ static vp_couple _vp_couple0[]={
static
vorbis_info_psy
_psy_set0
=
{
ATH_Bark_dB_lineaggressive
,
-
100
.
f
,
-
140
.
f
,
6
.
f
,
/* floor master att */
...
...
@@ -147,7 +147,7 @@ static vorbis_info_psy _psy_set0={
.
900
f
,
0
.
f
,
/*11500*/
.
900
f
,
1
.
f
,
/*16000*/
},
95
.
f
,
/* even decade + 5 is important; saves an rint() later in a
tight loop) */
-
44
.,
...
...
@@ -158,7 +158,7 @@ static vorbis_info_psy _psy_set0={
static
vorbis_info_floor1
_floor_set0
=
{
1
,
{
0
},
{
32
},
{
0
},
{
0
},
...
...
@@ -170,12 +170,12 @@ static vorbis_info_floor1 _floor_set0={1,
88
,
31
,
243
,
14
,
54
,
143
,
460
,
6
,
3
,
10
,
22
,
18
,
26
,
41
,
36
,
47
,
69
,
61
,
78
,
112
,
99
,
126
,
185
,
162
,
211
,
6
,
3
,
10
,
22
,
18
,
26
,
41
,
36
,
47
,
69
,
61
,
78
,
112
,
99
,
126
,
185
,
162
,
211
,
329
,
282
,
387
,
672
,
553
,
825
},
60
,
30
,
400
,
20
,
8
,
1
,
18
.,
20
,
600
,
...
...
@@ -183,8 +183,8 @@ static vorbis_info_floor1 _floor_set0={1,
static
vorbis_info_mapping0
mapping_info
=
{
1
,{
0
,
1
},{
0
},{
0
},{
0
},
0
,
1
,
{
0
},{
1
}};
static
codec_setup_info
codec_setup0
=
{
{
0
,
0
},
1
,
1
,
1
,
1
,
1
,
0
,
1
,
static
codec_setup_info
codec_setup0
=
{
{
0
,
0
},
1
,
1
,
1
,
1
,
1
,
0
,
1
,
{
NULL
},
{
0
},{
&
mapping_info
},
{
0
},{
NULL
},
...
...
@@ -193,7 +193,7 @@ static codec_setup_info codec_setup0={ {0,0},
{
NULL
},
{
&
_psy_set0
},
&
_psy_set0G
};
static
int
noisy
=
0
;
void
analysis
(
char
*
base
,
int
i
,
float
*
v
,
int
n
,
int
bark
,
int
dB
){
if
(
noisy
){
...
...
@@ -211,7 +211,7 @@ void analysis(char *base,int i,float *v,int n,int bark,int dB){
fprintf
(
of
,
"%g "
,
toBARK
(
22050
.
f
*
j
/
n
));
else
fprintf
(
of
,
"%g "
,(
float
)
j
);
if
(
dB
){
fprintf
(
of
,
"%g
\n
"
,
todB
(
v
+
j
));
}
else
{
...
...
@@ -268,7 +268,7 @@ int main(int argc,char *argv[]){
framesize
=
atoi
(
argv
[
0
]);
argv
++
;
}
vi
.
channels
=
2
;
vi
.
codec_setup
=&
codec_setup0
;
...
...
@@ -291,7 +291,7 @@ int main(int argc,char *argv[]){
/* we cheat on the WAV header; we just bypass 44 bytes and never
verify that it matches 16bit/stereo/44.1kHz. */
fread
(
buffer
,
1
,
44
,
stdin
);
fwrite
(
buffer
,
1
,
44
,
stdout
);
memset
(
buffer
,
0
,
framesize
*
2
);
...
...
@@ -301,10 +301,10 @@ int main(int argc,char *argv[]){
fprintf
(
stderr
,
"Processing for frame size %d...
\n
"
,
framesize
);
while
(
!
eos
){
long
bytes
=
fread
(
buffer2
,
1
,
framesize
*
2
,
stdin
);
long
bytes
=
fread
(
buffer2
,
1
,
framesize
*
2
,
stdin
);
if
(
bytes
<
framesize
*
2
)
memset
(
buffer2
+
bytes
,
0
,
framesize
*
2
-
bytes
);
if
(
bytes
!=
0
){
int
nonzero
[
2
];
...
...
@@ -315,10 +315,10 @@ int main(int argc,char *argv[]){
pcm
[
1
][
i
]
=
((
buffer
[
i
*
4
+
3
]
<<
8
)
|
(
0x00ff
&
(
int
)
buffer
[
i
*
4
+
2
]))
/
32768
.
f
;
}
{
float
secs
=
framesize
/
44100
.;
ampmax
+=
secs
*
ampmax_att_per_sec
;
if
(
ampmax
<-
9999
)
ampmax
=-
9999
;
}
...
...
@@ -330,11 +330,11 @@ int main(int argc,char *argv[]){
float
*
logmdct
=
mdct
+
framesize
/
2
;
analysis
(
"pre"
,
frameno
+
i
,
pcm
[
i
],
framesize
,
0
,
0
);
/* fft and mdct transforms */
for
(
j
=
0
;
j
<
framesize
;
j
++
)
fft
[
j
]
=
pcm
[
i
][
j
]
*=
window
[
j
];
drft_forward
(
&
f_look
,
fft
);
local_ampmax
[
i
]
=-
9999
.
f
;
...
...
@@ -346,7 +346,7 @@ int main(int argc,char *argv[]){
if
(
temp
>
local_ampmax
[
i
])
local_ampmax
[
i
]
=
temp
;
}
if
(
local_ampmax
[
i
]
>
ampmax
)
ampmax
=
local_ampmax
[
i
];
mdct_forward
(
&
m_look
,
pcm
[
i
],
mdct
);
for
(
j
=
0
;
j
<
framesize
/
2
;
j
++
)
logmdct
[
j
]
=
todB
(
mdct
+
j
);
...
...
@@ -390,7 +390,7 @@ int main(int argc,char *argv[]){
logmdct
,
mask
,
logmax
,
flr
[
i
]);
}
...
...
@@ -405,7 +405,7 @@ int main(int argc,char *argv[]){
for
(
j
=
0
;
j
<
framesize
/
2
;
j
++
)
if
(
fabs
(
pcm
[
i
][
j
])
>
1500
)
fprintf
(
stderr
,
"%ld "
,
frameno
+
i
);
analysis
(
"res"
,
frameno
+
i
,
pcm
[
i
],
framesize
/
2
,
1
,
0
);
analysis
(
"codedflr"
,
frameno
+
i
,
flr
[
i
],
framesize
/
2
,
1
,
1
);
}
...
...
@@ -415,7 +415,7 @@ int main(int argc,char *argv[]){
&
vi
,
pcm
,
nonzero
);
for
(
i
=
0
;
i
<
2
;
i
++
)
analysis
(
"quant"
,
frameno
+
i
,
pcm
[
i
],
framesize
/
2
,
1
,
0
);
...
...
@@ -425,7 +425,7 @@ int main(int argc,char *argv[]){
&
mapping_info
,
pcm
,
nonzero
);
for
(
i
=
0
;
i
<
2
;
i
++
)
analysis
(
"coupled"
,
frameno
+
i
,
pcm
[
i
],
framesize
/
2
,
1
,
0
);
...
...
@@ -433,11 +433,11 @@ int main(int argc,char *argv[]){
for
(
i
=
mapping_info
.
coupling_steps
-
1
;
i
>=
0
;
i
--
){
float
*
pcmM
=
pcm
[
mapping_info
.
coupling_mag
[
i
]];
float
*
pcmA
=
pcm
[
mapping_info
.
coupling_ang
[
i
]];
for
(
j
=
0
;
j
<
framesize
/
2
;
j
++
){
float
mag
=
pcmM
[
j
];
float
ang
=
pcmA
[
j
];
if
(
mag
>
0
)
if
(
ang
>
0
){
pcmM
[
j
]
=
mag
;
...
...
@@ -456,7 +456,7 @@ int main(int argc,char *argv[]){
}
}
}
for
(
i
=
0
;
i
<
2
;
i
++
)
analysis
(
"decoupled"
,
frameno
+
i
,
pcm
[
i
],
framesize
/
2
,
1
,
0
);
...
...
@@ -478,7 +478,7 @@ int main(int argc,char *argv[]){
}
/* write data. Use the part of buffer we're about to shift out */
for
(
i
=
0
;
i
<
2
;
i
++
){
char
*
ptr
=
buffer
+
i
*
2
;
...
...
@@ -502,7 +502,7 @@ int main(int argc,char *argv[]){
ptr
+=
4
;
}
}
fprintf
(
stderr
,
"*"
);
fwrite
(
buffer
,
1
,
framesize
*
2
,
stdout
);
memmove
(
buffer
,
buffer2
,
framesize
*
2
);
...
...
lib/synthesis.c
View file @
ed677ec7
...
...
@@ -116,7 +116,7 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
if
(
!
ci
->
mode_param
[
mode
]){
return
(
OV_EBADPACKET
);
}
vb
->
W
=
ci
->
mode_param
[
mode
]
->
blockflag
;
if
(
vb
->
W
){
vb
->
lW
=
oggpack_read
(
opb
,
1
);
...
...
lib/tone.c
View file @
ed677ec7
...
...
@@ -12,7 +12,7 @@ int main (int argc,char *argv[]){
int
i
,
j
;
double
*
f
;
double
*
amp
;
if
(
argc
<
2
)
usage
();
f
=
alloca
(
sizeof
(
*
f
)
*
(
argc
-
1
));
...
...
@@ -21,7 +21,7 @@ int main (int argc,char *argv[]){
i
=
0
;
while
(
argv
[
i
+
1
]){
char
*
pos
=
strchr
(
argv
[
i
+
1
],
','
);
f
[
i
]
=
atof
(
argv
[
i
+
1
]);
if
(
pos
)
amp
[
i
]
=
atof
(
pos
+
1
)
*
32767
.
f
;
...
...
vq/bookutil.c
View file @
ed677ec7
...
...
@@ -90,7 +90,7 @@ char *get_line(FILE *in){
while
(
!
gotline
){
if
(
sofar
+
1
>=
lbufsize
){
if
(
!
lbufsize
){
if
(
!
lbufsize
){
lbufsize
=
1024
;
linebuffer
=
_ogg_malloc
(
lbufsize
);
}
else
{
...
...
@@ -115,7 +115,7 @@ char *get_line(FILE *in){
}
}
}
if
(
linebuffer
[
0
]
==
'#'
){
sofar
=
0
;
}
else
{
...
...
@@ -196,7 +196,7 @@ int get_vector(codebook *b,FILE *in,int start, int n,float *a){
for
(
i
=
1
;
i
<
c
->
dim
;
i
++
)
if
(
get_line_value
(
in
,
a
+
i
))
break
;
if
(
i
==
c
->
dim
){
float
temp
=
a
[
c
->
dim
-
1
];
for
(
i
=
0
;
i
<
c
->
dim
;
i
++
)
a
[
i
]
-=
sequence_base
;
...
...
@@ -260,7 +260,7 @@ codebook *codebook_load(char *filename){
fprintf
(
stderr
,
"1: syntax in %s in line:
\t
%s"
,
filename
,
line
);
exit
(
1
);
}
switch
(
c
->
maptype
){
case
0
:
quant_to_read
=
0
;
...
...
@@ -272,7 +272,7 @@ codebook *codebook_load(char *filename){
quant_to_read
=
c
->
entries
*
c
->
dim
;
break
;
}
/* load the quantized entries */
find_seek_to
(
in
,
"static const long _vq_quantlist_"
);
reset_next_value
();
...
...
@@ -282,7 +282,7 @@ codebook *codebook_load(char *filename){
fprintf
(
stderr
,
"out of data while reading codebook %s
\n
"
,
filename
);
exit
(
1
);
}
/* load the lengthlist */
find_seek_to
(
in
,
"_lengthlist"
);
reset_next_value
();
...
...
@@ -295,7 +295,7 @@ codebook *codebook_load(char *filename){
/* got it all */
fclose
(
in
);
vorbis_book_init_encode
(
b
,
c
);
b
->
valuelist
=
_book_unquantize
(
c
,
c
->
entries
,
NULL
);
...
...
@@ -347,9 +347,9 @@ void build_tree_from_lengths(int vals, long *hist, long *lengths){
for
(
i
=
vals
;
i
>
1
;
i
--
){
int
first
=-
1
,
second
=-
1
;
long
least
=-
1
;
spinnit
(
"building... "
,
i
);
/* find the two nodes to join */
for
(
j
=
0
;
j
<
vals
;
j
++
)
if
(
least
==-
1
||
hist
[
j
]
<=
least
){
...
...
@@ -366,7 +366,7 @@ void build_tree_from_lengths(int vals, long *hist, long *lengths){
fprintf
(
stderr
,
"huffman fault; no free branch
\n
"
);
exit
(
1
);
}
/* join them */
least
=
hist
[
first
]
+
hist
[
second
];
for
(
j
=
0
;
j
<
vals
;
j
++
)
...
...
@@ -420,9 +420,9 @@ void build_tree_from_lengths0(int vals, long *hist, long *lengths){
fprintf
(
stderr
,
"
\r
Eliminating %d unused entries; %d entries remain
\n
"
,
vals
-
upper
,
upper
);
}
build_tree_from_lengths
(
upper
,
newhist
,
lengthlist
);
upper
=
0
;
for
(
i
=
0
;
i
<
vals
;
i
++
)
if
(
hist
[
i
]
>
0
)
...
...
@@ -460,9 +460,9 @@ void write_codebook(FILE *out,char *name,const static_codebook *c){
fprintf
(
out
,
"};
\n\n
"
);
/* tie it all together */
fprintf
(
out
,
"static const static_codebook %s = {
\n
"
,
name
);
fprintf
(
out
,
"
\t
%ld, %ld,
\n
"
,
c
->
dim
,
c
->
entries
);
fprintf
(
out
,
"
\t
(char *)_vq_lengthlist_%s,
\n
"
,
name
);
fprintf
(
out
,
"
\t
%d, %ld, %ld, %d, %d,
\n
"
,
...
...
vq/distribution.c
View file @
ed677ec7
...
...
@@ -107,7 +107,7 @@ int main(int argc,char *argv[]){
if
(
c
->
lengthlist
[
j
]){
int
indexdiv
=
1
;
printf
(
"%4d: "
,
j
);
for
(
k
=
0
;
k
<
b
->
dim
;
k
++
){
for
(
k
=
0
;
k
<
b
->
dim
;
k
++
){
int
index
=
(
j
/
indexdiv
)
%
bins
;
printf
(
"%+3.1f,"
,
c
->
quantlist
[
index
]
*
_float32_unpack
(
c
->
q_delta
)
+
_float32_unpack
(
c
->
q_min
));
...
...
@@ -137,7 +137,7 @@ int main(int argc,char *argv[]){
long
maxcount
=
0
,
i
,
j
;
for
(
i
=
0
;
i
<
bins
;
i
++
)
if
(
countarray
[
i
]
>
maxcount
)
maxcount
=
countarray
[
i
];
for
(
i
=
0
;
i
<
bins
;
i
++
){
int
ptr
=
sort
[
i
]
-
c
->
quantlist
;
int
stars
=
rint
(
50
.
/
maxcount
*
countarray
[
ptr
]);
...
...
@@ -160,30 +160,30 @@ int main(int argc,char *argv[]){
/* do it the simple way; two pass. */
line
=
setup_line
(
in
);
while
(
line
){
while
(
line
){
float
code
;
char
buf
[
80
];
lines
++
;
sprintf
(
buf
,
"getting min/max (%.2f::%.2f). lines..."
,
min
,
max
);
if
(
!
(
lines
&
0xff
))
spinnit
(
buf
,
lines
);
while
(
!
flag
&&
sscanf
(
line
,
"%f"
,
&
code
)
==
1
){
line
=
strchr
(
line
,
','
);
min
=
max
=
code
;
flag
=
1
;
}
while
(
line
&&
sscanf
(
line
,
"%f"
,
&
code
)
==
1
){
line
=
strchr
(
line
,
','
);
if
(
line
)
line
++
;
if
(
code
<
min
)
min
=
code
;
if
(
code
>
max
)
max
=
code
;
}
line
=
setup_line
(
in
);
}
if
(
bins
<
1
){
if
((
int
)(
max
-
min
)
==
min
-
max
){
bins
=
max
-
min
;
...
...
@@ -191,43 +191,43 @@ int main(int argc,char *argv[]){
bins
=
25
;
}
}
printf
(
"
\r
\r
"
);
printf
(
"Minimum scalar value: %f
\n
"
,
min
);
printf
(
"Maximum scalar value: %f
\n
"
,
max
);
if
(
argv
[
2
]){
printf
(
"
\n
counting hits into %ld bins...
\n
"
,
bins
+
1
);
countarray
=
calloc
(
bins
+
1
,
sizeof
(
long
));
rewind
(
in
);
line
=
setup_line
(
in
);
while
(
line
){
while
(
line
){
float
code
;
lines
--
;
if
(
!
(
lines
&
0xff
))
spinnit
(
"counting distribution. lines so far..."
,
lines
);
while
(
line
&&
sscanf
(
line
,
"%f"
,
&
code
)
==
1
){
line
=
strchr
(
line
,
','
);
if
(
line
)
line
++
;
code
-=
min
;
code
/=
(
max
-
min
);
code
*=
bins
;
countarray
[(
int
)
rint
(
code
)]
++
;
total
++
;
}
line
=
setup_line
(
in
);
}
/* make a pretty graph */
{
long
maxcount
=
0
,
i
,
j
;
for
(
i
=
0
;
i
<
bins
+
1
;
i
++
)
if
(
countarray
[
i
]
>
maxcount
)
maxcount
=
countarray
[
i
];
printf
(
"
\r
\r
"
);
printf
(
"Total scalars: %ld
\n
"
,
total
);
for
(
i
=
0
;
i
<
bins
+
1
;
i
++
){
...
...
vq/huffbuild.c
View file @
ed677ec7
...
...
@@ -48,7 +48,7 @@ static int getval(FILE *in,int begin,int n,int group,int max){
static
void
usage
(){
fprintf
(
stderr
,
"usage:
\n
"
"usage:
\n
"
"huffbuild <input>.vqd <begin,n,group>|<lorange-hirange> [noguard]
\n
"
" where begin,n,group is first scalar,
\n
"
" number of scalars of each in line,
\n
"
...
...
@@ -117,7 +117,7 @@ int main(int argc, char *argv[]){
long
v
;
if
(
get_next_ivalue
(
file
,
&
v
))
break
;
if
(
v
>
maxval
)
maxval
=
v
;
if
(
!
(
i
++&
0xff
))
spinnit
(
"loading... "
,
i
);
}
rewind
(
file
);
...
...
@@ -128,9 +128,9 @@ int main(int argc, char *argv[]){
long
vals
=
pow
(
maxval
,
subn
);
long
*
hist
=
_ogg_calloc
(
vals
,
sizeof
(
long
));
long
*
lengths
=
_ogg_calloc
(
vals
,
sizeof
(
long
));
for
(
j
=
loval
;
j
<
vals
;
j
++
)
hist
[
j
]
=
guard
;
if
(
file
){
reset_next_value
();
i
/=
subn
;
...
...
@@ -142,7 +142,7 @@ int main(int argc, char *argv[]){
}
fclose
(
file
);
}
/* we have the probabilities, build the tree */
fprintf
(
stderr
,
"Building tree for %ld entries
\n
"
,
vals
);
build_tree_from_lengths0
(
vals
,
hist
,
lengths
);
...
...
@@ -158,7 +158,7 @@ int main(int argc, char *argv[]){
exit
(
1
);
}
}
/* first, the static vectors, then the book structure to tie it together. */
/* lengthlist */
fprintf
(
file
,
"static const char _huff_lengthlist_%s[] = {
\n
"
,
base
);
...
...
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]){