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