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
16 ********************************************************************/
22 #include "vorbis/codec.h"
23 #include "codec_internal.h"
31 /* decides between modes, dispatches to the appropriate mapping. */
32 int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
34 vorbis_block_internal *vbi=vb->internal;
41 /* first things first. Make sure encode is ready */
42 for(i=0;i<PACKETBLOBS;i++)
43 oggpack_reset(vbi->packetblob[i]);
45 /* we only have one mapping type (0), and we let the mapping code
46 itself figure out what soft mode to use. This allows easier
49 if((ret=_mapping_P[0]->forward(vb)))
53 if(vorbis_bitrate_managed(vb))
54 /* The app is using a bitmanaged mode... but not using the
55 bitrate management interface. */
58 op->packet=oggpack_get_buffer(&vb->opb);
59 op->bytes=oggpack_bytes(&vb->opb);
61 op->e_o_s=vb->eofflag;
62 op->granulepos=vb->granulepos;
63 op->packetno=vb->sequence; /* for sake of completeness */
68 /* there was no great place to put this.... */
69 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]);
105 void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
107 if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);