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