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 https://xiph.org/ *
11 ********************************************************************
13 function: single-block PCM analysis mode dispatch
15 ********************************************************************/
21 #include "vorbis/codec.h"
22 #include "codec_internal.h"
28 /* decides between modes, dispatches to the appropriate mapping. */
29 int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
31 vorbis_block_internal *vbi=vb->internal;
38 /* first things first. Make sure encode is ready */
39 for(i=0;i<PACKETBLOBS;i++)
40 oggpack_reset(vbi->packetblob[i]);
42 /* we only have one mapping type (0), and we let the mapping code
43 itself figure out what soft mode to use. This allows easier
46 if((ret=_mapping_P[0]->forward(vb)))
50 if(vorbis_bitrate_managed(vb))
51 /* The app is using a bitmanaged mode... but not using the
52 bitrate management interface. */
55 op->packet=oggpack_get_buffer(&vb->opb);
56 op->bytes=oggpack_bytes(&vb->opb);
58 op->e_o_s=vb->eofflag;
59 op->granulepos=vb->granulepos;
60 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){
74 sprintf(buffer,"%s_%d.m",base,i);
77 if(!of)perror("failed to open data dump file");
81 float b=toBARK((4000.f*j/n)+.25);
85 fprintf(of,"%f ",(double)(j+off)/8000.);
87 fprintf(of,"%f ",(double)j);
95 fprintf(of,"%f\n",val);
97 fprintf(of,"%f\n",v[j]);
103 void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
105 if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);