1 /********************************************************************
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. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
13 function: single-block PCM analysis mode dispatch
14 last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $
16 ********************************************************************/
22 #include "vorbis/codec.h"
23 #include "codec_internal.h"
29 /* decides between modes, dispatches to the appropriate mapping. */
30 int vorbis_analysis(vorbis_block
*vb
, ogg_packet
*op
){
32 vorbis_block_internal
*vbi
=vb
->internal
;
39 /* first things first. Make sure encode is ready */
40 for(i
=0;i
<PACKETBLOBS
;i
++)
41 oggpack_reset(vbi
->packetblob
[i
]);
43 /* we only have one mapping type (0), and we let the mapping code
44 itself figure out what soft mode to use. This allows easier
47 if((ret
=_mapping_P
[0]->forward(vb
)))
51 if(vorbis_bitrate_managed(vb
))
52 /* The app is using a bitmanaged mode... but not using the
53 bitrate management interface. */
56 op
->packet
=oggpack_get_buffer(&vb
->opb
);
57 op
->bytes
=oggpack_bytes(&vb
->opb
);
59 op
->e_o_s
=vb
->eofflag
;
60 op
->granulepos
=vb
->granulepos
;
61 op
->packetno
=vb
->sequence
; /* for sake of completeness */
69 /* there was no great place to put this.... */
70 void _analysis_output_always(char *base
,int i
,float *v
,int n
,int bark
,int dB
,ogg_int64_t off
){
75 sprintf(buffer
,"%s_%d.m",base
,i
);
78 if(!of
)perror("failed to open data dump file");
82 float b
=toBARK((4000.f
*j
/n
)+.25);
86 fprintf(of
,"%f ",(double)(j
+off
)/8000.);
88 fprintf(of
,"%f ",(double)j
);
96 fprintf(of
,"%f\n",val
);
98 fprintf(of
,"%f\n",v
[j
]);
104 void _analysis_output(char *base
,int i
,float *v
,int n
,int bark
,int dB
,
106 if(analysis_noisy
)_analysis_output_always(base
,i
,v
,n
,bark
,dB
,off
);