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-2002 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: single-block PCM analysis mode dispatch
14 last mod: $Id: analysis.c,v 1.55 2002/07/11 06:40:48 xiphmont Exp $
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){
40 /* first things first. Make sure encode is ready */
41 oggpack_reset(&vb->opb);
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 */
66 /* there was no great place to put this.... */
67 void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){
73 sprintf(buffer,"%s_%d.m",base,i);
76 if(!of)perror("failed to open data dump file");
80 float b=toBARK((4000.f*j/n)+.25);
84 fprintf(of,"%f ",(double)(j+off)/8000.);
86 fprintf(of,"%f ",(double)j);
94 fprintf(of,"%f\n",val);
96 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);