X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fanalysis.c;h=14919737eb5779ba8ba2da301e0db3bda8eaac71;hb=ed77529436987db979f3703cbbedd5dae2dd551c;hp=b7152cba7a8cec66f1bb798d65b65ae01bc85c7f;hpb=a8ef3e3319b6f9fddc7745b363ef0c58c0e27a5f;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/analysis.c b/lib/analysis.c index b7152cb..1491973 100644 --- a/lib/analysis.c +++ b/lib/analysis.c @@ -1,36 +1,34 @@ /******************************************************************** * * - * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY * - * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. * - * PLEASE READ THESE TERMS DISTRIBUTING. * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 * - * by Monty and The XIPHOPHORUS Company * - * http://www.xiph.org/ * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: single-block PCM analysis mode dispatch - last mod: $Id: analysis.c,v 1.31 2000/07/12 09:36:17 xiphmont Exp $ ********************************************************************/ #include #include #include +#include #include "vorbis/codec.h" -#include "bitwise.h" +#include "codec_internal.h" #include "registry.h" #include "scales.h" #include "os.h" +#include "misc.h" /* decides between modes, dispatches to the appropriate mapping. */ -int vorbis_analysis(vorbis_block *vb,ogg_packet *op){ - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - int type; - int mode=0; +int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ + int ret,i; + vorbis_block_internal *vbi=vb->internal; vb->glue_bits=0; vb->time_bits=0; @@ -38,68 +36,84 @@ int vorbis_analysis(vorbis_block *vb,ogg_packet *op){ vb->res_bits=0; /* first things first. Make sure encode is ready */ - _oggpack_reset(&vb->opb); - /* Encode the packet type */ - _oggpack_write(&vb->opb,0,1); - - /* currently lazy. Short block dispatches to 0, long to 1. */ - - if(vb->W &&vi->modes>1)mode=1; - type=vi->map_type[vi->mode_param[mode]->mapping]; - vb->mode=mode; - - /* Encode frame mode, pre,post windowsize, then dispatch */ - _oggpack_write(&vb->opb,mode,vd->modebits); - if(vb->W){ - _oggpack_write(&vb->opb,vb->lW,1); - _oggpack_write(&vb->opb,vb->nW,1); - fprintf(stderr,"*"); - }else{ - fprintf(stderr,"."); + for(i=0;ipacketblob[i]); + + /* we only have one mapping type (0), and we let the mapping code + itself figure out what soft mode to use. This allows easier + bitrate management */ + + if((ret=_mapping_P[0]->forward(vb))) + return(ret); + + if(op){ + if(vorbis_bitrate_managed(vb)) + /* The app is using a bitmanaged mode... but not using the + bitrate management interface. */ + return(OV_EINVAL); + + op->packet=oggpack_get_buffer(&vb->opb); + op->bytes=oggpack_bytes(&vb->opb); + op->b_o_s=0; + op->e_o_s=vb->eofflag; + op->granulepos=vb->granulepos; + op->packetno=vb->sequence; /* for sake of completeness */ } - - if(_mapping_P[type]->forward(vb,vd->mode[mode])) - return(-1); - - /* set up the packet wrapper */ - - op->packet=_oggpack_buffer(&vb->opb); - op->bytes=_oggpack_bytes(&vb->opb); - op->b_o_s=0; - op->e_o_s=vb->eofflag; - op->frameno=vb->frameno; - op->packetno=vb->sequence; /* for sake of completeness */ - return(0); } -/* there was no great place to put this.... */ -void _analysis_output(char *base,int i,double *v,int n,int bark,int dB){ #ifdef ANALYSIS +int analysis_noisy=1; + +/* there was no great place to put this.... */ +void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ int j; FILE *of; char buffer[80]; + sprintf(buffer,"%s_%d.m",base,i); of=fopen(buffer,"w"); if(!of)perror("failed to open data dump file"); for(j=0;j