michael@0: /******************************************************************** michael@0: * * michael@0: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * michael@0: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * michael@0: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * michael@0: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * michael@0: * * michael@0: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * michael@0: * by the Xiph.Org Foundation http://www.xiph.org/ * michael@0: * * michael@0: ******************************************************************** michael@0: michael@0: function: single-block PCM analysis mode dispatch michael@0: last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $ michael@0: michael@0: ********************************************************************/ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include "vorbis/codec.h" michael@0: #include "codec_internal.h" michael@0: #include "registry.h" michael@0: #include "scales.h" michael@0: #include "os.h" michael@0: #include "misc.h" michael@0: michael@0: /* decides between modes, dispatches to the appropriate mapping. */ michael@0: int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ michael@0: int ret,i; michael@0: vorbis_block_internal *vbi=vb->internal; michael@0: michael@0: vb->glue_bits=0; michael@0: vb->time_bits=0; michael@0: vb->floor_bits=0; michael@0: vb->res_bits=0; michael@0: michael@0: /* first things first. Make sure encode is ready */ michael@0: for(i=0;ipacketblob[i]); michael@0: michael@0: /* we only have one mapping type (0), and we let the mapping code michael@0: itself figure out what soft mode to use. This allows easier michael@0: bitrate management */ michael@0: michael@0: if((ret=_mapping_P[0]->forward(vb))) michael@0: return(ret); michael@0: michael@0: if(op){ michael@0: if(vorbis_bitrate_managed(vb)) michael@0: /* The app is using a bitmanaged mode... but not using the michael@0: bitrate management interface. */ michael@0: return(OV_EINVAL); michael@0: michael@0: op->packet=oggpack_get_buffer(&vb->opb); michael@0: op->bytes=oggpack_bytes(&vb->opb); michael@0: op->b_o_s=0; michael@0: op->e_o_s=vb->eofflag; michael@0: op->granulepos=vb->granulepos; michael@0: op->packetno=vb->sequence; /* for sake of completeness */ michael@0: } michael@0: return(0); michael@0: } michael@0: michael@0: #ifdef ANALYSIS michael@0: int analysis_noisy=1; michael@0: michael@0: /* there was no great place to put this.... */ michael@0: void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ michael@0: int j; michael@0: FILE *of; michael@0: char buffer[80]; michael@0: michael@0: sprintf(buffer,"%s_%d.m",base,i); michael@0: of=fopen(buffer,"w"); michael@0: michael@0: if(!of)perror("failed to open data dump file"); michael@0: michael@0: for(j=0;j