X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fanalysis.c;h=0e11a167be8dec155075c672fba38be75d5995bb;hb=0a4beb1d04f802c48016b11fb939690e24173168;hp=b83036a1209a8493679b96890d0402451fcedcf1;hpb=0767f5fbb63b6255e0ca13708f0c38c971c30d34;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/analysis.c b/lib/analysis.c index b83036a..0e11a16 100644 --- a/lib/analysis.c +++ b/lib/analysis.c @@ -1,262 +1,119 @@ /******************************************************************** * * - * 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-1999 * - * by 1999 Monty and The XIPHOPHORUS Company * - * http://www.xiph.org/ * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * + * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** - function: single-block PCM analysis - author: Monty - modifications by: Monty - last modification date: Oct 21 1999 + function: single-block PCM analysis mode dispatch ********************************************************************/ #include #include #include -#include "lpc.h" -#include "lsp.h" -#include "codec.h" -#include "envelope.h" -#include "mdct.h" -#include "psy.h" -#include "bitwise.h" -#include "spectrum.h" - -/* this code is still seriously abbreviated. I'm filling in pieces as - we go... --Monty 19991004 */ - -int vorbis_analysis(vorbis_block *vb,ogg_packet *op){ - int i; - double *window=vb->vd->window[vb->W][vb->lW][vb->nW]; - psy_lookup *vp=&vb->vd->vp[vb->W]; - lpc_lookup *vl=&vb->vd->vl[vb->W]; - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - oggpack_buffer *opb=&vb->opb; - - int n=vb->pcmend; - int spectral_order=vi->floororder[vb->W]; - - vb->gluebits=0; - vb->time_envelope_bits=0; - vb->spectral_envelope_bits=0; - vb->spectral_residue_bits=0; - - /*lpc_lookup *vbal=&vb->vd->vbal[vb->W]; - double balance_v[vbal->m]; - double balance_amp;*/ - - /* first things first. Make sure encode is ready*/ - _oggpack_reset(opb); - /* Encode the packet type */ - _oggpack_write(opb,0,1); - - /* Encode the block size */ - _oggpack_write(opb,vb->W,1); - if(vb->W){ - _oggpack_write(opb,vb->lW,1); - _oggpack_write(opb,vb->nW,1); +#include +#include "vorbis/codec.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){ + int ret,i; + vorbis_block_internal *vbi=vb->internal; + + vb->glue_bits=0; + vb->time_bits=0; + vb->floor_bits=0; + vb->res_bits=0; + + /* first things first. Make sure encode is ready */ + 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 */ } - - /* No envelope encoding yet */ - _oggpack_write(opb,0,1); - - /* time domain PCM -> MDCT domain */ - for(i=0;ichannels;i++) - mdct_forward(&vd->vm[vb->W],vb->pcm[i],vb->pcm[i],window); - - /* no balance yet */ - - /* extract the spectral envelope and residue */ - /* just do by channel. No coupling yet */ - { - for(i=0;ichannels;i++){ - static int frameno=0; - int j; - double floor[n/2]; - double curve[n/2]; - double *lpc=vb->lpc[i]; - double *lsp=vb->lsp[i]; - - memset(floor,0,sizeof(double)*n/2); - - _vp_noise_floor(vp,vb->pcm[i],floor); + return(0); +} #ifdef ANALYSIS - { - FILE *out; - char buffer[80]; - - sprintf(buffer,"Aspectrum%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jpcm[i][j]); - fclose(out); - - sprintf(buffer,"Anoise%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jpcm[i],floor); +void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, + ogg_int64_t off){ + if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off); +} -#ifdef ANALYSIS - { - FILE *out; - char buffer[80]; - - sprintf(buffer,"Apremask%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jamp[i]=sqrt(vorbis_curve_to_lpc(floor,lpc,vl)); - /* LSP <-> LPC is orthogonal and LSP quantizes more stably */ - vorbis_lpc_to_lsp(lpc,lsp,vl->m); - /* code the spectral envelope; mutates the lsp coeffs to reflect - what was actually encoded */ - _vs_spectrum_encode(vb,vb->amp[i],lsp); - /* Generate residue from the decoded envelope, which will be - slightly different to the pre-encoding floor due to - quantization. Slow, yes, but perhaps more accurate */ - vorbis_lsp_to_lpc(lsp,lpc,vl->m); - vorbis_lpc_to_curve(curve,lpc,vb->amp[i],vl); - - /* this may do various interesting massaging too...*/ - _vs_residue_quantize(vb->pcm[i],curve,vi,n/2); -#ifdef ANALYSIS - { - FILE *out; - char buffer[80]; - - sprintf(buffer,"Alpc%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jm;j++) - fprintf(out,"%g\n",lpc[j]); - fclose(out); - sprintf(buffer,"Alsp%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jm;j++) - fprintf(out,"%g\n",lsp[j]); - fclose(out); - sprintf(buffer,"Amask%d.m",vb->sequence); - out=fopen(buffer,"w+"); - for(j=0;jsequence); - out=fopen(buffer,"w+"); - for(j=0;jpcm[i][j]); - fclose(out); - } -#endif - - /* encode the residue */ - _vs_residue_encode(vb,vb->pcm[i]); - - } - } - /* set up the packet wrapper */ - op->packet=opb->buffer; - op->bytes=_oggpack_bytes(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); -} - - - - -/* commented out, relocated balance stuff */ - /*{ - double *C=vb->pcm[0]; - double *D=vb->pcm[1]; - - balance_amp=_vp_balance_compute(D,C,balance_v,vbal); - - { - FILE *out; - char buffer[80]; - - sprintf(buffer,"com%d.m",frameno); - out=fopen(buffer,"w+"); - for(i=0;i