diff options
author | Monty <xiphmont@xiph.org> | 2001-12-05 08:03:20 +0000 |
---|---|---|
committer | Monty <xiphmont@xiph.org> | 2001-12-05 08:03:20 +0000 |
commit | c5dbab6b138adadc26bf158c39ab2ee427e7519b (patch) | |
tree | 48442e9e134821e3defb6b0b247e32df9da817d4 | |
parent | c6ec64eaa03fc3d09c1586c879788707e25808de (diff) | |
download | libvorbis-git-c5dbab6b138adadc26bf158c39ab2ee427e7519b.tar.gz |
Incremental commit
svn path=/branches/branch_monty_20011009/vorbis/; revision=2421
-rw-r--r-- | lib/bitrate.c | 8 | ||||
-rw-r--r-- | lib/block.c | 4 | ||||
-rw-r--r-- | lib/envelope.c | 236 | ||||
-rw-r--r-- | lib/mapping0.c | 8 | ||||
-rw-r--r-- | lib/masking.h | 242 | ||||
-rw-r--r-- | lib/modes/floor_44.h | 65 | ||||
-rw-r--r-- | lib/modes/psych_44.h | 174 | ||||
-rw-r--r-- | lib/modes/residue_44.h | 48 | ||||
-rw-r--r-- | lib/psy.c | 38 | ||||
-rw-r--r-- | lib/registry.c | 4 | ||||
-rw-r--r-- | lib/vorbisenc.c | 221 |
11 files changed, 767 insertions, 281 deletions
diff --git a/lib/bitrate.c b/lib/bitrate.c index 4286e366..160ac34c 100644 --- a/lib/bitrate.c +++ b/lib/bitrate.c @@ -11,7 +11,7 @@ ******************************************************************** function: bitrate tracking and management - last mod: $Id: bitrate.c,v 1.1.2.5 2001/12/04 11:16:19 xiphmont Exp $ + last mod: $Id: bitrate.c,v 1.1.2.6 2001/12/05 08:03:16 xiphmont Exp $ ********************************************************************/ @@ -85,7 +85,7 @@ static long limit_sum(bitrate_manager_state *bm,int limit){ void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){ int i; codec_setup_info *ci=vi->codec_setup; - bitrate_manager_info *bi=ci->bi; + bitrate_manager_info *bi=&ci->bi; long maxlatency; memset(bm,0,sizeof(*bm)); @@ -199,7 +199,7 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ bitrate_manager_state *bm=&b->bms; vorbis_info *vi=vd->vi; codec_setup_info *ci=vi->codec_setup; - bitrate_manager_info *bi=ci->bi; + bitrate_manager_info *bi=&ci->bi; int eofflag=vb->eofflag; int head=bm->queue_head; int next_head=head+1; @@ -363,7 +363,7 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ if(bm->avgnoise>bi->avgfloat_noise_maxval) bm->avgnoise=bi->avgfloat_noise_maxval; } - fprintf(stderr,"noise:%f req:%d trigger:%d\n",bm->avgnoise, + fprintf(stderr,"noise:%f req:%ld trigger:%ld\n",bm->avgnoise, bm->noisetrigger_request,bm->noisetrigger_postpone); } diff --git a/lib/block.c b/lib/block.c index 468939ea..e88a7fc3 100644 --- a/lib/block.c +++ b/lib/block.c @@ -11,7 +11,7 @@ ******************************************************************** function: PCM data vector blocking, windowing and dis/reassembly - last mod: $Id: block.c,v 1.50.2.6 2001/11/22 06:21:07 xiphmont Exp $ + last mod: $Id: block.c,v 1.50.2.7 2001/12/05 08:03:16 xiphmont Exp $ Handle windowing, overlap-add, etc of the PCM vectors. This is made more amusing by Vorbis' current two allowed block sizes. @@ -492,7 +492,7 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ codec_setup_info *ci=vi->codec_setup; backend_lookup_state *b=v->backend_state; vorbis_look_psy_global *g=b->psy_g_look; - vorbis_info_psy_global *gi=ci->psy_g_param; + vorbis_info_psy_global *gi=&ci->psy_g_param; long beginW=v->centerW-ci->blocksizes[v->W]/2,centerNext; /* check to see if we're started... */ diff --git a/lib/envelope.c b/lib/envelope.c new file mode 100644 index 00000000..0c666f89 --- /dev/null +++ b/lib/envelope.c @@ -0,0 +1,236 @@ +/******************************************************************** + * * + * 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 OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + + ******************************************************************** + + function: PCM data envelope analysis and manipulation + last mod: $Id: envelope.c,v 1.38.2.1 2001/12/05 08:03:17 xiphmont Exp $ + + Preecho calculation. + + ********************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <math.h> +#include <ogg/ogg.h> +#include "vorbis/codec.h" +#include "codec_internal.h" + +#include "os.h" +#include "scales.h" +#include "envelope.h" +#include "misc.h" +#include "iir.c" /* Yes, ugly, but needed for inlining */ + +/* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher */ + +static int cheb_highpass_stages=6; +static float cheb_highpass_B[]={1.f,-6.f,15.f,-20.f,15.f,-6.f,1.f}; + +static int cheb_bandpass_stages=6; +static float cheb_bandpass_B[]={-1.f,0.f,3.f,0.f,-3.f,0.f,1.f}; + + +/* 10kHz Chebyshev highpass */ +static float cheb_highpass10k_gain= 54.34519586f; +static float cheb_highpass10k_A[]={ + -0.2064797169f, + -0.5609713214f, + -1.1352465327f, + -1.4495555418f, + -1.7938140760f, + -0.9473564683f}; + +/* 6kHz-10kHz Chebyshev bandpass */ +static float cheb_bandpass6k_gain=113.4643935f; +static float cheb_bandpass6k_A[]={ + -0.5712621337f, + 1.5626130710f, + -3.3348854983f, + 4.0471340821f, + -4.0051680331f, + 2.2786325610f}; + +/* 3kHz-6kHz Chebyshev bandpass */ +static float cheb_bandpass3k_gain= 248.8359377f; +static float cheb_bandpass3k_A[]={ + -0.6564230022f, + 3.3747911257f, + -8.0098635981f, + 11.0040876874f, + -9.2250963484f, + 4.4760355389f}; + +/* 1.5kHz-3kHz Chebyshev bandpass */ +static float cheb_bandpass1k_gain= 1798.537183f; +static float cheb_bandpass1k_A[]={ + -0.8097527363f, + 4.7725742682f, + -11.9800219408f, + 16.3770336223f, + -12.8553129536f, + 5.4948074309f}; + +void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy_global *gi=&ci->psy_g_param; + int ch=vi->channels; + int window=gi->envelopesa; + int i; + e->winlength=window; + e->minenergy=fromdB(gi->preecho_minenergy); + e->iir=_ogg_calloc(ch*4,sizeof(*e->iir)); + e->filtered=_ogg_calloc(ch*4,sizeof(*e->filtered)); + e->ch=ch; + e->storage=128; + for(i=0;i<ch*4;i+=4){ + + IIR_init(e->iir+i,cheb_highpass_stages,cheb_highpass10k_gain, + cheb_highpass10k_A,cheb_highpass_B); + IIR_init(e->iir+i+1,cheb_bandpass_stages,cheb_bandpass6k_gain, + cheb_bandpass6k_A,cheb_bandpass_B); + IIR_init(e->iir+i+2,cheb_bandpass_stages,cheb_bandpass3k_gain, + cheb_bandpass3k_A,cheb_bandpass_B); + IIR_init(e->iir+i+3,cheb_bandpass_stages,cheb_bandpass1k_gain, + cheb_bandpass1k_A,cheb_bandpass_B); + + e->filtered[i]=_ogg_calloc(e->storage,sizeof(*e->filtered[i])); + e->filtered[i+1]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+1])); + e->filtered[i+2]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+2])); + e->filtered[i+3]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+3])); + } + +} + +void _ve_envelope_clear(envelope_lookup *e){ + int i; + for(i=0;i<e->ch*4;i++){ + IIR_clear((e->iir+i)); + _ogg_free(e->filtered[i]); + } + _ogg_free(e->filtered); + _ogg_free(e->iir); + memset(e,0,sizeof(*e)); +} + +/* straight threshhold based until we find something that works better + and isn't patented */ +static float _ve_deltai(envelope_lookup *ve,float *pre,float *post){ + long n=ve->winlength; + + long i; + + /* we want to have a 'minimum bar' for energy, else we're just + basing blocks on quantization noise that outweighs the signal + itself (for low power signals) */ + + float minV=ve->minenergy; + float A=minV*minV*n; + float B=A; + + for(i=0;i<n;i++){ + A+=pre[i]*pre[i]; + B+=post[i]*post[i]; + } + + A=todB(&A); + B=todB(&B); + + return(B-A); +} + +long _ve_envelope_search(vorbis_dsp_state *v,long searchpoint){ + vorbis_info *vi=v->vi; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy_global *gi=&ci->psy_g_param; + envelope_lookup *ve=((backend_lookup_state *)(v->backend_state))->ve; + long i,j,k; + + /* make sure we have enough storage to match the PCM */ + if(v->pcm_storage>ve->storage){ + ve->storage=v->pcm_storage; + for(i=0;i<ve->ch*4;i++) + ve->filtered[i]=_ogg_realloc(ve->filtered[i],ve->storage*sizeof(*ve->filtered[i])); + } + + /* catch up the highpass to match the pcm */ + for(i=0;i<ve->ch;i++){ + float *pcm=v->pcm[i]; + float *filtered0=ve->filtered[i*4]; + float *filtered1=ve->filtered[i*4+1]; + float *filtered2=ve->filtered[i*4+2]; + float *filtered3=ve->filtered[i*4+3]; + IIR_state *iir0=ve->iir+i*4; + IIR_state *iir1=ve->iir+i*4+1; + IIR_state *iir2=ve->iir+i*4+2; + IIR_state *iir3=ve->iir+i*4+3; + int flag=1; + for(j=ve->current;j<v->pcm_current;j++){ + filtered0[j]=IIR_filter(iir0,pcm[j]); + filtered1[j]=IIR_filter_Band(iir1,pcm[j]); + filtered2[j]=IIR_filter_Band(iir2,pcm[j]); + filtered3[j]=IIR_filter_Band(iir3,pcm[j]); + if(pcm[j])flag=0; + } + if(flag && ve->current+64<v->pcm_current){ + IIR_reset(iir0); + IIR_reset(iir1); + IIR_reset(iir2); + IIR_reset(iir3); + } + + } + + ve->current=v->pcm_current; + + /* Now search through our cached highpass data for breaking points */ + /* starting point */ + if(v->W) + j=v->centerW+ci->blocksizes[1]/4-ci->blocksizes[0]/4; + else + j=v->centerW; + + if(j<ve->lastmark)j=ve->lastmark; + + while(j+ve->winlength<=v->pcm_current){ + if(j>=searchpoint)return(1); + + ve->lastmark=j; + for(i=0;i<ve->ch;i++){ + for(k=0;k<4;k++){ + float *filtered=ve->filtered[i*4+k]+j; + float m=_ve_deltai(ve,filtered-ve->winlength,filtered); + + if(m>gi->preecho_thresh[k])return(0); + if(m<gi->postecho_thresh[k])return(0); + + } + } + + j+=min(ci->blocksizes[0],ve->winlength)/2; + + } + if(j>=searchpoint)return(1); + + return(-1); +} + +void _ve_envelope_shift(envelope_lookup *e,long shift){ + int i; + for(i=0;i<e->ch*4;i++) + memmove(e->filtered[i],e->filtered[i]+shift,(e->current-shift)* + sizeof(*e->filtered[i])); + e->current-=shift; + e->lastmark-=shift; +} + + diff --git a/lib/mapping0.c b/lib/mapping0.c index 68e9f7dc..82c8829a 100644 --- a/lib/mapping0.c +++ b/lib/mapping0.c @@ -11,7 +11,7 @@ ******************************************************************** function: channel mapping 0 implementation - last mod: $Id: mapping0.c,v 1.37.2.10 2001/11/24 07:16:38 xiphmont Exp $ + last mod: $Id: mapping0.c,v 1.37.2.11 2001/12/05 08:03:17 xiphmont Exp $ ********************************************************************/ @@ -143,13 +143,13 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode int psynum=info->psy[0]; look->psy_look[0]=_ogg_calloc(1,sizeof(*look->psy_look[0])); _vp_psy_init(look->psy_look[0],ci->psy_param[psynum], - ci->psy_g_param, + &ci->psy_g_param, ci->blocksizes[vm->blockflag]/2,vi->rate); psynum=info->psy[1]; look->psy_look[1]=_ogg_calloc(1,sizeof(*look->psy_look[1])); _vp_psy_init(look->psy_look[1],ci->psy_param[psynum], - ci->psy_g_param, + &ci->psy_g_param, ci->blocksizes[vm->blockflag]/2,vi->rate); }else{ @@ -157,7 +157,7 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode look->psy_look[0]=_ogg_calloc(1,sizeof(*look->psy_look[0])); look->psy_look[1]=look->psy_look[0]; _vp_psy_init(look->psy_look[0],ci->psy_param[psynum], - ci->psy_g_param, + &ci->psy_g_param, ci->blocksizes[vm->blockflag]/2,vi->rate); } diff --git a/lib/masking.h b/lib/masking.h new file mode 100644 index 00000000..8eeabfb1 --- /dev/null +++ b/lib/masking.h @@ -0,0 +1,242 @@ +/******************************************************************** + * * + * 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 OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + + ******************************************************************** + + function: masking curve data for psychoacoustics + last mod: $Id: masking.h,v 1.18.4.1 2001/12/05 08:03:17 xiphmont Exp $ + + ********************************************************************/ + +#ifndef _V_MASKING_H_ +#define _V_MASKING_H_ + +static float ATH_Bark_dB_lspconservative[]={ + 15, 15, 15, 15, 11, 10, 8, 7, 7, 7, + 6, 2, 0, 0, -3, -5, -6, -6, -4.5f, 2.5f, + 10, 15, 15, 15, 15, 15, 15}; + +/* The below masking curves are straight from the R. Ehmer + (J. Acoustical Society of America) papers ca 1958-59. I modified + them slightly as Ehmer does not correct for the Absolute Threshold + of Hearing, and the low dB portions of the curves are thus highly + suspect. */ + +/* Let's all do the Trek thing and just call them 'Ehmer curves' ;-) + Note these are octaves, not Bark scale. */ + +#define EHMER_OFFSET 16 +#define EHMER_MAX 56 + +static float tone_125_40dB_SL[EHMER_MAX]={ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 18, 16, 14, 12, 11, 9, 7, 5, 3, 2, 0, -2, -4, -6, -8, + -10, -12, -14, -16, -18, -20, -900, -900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_125_60dB_SL[EHMER_MAX]={ + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 38, 36, 34, 32, 31, 29, 27, 25, 23, 22, 20, 18, 16, 14, 12, + 10, 8, 6, 4, 2, 0, -3, -5, -8,-10,-14,-17,-20,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_125_80dB_SL[EHMER_MAX]={ + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 58, 56, 54, 52, 51, 49, 47, 45, 43, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 17, 15, 12, 10, 6, 3, 0, -4, -8,-12, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_125_100dB_SL[EHMER_MAX]={ + 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, + 78, 77, 75, 74, 73, 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, 60, + 58, 57, 55, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 31, 29, + 27, 24, 22, 20, 18, 15, 13, 11}; + +static float tone_250_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -19, -13, -7, -1, 4, 9, 15, 20, + 22, 23, 22, 19, 18, 18, 16, 13, 9, 7, 3, 1, -1, -3, -6, -8, + -10, -13, -16, -19,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_250_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900, -10, -5, 1, 7, 13, 19, 25, 30, 33, + 36, 39, 38, 37, 38, 39, 39, 40, 38, 36, 35, 34, 33, 31, 29, 28, + 28, 28, 25, 20, 14, 10, 5, 0, -5,-10,-15,-20,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_250_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900, -10, 10, 17, 24, 30, 37, 41, 48, 49, + 50, 53, 54, 53, 53, 54, 55, 57, 57, 57, 58, 59, 60, 58, 57, 58, + 59, 58, 57, 54, 52, 50, 49, 47, 46, 47, 46, 44, 43, 42, 41, 40, + 38, 32, 27, 22, 17, 11, 6, 0}; +/* no data, just interpolated from 80 */ +static float tone_250_100dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900, -10, 15, 25, 34, 40, 50, 56, 60, 70, + 70, 73, 74, 73, 73, 74, 75, 77, 77, 77, 78, 79, 80, 78, 77, 78, + 79, 78, 77, 74, 72, 70, 69, 67, 66, 67, 66, 64, 63, 62, 61, 60, + 58, 52, 47, 42, 37, 31, 26, 20}; + +static float tone_500_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900, -20, -14, -8, -2, 4, 10, 17, + 23, 16, 12, 9, 6, 3, 0, -3, -7, -10, -13, -16, -20,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_500_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -18, -12, -6, 0, 6, 13, 20, 30, + 39, 34, 31, 29, 29, 27, 24, 21, 18, 16, 13, 8, 6, 3, 1, -1, + -5, -2, -5, -8, -12, -15, -18,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_500_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-16,-10, 0, 10, 20, 32, 43, + 53, 52, 52, 50, 49, 50, 52, 55, 55, 54, 51, 49, 46, 44, 44, 42, + 38, 34, 32, 29, 29, 28, 25, 23, 20, 16, 10, 7, 4, 2, -1, -4, + -7, -10, -15, -20,-900,-900,-900,-900}; +static float tone_500_100dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900, -10, -7, 2, 10, 19, 27, 35, 55, 56, + 62, 61, 60, 58, 57, 57, 59, 63, 65, 66, 62, 60, 57, 57, 58, 58, + 57, 56, 56, 56, 57, 57, 56, 57, 57, 54, 47, 41, 37, 28, 21, 16, + 10, 3, -3, -8, -13, -18,-900,-900}; + +static float tone_1000_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900, -20, -10, 0, 9, 20, + 27, 20, 13, 14, 13, 5, -1, -6, -11, -20,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_1000_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-13,-3, 7, 17, 25, 37, + 42, 33, 25, 25, 23, 18, 13, 9, 4, -1, -7,-13,-18, -23, -28, -33, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_1000_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-14, -4, 6, 16, 27, 33, 50, + 59, 57, 47, 41, 40, 43, 47, 48, 47, 42, 39, 37, 37, 36, 35, 32, + 30, 27, 21, 15, 5, -2, -10, -18, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_1000_100dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-10, 0, 10, 23, 33, 45, 60, + 70, 72, 55, 49, 43, 40, 44, 54, 59, 58, 49, 43, 52, 57, 57, 58, + 58, 54, 49, 47, 42, 39, 33, 28, 20, 15, 5, 0, -5,-15,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float tone_2000_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900, 5, 12, 20, + 24, 14, 8, 0, -5,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_2000_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -2, 8, 19, 31, + 38, 30, 15, 15, 15, 13, 8, 5, -2,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_2000_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 2, 10, 22, 38, + 52, 51, 40, 30, 28, 30, 33, 37, 37, 35, 31, 26, 20, 15, 10, 5, + 0,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_2000_100dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 6, 20, 40, 55, + 66, 60, 53, 40, 35, 31, 34, 42, 58, 48, 43, 45, 52, 57, 50, 42, + 45, 45, 35, 25, 20, 11, 2,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float tone_4000_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900, 2, 4, 18, + 24, 10, 5, 0, -5,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float tone_4000_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -2, 2, 4, 20, + 38, 30, 22, 15, 10, 5, 0, -10, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float tone_4000_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 0, 4, 10, 35, + 51, 49, 35, 35, 36, 36, 36, 31, 25, 20, 10, 0,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float tone_4000_100dB_SL[EHMER_MAX]={ +-900, -5, 1, 3, 5, 8, 10, 12, 14, 20, 26, 28, 32, 36, 41, 51, + 61, 59, 45, 45, 48, 48, 40, 25, 40, 30, 18, 5, 0, -900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + + +static float tone_8000_40dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -10, 3, 10, 18, + 26, 21, 14, 5, 0, 0, 5, 10, 20, 35, 55, 45, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_8000_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -10, 5, 12, 30, + 43, 40, 36, 35, 36, 38, 41, 43, 45, 60, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900, + -900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_8000_80dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900,-900,-900, -10, -1, 2, 6, 10, 13, 19, 25, 35, + 63, 59, 57, 56, 57, 59, 61, 62, 63, 65, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, + -900,-900,-900,-900,-900,-900,-900,-900}; +static float tone_8000_100dB_SL[EHMER_MAX]={ + -18, -12, -7, -3, 0, 2, 5, 8, 10, 14, 18, 20, 20, 22, 40, 40, + 70, 50, 30, 30, 30, 30, 30, 30, 30, 40, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900, + -900,-900,-900,-900,-900,-900,-900,-900}; + +#if 0 /* not used for the time being */ +static float noise_500_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900,-900, -20, -11, -2, 7, 16, 25, 34, 43, 52, 61, 66, + 69, 68, 58, 50, 44, 38, 32, 28, 25, 24, 20, 18, 17, 12, 10, 8, + 5, 0, -5, -8, -12, -15, -18, -22, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_500_80dB_SL[EHMER_MAX]={ +-900,-900,-900, -20, -10, -1, 8, 17, 26, 35, 44, 53, 62, 70, 79, 83, + 85, 85, 81, 77, 74, 71, 68, 63, 61, 59, 56, 55, 54, 52, 48, 47, + 45, 46, 45, 43, 40, 37, 33, 32, 35, 32, 30, 29, 20, 10, 0, -10, + -20, -30,-900,-900,-900,-900,-900,-900}; + +static float noise_1000_60dB_SL[EHMER_MAX]={ +-900,-900,-900,-900, -24, -15, -6, 3, 12, 21, 28, 34, 40, 48, 57, 60, + 61, 56, 54, 45, 36, 27, 21, 19, 17, 13, 10, 0, -10, -20, -20,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_1000_80dB_SL[EHMER_MAX]={ +-900, -26, -17, -8, 1, 10, 19, 28, 37, 41, 46, 51, 58, 68, 74, 81, + 80, 81, 70, 66, 58, 61, 59, 55, 54, 53, 52, 49, 48, 42, 38, 38, + 39, 34, 30, 27, 20, 10, 0, -10, -20, -30,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_2000_60dB_SL[EHMER_MAX]={ +-900,-900,-900, -34, -25, -16, -7, 2, 11, 18, 23, 30, 35, 42, 51, 58, + 58, 57, 50, 40,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_2000_80dB_SL[EHMER_MAX]={ +-900, -26, -17, -8, 1, 10, 19, 28, 33, 38, 43, 48, 53, 62, 70, 77, + 77, 75, 70, 67, 68, 66, 62, 61, 60, 59, 52, 47, 39, 35, 34, 35, + 35, 33, 30, 27, 20, 10, 0, -10, -20, -30,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_4000_60dB_SL[EHMER_MAX]={ +-900,-900,-900, -34, -25, -16, -7, 2, 11, 20, 25, 31, 37, 45, 56, 62, + 64, 61,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +static float noise_4000_80dB_SL[EHMER_MAX]={ +-900, -26, -17, -8, 1, 10, 19, 26, 33, 39, 45, 50, 55, 65, 75, 82, + 84, 81, 78, 72, 70, 69, 66, 61, 50, 48, 46, 40, 35, 30, 25, 20, + 15, 10, 5, 0, -10, -20, -30,-900, -900,-900,-900,-900,-900,-900,-900,-900, +-900,-900,-900,-900,-900,-900,-900,-900}; + +#endif +#endif + + diff --git a/lib/modes/floor_44.h b/lib/modes/floor_44.h index ec1cdf5f..9fb6caff 100644 --- a/lib/modes/floor_44.h +++ b/lib/modes/floor_44.h @@ -11,7 +11,7 @@ ******************************************************************** function: key floor settings for 44.1/48kHz - last mod: $Id: floor_44.h,v 1.1.2.1 2001/12/04 11:17:24 xiphmont Exp $ + last mod: $Id: floor_44.h,v 1.1.2.2 2001/12/05 08:03:20 xiphmont Exp $ ********************************************************************/ @@ -56,35 +56,37 @@ #include "books/line_1024x31_3sub2.vqh" #include "books/line_1024x31_3sub3.vqh" -static static_codebook _floor_44_128_books[2][9]={ - { - &_huff_book_line_128x7_class1, - &_huff_book_line_128x7_class2, - - &_huff_book_line_128x7_0sub0, - &_huff_book_line_128x7_1sub1, - &_huff_book_line_128x7_1sub2, - &_huff_book_line_128x7_1sub3, - &_huff_book_line_128x7_2sub1, - &_huff_book_line_128x7_2sub2, - &_huff_book_line_128x7_2sub3, - }, - { - &_huff_book_line_128x19_class1, - &_huff_book_line_128x19_class2, - - &_huff_book_line_128x19_0sub0, - &_huff_book_line_128x19_1sub1, - &_huff_book_line_128x19_1sub2, - &_huff_book_line_128x19_1sub3, - &_huff_book_line_128x19_2sub1, - &_huff_book_line_128x19_2sub2, - &_huff_book_line_128x19_2sub3, - } +static static_codebook *_floor_44_128x7_books[]={ + &_huff_book_line_128x7_class1, + &_huff_book_line_128x7_class2, + + &_huff_book_line_128x7_0sub0, + &_huff_book_line_128x7_1sub1, + &_huff_book_line_128x7_1sub2, + &_huff_book_line_128x7_1sub3, + &_huff_book_line_128x7_2sub1, + &_huff_book_line_128x7_2sub2, + &_huff_book_line_128x7_2sub3, +}; +static static_codebook *_floor_44_128x19_books[]={ + &_huff_book_line_128x19_class1, + &_huff_book_line_128x19_class2, + + &_huff_book_line_128x19_0sub0, + &_huff_book_line_128x19_1sub1, + &_huff_book_line_128x19_1sub2, + &_huff_book_line_128x19_1sub3, + &_huff_book_line_128x19_2sub1, + &_huff_book_line_128x19_2sub2, + &_huff_book_line_128x19_2sub3, }; -static static_codebook _floor_44_1024_books[1][14]={ - { +static static_codebook **_floor_44_128_books[2]={ + _floor_44_128x7_books, + _floor_44_128x19_books, +}; + +static static_codebook *_floor_44_1024x31_books[]={ &_huff_book_line_1024x31_class0, &_huff_book_line_1024x31_class1, &_huff_book_line_1024x31_class2, @@ -100,8 +102,11 @@ static static_codebook _floor_44_1024_books[1][14]={ &_huff_book_line_1024x31_3sub1, &_huff_book_line_1024x31_3sub2, &_huff_book_line_1024x31_3sub3, - } -} +}; + +static static_codebook **_floor_44_1024_books[1]={ + _floor_44_1024x31_books +}; static vorbis_info_floor1 _floor_44_128[2]={ { diff --git a/lib/modes/psych_44.h b/lib/modes/psych_44.h index 59ca759f..6473b2c7 100644 --- a/lib/modes/psych_44.h +++ b/lib/modes/psych_44.h @@ -11,12 +11,10 @@ ******************************************************************** function: key psychoacoustic settings for 44.1/48kHz - last mod: $Id: psych_44.h,v 1.1.2.1 2001/12/04 11:17:24 xiphmont Exp $ + last mod: $Id: psych_44.h,v 1.1.2.2 2001/12/05 08:03:20 xiphmont Exp $ ********************************************************************/ -#include "vorbis/codec.h" -#include "backends.h" /* preecho trigger settings *****************************************/ @@ -62,9 +60,9 @@ static float _psy_compand_44[3][NOISE_COMPAND_LEVELS]={ }; /* tonal masking curve level adjustments *************************/ -static int _vp_tonemask_adj_longblock[6][17][11]={ +static vp_adjblock _vp_tonemask_adj_longblock[6]={ /* adjust for mode zero */ - { + {{ { 10, 10, 5, }, /*63*/ { 10, 10, 5, }, { 10, 10, 5, }, /* 125 */ @@ -83,10 +81,10 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, /* 8000 */ { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, { 16, 16, 14, 12, 12, 15, 15, 15, 15, 15, 10}, /* 16000 */ - }, + }}, /* adjust for mode two */ - { + {{ { 10, 10, 5, }, /*63*/ { 10, 10, 5, }, { 10, 10, 5, }, /* 125 */ @@ -105,10 +103,10 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 7, 5, 5, 10, 10, 10, 5, }, { 16, 16, 14, 8, 8, 8, 10, 10, 10, 5, }, /* 16000 */ - }, + }}, /* adjust for mode four */ - { + {{ { 10, 5, 5, }, /*63*/ { 10, 5, 5, }, { 10, 5, 5, }, /* 125 */ @@ -127,10 +125,10 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 5, 5, 5, 10, 10, 10, 5, }, { 16, 16, 14, 8, 8, 8, 10, 10, 10, 5, }, /* 16000 */ - }, + }}, /* adjust for mode six */ - { + {{ { 10, 5, 5, }, /*63*/ { 10, 5, 5, }, { 10, 5, 5, }, /* 125 */ @@ -149,10 +147,10 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 5, 5, 5, 5, 5, 5, }, { 12, 10, 10, 5, 5, 5, 5, 5, 5, }, /* 16000 */ - }, + }}, /* adjust for mode eight */ - { + {{ { 0, }, /*63*/ { 0, }, { 0, }, /* 125 */ @@ -171,10 +169,10 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 0, }, /* 8000 */ { 0, }, { 5, 5, 5, 5, 5, 5, 5, }, /* 16000 */ - }, + }}, /* adjust for mode ten */ - { + {{ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*125*/ @@ -192,12 +190,12 @@ static int _vp_tonemask_adj_longblock[6][17][11]={ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*8000*/ { 0, 0, 0, -5,-10,-10,-10,-15,-15,-15,-15}, { 0, 0, 0, 0, 0, -5, -5,-10,-15,-15,-15}, /*16000*/ - }, + }}, }; -static int _vp_tonemask_adj_otherblock[6][17][11]={ +static vp_adjblock _vp_tonemask_adj_otherblock[6]={ /* adjust for mode zero */ - { + {{ { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, /*63*/ { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, /*125*/ @@ -217,10 +215,10 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, /*8000*/ { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, { 16, 16, 14, 12, 12, 15, 15, 15, 15, 15, 10}, /*16000*/ - }, + }}, /* adjust for mode two */ - { + {{ { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, /*63*/ { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, { 0, 0, 0, 0,-10,-10,-10,-10,-10,-10,-10}, /*125*/ @@ -240,10 +238,10 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 7, 5, 5, 10, 10, 10, 5, }, { 16, 16, 14, 8, 8, 8, 10, 10, 10, 5, }, /* 16000 */ - }, + }}, /* adjust for mode four */ - { + {{ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*125*/ @@ -263,10 +261,10 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 5, 5, 5, 10, 10, 10, 5, }, { 16, 16, 14, 8, 8, 8, 10, 10, 10, 5, }, /* 16000 */ - }, + }}, /* adjust for mode six */ - { + {{ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*63*/ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*125*/ @@ -286,10 +284,10 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 10, 10, 7, 5, }, /* 8000 */ { 10, 10, 7, 5, 5, 5, 5, 5, 5, }, { 12, 10, 10, 5, 5, 5, 5, 5, 5, }, /* 16000 */ - }, + }}, /* adjust for mode eight */ - { + {{ {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*63*/ {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, {-10,-10,-10,-15,-15,-15,-15,-20,-20,-20,-20}, /*125*/ @@ -309,10 +307,10 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 0, }, /* 8000 */ { 0, }, { 5, 5, 5, 5, 5, 5, 5, }, /* 16000 */ - }, + }}, /* adjust for mode ten */ - { + {{ { 0, 0, 0, -5,-15,-20,-20,-20,-20,-20,-20}, /*63*/ { 0, 0, 0, -5,-15,-20,-20,-20,-20,-20,-20}, { 0, 0, 0, -5,-15,-20,-20,-20,-20,-20,-20}, /*125*/ @@ -330,12 +328,12 @@ static int _vp_tonemask_adj_otherblock[6][17][11]={ { 0, 0, 0, -5,-15,-15,-15,-15,-15,-15,-15}, /*8000*/ { 0, 0, 0, -5,-10,-10,-10,-15,-15,-15,-15}, { 0, 0, 0, 0, 0, -5, -5,-10,-15,-15,-15}, /*16000*/ - }, + }}, }; -static int _vp_peakguard_[6][17][11]={ +static vp_adjblock _vp_peakguard[6]={ /* zero */ - { + {{ {-14,-16,-18,-19,-24,-24,-24,-24,-24,-24,-24},/*63*/ {-14,-16,-18,-19,-24,-24,-24,-24,-24,-24,-24}, {-14,-16,-18,-19,-24,-24,-24,-24,-24,-24,-24},/*125*/ @@ -353,9 +351,9 @@ static int _vp_peakguard_[6][17][11]={ {-10,-10,-10,-10,-10,-14,-16,-18,-22,-24,-24},/*8000*/ {-10,-10,-10,-10,-10,-14,-16,-18,-22,-24,-24}, {-10,-10,-10,-10,-10,-12,-16,-18,-22,-24,-24},/*16000*/ - }, + }}, /* two */ - { + {{ {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*63*/ {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30}, {-14,-20,-20,-20,-26,-30,-30,-30,-30,-30,-30},/*125*/ @@ -373,9 +371,9 @@ static int _vp_peakguard_[6][17][11]={ {-10,-10,-10,-10,-10,-11,-12,-13,-22,-30,-30},/*8000*/ {-10,-10,-10,-10,-10,-10,-10,-11,-22,-30,-30}, {-10,-10,-10,-10,-10,-10,-10,-10,-20,-30,-30},/*16000*/ - }, + }}, /* four */ - { + {{ {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/ {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40}, {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*125*/ @@ -393,9 +391,9 @@ static int _vp_peakguard_[6][17][11]={ {-10,-10,-10,-10,-10,-11,-12,-13,-22,-32,-40},/*8000*/ {-10,-10,-10,-10,-10,-10,-10,-11,-22,-32,-40}, {-10,-10,-10,-10,-10,-10,-10,-10,-20,-32,-40},/*16000*/ - }, + }}, /* six */ - { + {{ {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*63*/ {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40}, {-14,-20,-20,-20,-26,-32,-32,-32,-32,-32,-40},/*125*/ @@ -413,9 +411,9 @@ static int _vp_peakguard_[6][17][11]={ {-14,-14,-14,-18,-20,-20,-24,-24,-24,-32,-40},/*8000*/ {-14,-14,-14,-18,-20,-20,-24,-24,-24,-32,-40}, {-14,-14,-14,-18,-20,-20,-22,-24,-24,-32,-40},/*16000*/ - }, + }}, /* eight */ - { + {{ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*63*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*88*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*125*/ @@ -433,9 +431,9 @@ static int _vp_peakguard_[6][17][11]={ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*8000*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*11500*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-40,-40},/*16600*/ - }, + }}, /* ten */ - { + {{ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*63*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*88*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*125*/ @@ -453,7 +451,7 @@ static int _vp_peakguard_[6][17][11]={ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*8000*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*11500*/ {-14,-20,-24,-26,-32,-34,-36,-38,-40,-44,-46},/*16600*/ - } + }} }; static int _psy_noisebias_long[11][17]={ @@ -469,7 +467,7 @@ static int _psy_noisebias_long[11][17]={ {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -8, -8, -4, -3, -3, -2, -2}, {-28,-28,-28,-28,-28,-26,-24,-18,-14,-10,-10,-10, -8, -7, -7, -6, -6}, {-50,-50,-50,-50,-50,-50,-50,-48,-44,-40,-40,-40,-40,-40,-40,-40,-40}, -} +}; static int _psy_noisebias_other[11][17]={ /*63 125 250 500 1k 2k 4k 8k 16k*/ @@ -489,103 +487,103 @@ static int _psy_noisebias_other[11][17]={ static vorbis_info_psy _psy_settings[11]={ /* zero */ { /* ATH style ,float,min */ - ATH_Bark_dB_lineaggressive,-100.,-110., + {-1},-100.,-110., /* tonemask att,guard,suppr,curves peakattp,curvelimitp,peaksettings*/ - 3.f, -18.f,-10.f, NULL, 1, 0, NULL, + 3.f, -18.f,-10.f, {{{0.}}}, 1, 0, {{{0.}}}, /*noisemaskp,supp, low/high window, low/hi guard, minimum */ 1, -0.f, .5f, .5f, 0,0,0, - {0},NULL,95.f,NULL + {-1},{-1},95.f,{{-1}} }, /* one */ { - ATH_Bark_dB_lineaggressive,-100.,-110., - 0.f,-24.f,-20.f, NULL, 1,0,NULL, + {-1},-100.,-110., + 0.f,-24.f,-20.f, {{{0.}}}, 1,0,{{{0.}}}, 1,-24.f,.5f,.5f,0,0,0, - {0},NULL,95.f,NULL + {-1},{-1},95.f,{{-1}} }, /* two */ { - ATH_Bark_dB_lineaggressive,-100.,-120., - 0.f,-24.f,-20.f, NULL, 1,0,NULL, + {-1},-100.,-120., + 0.f,-24.f,-20.f, {{{0.}}}, 1,0,{{{0.}}}, 1,-24.f,.5f,.5f,0,0,0, - {0},NULL,95.f,NULL + {-1},{-1},95.f,{{-1}} }, /* three */ { - ATH_Bark_dB_lineaggressive,-100.,-140., - 0.f,-24.f,-20.f, NULL, 1,0,NULL, + {-1},-100.,-140., + 0.f,-24.f,-20.f, {{{0.}}}, 1,0,{{{0.}}}, 1,-24.f,.5f,.5f,0,0,0, - {0},NULL,95.f,NULL + {-1},{-1},95.f,{{-1}} }, /* four */ { - ATH_Bark_dB_lineaggressive,-100.,-140., - 0.f,-26.f,-30.f, NULL, 1,4,NULL, + {-1},-100.,-140., + 0.f,-26.f,-30.f, {{{0.}}}, 1,4,{{{0.}}}, 1,-24.f,.5f,.5f,0,0,0, - {0},NULL,95.f,NULL + {-1},{-1},95.f,{{-1}} }, /* five */ { - ATH_Bark_dB_lineaggressive,-100.,-140., - 0.f,-40.f,-30.f, NULL, 1,4,NULL, + {-1},-100.,-140., + 0.f,-40.f,-30.f, {{{0.}}}, 1,4,{{{0.}}}, 1,-30.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} }, /* six */ { - ATH_Bark_dB_lineaggressive,-100.,-140., - 0.f,-40.f,-40.f, NULL, 1,30,NULL, + {-1},-100.,-140., + 0.f,-40.f,-40.f, {{{0.}}}, 1,30,{{{0.}}}, 1,-40.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} }, /* seven */ { - ATH_Bark_dB_lineconservative,-100.,-140., - 0.f,-40.f,-40.f, NULL, 1,30,NULL, + {-1},-100.,-140., + 0.f,-40.f,-40.f, {{{0.}}}, 1,30,{{{0.}}}, 1,-40.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} }, /* eight */ { - ATH_Bark_dB_lineconservative,-100.,-140., - 0.f,-45.f,-45.f, NULL, 1,30,NULL, + {-1},-100.,-140., + 0.f,-45.f,-45.f, {{{0.}}}, 1,30,{{{0.}}}, 1,-45.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} }, /* nine */ { - ATH_Bark_dB_lineconservative,-110.,-140., - 0.f,-45.f,-45.f, NULL, 1,30,NULL, + {-1},-110.,-140., + 0.f,-45.f,-45.f, {{{0.}}}, 1,30,{{{0.}}}, 1,-45.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} }, /* ten */ { - ATH_Bark_dB_lineconservative,-120.,-150., - 0.f,-45.f,-45.f, NULL, 1,30,NULL, + {-1},-120.,-150., + 0.f,-45.f,-45.f, {{{0.}}}, 1,30,{{{0.}}}, 1,-45.f,.5f,.5f,0,0,0, - {0},NULL,105.f,NULL + {-1},{-1},105.f,{{-1}} } }; -/* noise compander lookups * low, mid, high quality ****************/ +/* ath ****************/ static float ATH_Bark_dB[][27]={ { - 0, 15, 15, 15, 11, 10, 8, 7, 7, 7, - 6, 2, 0, 0, -2, -5, -6, -6, -4, 4, - 14, 20, 19, 17, 30, 60, 60, - } - { - 0, 15, 15, 15, 11, 10, 8, 7, 7, 7, - 6, 2, 0, 0, -2, -5, -6, -6, -4, 0, - 2, 6, 5, 5, 15, 25, 35 + 0.f, 15.f, 15.f, 15.f, 11.f, 10.f, 8.f, 7.f, 7.f, 7.f, + 6.f, 2.f, 0.f, 0.f, -2.f, -5.f, -6.f, -6.f, -4.f, 4.f, + 14.f, 20.f, 19.f, 17.f, 30.f, 60.f, 60.f, }, { - 0, 15, 15, 15, 11, 10, 8, 7, 7, 7, - 6, 2, 0, 0, -3, -5, -6, -6,-4.5f, 0f, - 2, 6, 5, 5, 15, 15, 15 + 0.f, 15.f, 15.f, 15.f, 11.f, 10.f, 8.f, 7.f, 7.f, 7.f, + 6.f, 2.f, 0.f, 0.f, -2.f, -5.f, -6.f, -6.f, -4.f, 0.f, + 2.f, 6.f, 5.f, 5.f, 15.f, 25.f, 35.f, }, + { + 0.f, 15.f, 15.f, 15.f, 11.f, 10.f, 8.f, 7.f, 7.f, 7.f, + 6.f, 2.f, 0.f, 0.f, -3.f, -5.f, -6.f, -6.f,-4.5f, 0.f, + 2.f, 6.f, 5.f, 5.f, 15.f, 15.f, 15.f, + } }; diff --git a/lib/modes/residue_44.h b/lib/modes/residue_44.h index 5115ee94..d1e42673 100644 --- a/lib/modes/residue_44.h +++ b/lib/modes/residue_44.h @@ -11,7 +11,7 @@ ******************************************************************** function: toplevel residue templates for 32/44.1/48kHz - last mod: $Id: residue_44.h,v 1.1.2.1 2001/12/04 11:17:25 xiphmont Exp $ + last mod: $Id: residue_44.h,v 1.1.2.2 2001/12/05 08:03:20 xiphmont Exp $ ********************************************************************/ @@ -102,10 +102,10 @@ static vorbis_info_residue0 _residue_44_high={ /* residue backfill is entered in the template array as if stereo backfill is not in use. It's up to vorbisenc to make the appropriate index adjustment */ -#ifdef 0 +#if 0 static vorbis_residue_template _residue_template_44_stereo[11]={ /* mode 0; 64-ish */ - {&residue_44_low, {&44c0_short,&44c0_long}, + {&_residue_44_low, {&44c0_short,&44c0_long}, { {{-1}}, /* lossless stereo */ {{-1}}, /* 6dB (2.5) stereo */ {{-1}}, /* 12dB (4.5) stereo */ @@ -137,7 +137,7 @@ static vorbis_residue_template _residue_template_44_stereo[11]={ /* mode 1; 80-ish */ -} +}; #endif #include "books/res_44c_Z_128aux.vqh" @@ -145,31 +145,31 @@ static vorbis_residue_template _residue_template_44_stereo[11]={ static vorbis_residue_template _residue_template_44_stereo_temp[11]={ /* mode 0; 64-ish */ - {&residue_44_low, {&_huff_book_res_44c_Z_128aux, + {&_residue_44_low, {&_huff_book_res_44c_Z_128aux, &_huff_book_res_44c_Z_1024aux}, - { {{-1}}, /* lossless stereo */ - {{-1}}, /* 6dB (2.5) stereo */ - {{-1}}, /* 12dB (4.5) stereo */ - {{-1}}, /* 17dB (7.5) stereo */ - {{-1}}, - {{-1}}, /* 27dB (22.5) stereo */ + { {{0}}, /* lossless stereo */ + {{0}}, /* 6dB (2.5) stereo */ + {{0}}, /* 12dB (4.5) stereo */ + {{0}}, /* 17dB (7.5) stereo */ + {{0}}, + {{0}}, /* 27dB (22.5) stereo */ }, - { {-1}, /* lossless stereo */ - {-1}, /* 6dB (2.5) stereo */ - {-1}, /* 12dB (4.5) stereo */ - {-1}, /* 17dB (7.5) stereo */ - {-1}, - {-1}, /* 27dB (22.5) stereo */ + { {0}, /* lossless stereo */ + {0}, /* 6dB (2.5) stereo */ + {0}, /* 12dB (4.5) stereo */ + {0}, /* 17dB (7.5) stereo */ + {0}, + {0}, /* 27dB (22.5) stereo */ }, - { {{-1}}, /* lossless stereo */ - {{-1}}, /* 6dB (2.5) stereo */ - {{-1}}, /* 12dB (4.5) stereo */ - {{-1}}, - {{-1}}, /* 22dB (12.5) stereo */ - {{-1}}, /* 27dB (22.5) stereo */ + { {{0}}, /* lossless stereo */ + {{0}}, /* 6dB (2.5) stereo */ + {{0}}, /* 12dB (4.5) stereo */ + {{0}}, + {{0}}, /* 22dB (12.5) stereo */ + {{0}}, /* 27dB (22.5) stereo */ }, } /* mode 1; 80-ish */ -} +}; @@ -11,7 +11,7 @@ ******************************************************************** function: psychoacoustics not including preecho - last mod: $Id: psy.c,v 1.56.2.5 2001/12/04 11:16:19 xiphmont Exp $ + last mod: $Id: psy.c,v 1.56.2.6 2001/12/05 08:03:17 xiphmont Exp $ ********************************************************************/ @@ -35,22 +35,10 @@ masking has a strong harmonic dependency */ vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){ - int i,j; codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=ci->psy_g_param; + vorbis_info_psy_global *gi=&ci->psy_g_param; vorbis_look_psy_global *look=_ogg_calloc(1,sizeof(*look)); - int shiftoc=rint(log(gi->eighth_octave_lines*8)/log(2))-1; - look->decaylines=toOC(96000.f)*(1<<(shiftoc+1))+.5f; /* max sample - rate of - 192000kHz - for now */ - look->decay=_ogg_calloc(vi->channels,sizeof(*look->decay)); - for(i=0;i<vi->channels;i++){ - look->decay[i]=_ogg_calloc(look->decaylines,sizeof(*look->decay[i])); - for(j=0;j<look->decaylines;j++) - look->decay[i][j]=-9999.; - } look->channels=vi->channels; look->ampmax=-9999.; @@ -59,14 +47,10 @@ vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){ } void _vp_global_free(vorbis_look_psy_global *look){ - int i; - if(look->decay){ - for(i=0;i<look->channels;i++) - _ogg_free(look->decay[i]); - _ogg_free(look->decay); + if(look){ + memset(look,0,sizeof(*look)); + _ogg_free(look); } - memset(look,0,sizeof(*look)); - _ogg_free(look); } void _vi_gpsy_free(vorbis_info_psy_global *i){ @@ -334,7 +318,7 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, /* set up the final curves */ for(i=0;i<P_BANDS;i++) - setup_curve(p->tonecurves[i],i,vi->toneatt->block[i]); + setup_curve(p->tonecurves[i],i,vi->toneatt.block[i]); for(i=0;i<P_LEVELS;i++) _analysis_output("curve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0); @@ -378,8 +362,8 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, for(i=0;i<P_BANDS;i++) for(j=0;j<P_LEVELS;j++){ for(k=2;k<EHMER_OFFSET+2+vi->curvelimitp;k++) - if(p->tonecurves[i][j][k]> vi->peakatt->block[i][j]) - p->tonecurves[i][j][k]= vi->peakatt->block[i][j]; + if(p->tonecurves[i][j][k]> vi->peakatt.block[i][j]) + p->tonecurves[i][j][k]= vi->peakatt.block[i][j]; else break; } @@ -423,8 +407,8 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, if(vi->peakattp) /* we limit maximum depth only optionally */ for(i=0;i<P_BANDS;i++) for(j=0;j<P_LEVELS;j++) - if(p->tonecurves[i][j][EHMER_OFFSET+2]< vi->peakatt->block[i][j]) - p->tonecurves[i][j][EHMER_OFFSET+2]= vi->peakatt->block[i][j]; + if(p->tonecurves[i][j][EHMER_OFFSET+2]< vi->peakatt.block[i][j]) + p->tonecurves[i][j][EHMER_OFFSET+2]= vi->peakatt.block[i][j]; for(i=0;i<P_LEVELS;i++) _analysis_output("pcurve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0); @@ -898,7 +882,7 @@ void _vp_compute_mask(vorbis_look_psy *p, float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){ vorbis_info *vi=vd->vi; codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=ci->psy_g_param; + vorbis_info_psy_global *gi=&ci->psy_g_param; int n=ci->blocksizes[vd->W]/2; float secs=(float)n/vi->rate; diff --git a/lib/registry.c b/lib/registry.c index 2ab78e56..fae3c5ff 100644 --- a/lib/registry.c +++ b/lib/registry.c @@ -11,14 +11,14 @@ ******************************************************************** function: registry for time, floor, res backends and channel mappings - last mod: $Id: registry.c,v 1.10.2.1 2001/12/04 11:16:20 xiphmont Exp $ + last mod: $Id: registry.c,v 1.10.2.2 2001/12/05 08:03:18 xiphmont Exp $ ********************************************************************/ #include "vorbis/codec.h" #include "codec_internal.h" #include "registry.h" -#include "registry_api.h" +#include "registry-api.h" #include "misc.h" diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c index af28212b..2ed24b6d 100644 --- a/lib/vorbisenc.c +++ b/lib/vorbisenc.c @@ -11,13 +11,14 @@ ******************************************************************** function: simple programmatic interface for encoder mode setup - last mod: $Id: vorbisenc.c,v 1.17.2.1 2001/12/04 11:16:20 xiphmont Exp $ + last mod: $Id: vorbisenc.c,v 1.17.2.2 2001/12/05 08:03:18 xiphmont Exp $ ********************************************************************/ #include <stdlib.h> #include <string.h> #include <math.h> +#include <stdarg.h> #include "vorbis/codec.h" #include "vorbis/vorbisenc.h" @@ -40,6 +41,10 @@ typedef struct { static_codebook *books_residue_backfill[6][10][2]; } vorbis_residue_template; +typedef struct vp_adjblock{ + int block[P_BANDS][P_LEVELS]; +} vp_adjblock; + #include "modes/residue_44.h" #include "modes/psych_44.h" #include "modes/floor_44.h" @@ -50,7 +55,7 @@ static vorbis_info_mode _mode_set_short={0,0,0,0}; static vorbis_info_mode _mode_set_long={1,0,0,1}; /* mapping conventions: - only one submap (this would change for efficient 5.1 support for example) + only one submap (this would change for efficient 5.1 support for example)*/ /* three psychoacoustic profiles are used: One for short blocks, and two for long blocks (transition and regular) */ static vorbis_info_mapping0 _mapping_set_short={ @@ -60,7 +65,7 @@ static vorbis_info_mapping0 _mapping_set_long={ static int vorbis_encode_toplevel_init(vorbis_info *vi,int small,int large,int ch,long rate){ if(vi && vi->codec_setup){ - codec_setup_info *ci=vi->ci; + codec_setup_info *ci=vi->codec_setup; vi->version=0; vi->channels=ch; @@ -72,7 +77,7 @@ static int vorbis_encode_toplevel_init(vorbis_info *vi,int small,int large,int c /* time mapping hooks are unused in vorbis I */ ci->times=1; ci->time_type[0]=0; - ci->time_param[0]=&time_dummy; + ci->time_param[0]=&_time_dummy; /* by convention, two modes: one for short, one for long blocks. short block mode uses mapping sero, long block uses mapping 1 */ @@ -94,12 +99,12 @@ static int vorbis_encode_toplevel_init(vorbis_info *vi,int small,int large,int c } static int vorbis_encode_floor_init(vorbis_info *vi,double q,int block, - static_codebook **books, - vorbis_info_floor1 **in, + static_codebook ***books, + vorbis_info_floor1 *in, ...){ int x[11],i,k,iq=rint(q*10); vorbis_info_floor1 *f=calloc(1,sizeof(*f)); - codec_setup_info *ci=vi->ci; + codec_setup_info *ci=vi->codec_setup; va_list ap; va_start(ap,in); @@ -107,7 +112,7 @@ static int vorbis_encode_floor_init(vorbis_info *vi,double q,int block, x[i]=va_arg(ap,int); va_end(ap); - memcpy(f,in[x[iq]],sizoef(*f)); + memcpy(f,in+x[iq],sizeof(*f)); /* fill in the lowpass field, even if it's temporary */ f->n=ci->blocksizes[block]>>1; @@ -121,7 +126,7 @@ static int vorbis_encode_floor_init(vorbis_info *vi,double q,int block, for(i=0;i<maxclass;i++){ if(f->class_book[i]>maxbook)maxbook=f->class_book[i]; f->class_book[i]+=ci->books; - for(k=0;k<(1<<info->class_subs[i]);k++){ + for(k=0;k<(1<<f->class_subs[i]);k++){ if(f->class_subbook[i][k]>maxbook)maxbook=f->class_subbook[i][k]; f->class_subbook[i][k]+=ci->books; } @@ -132,19 +137,19 @@ static int vorbis_encode_floor_init(vorbis_info *vi,double q,int block, } /* for now, we're only using floor 1 */ - vi->floor_type[vi->floors]=1; - vi->floor_param[vi->floors]=f; - vi->floors++; + ci->floor_type[ci->floors]=1; + ci->floor_param[ci->floors]=f; + ci->floors++; return(0); } static int vorbis_encode_global_psych_init(vorbis_info *vi,double q, - vorbis_info_psy_global **in, ...){ + vorbis_info_psy_global *in, ...){ int i,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy_global *g=&ci->g; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy_global *g=&ci->psy_g_param; va_list ap; va_start(ap,in); @@ -159,23 +164,23 @@ static int vorbis_encode_global_psych_init(vorbis_info *vi,double q, dq=q*10.-iq; } - memcpy(g,in[(int)x[iq]],sizeof(*g)); + memcpy(g,in+(int)x[iq],sizeof(*g)); /* interpolate the trigger threshholds */ for(i=0;i<4;i++){ - g->preecho_thresh[i]=in[iq]->preecho_thresh[i]*(1.-dq)+in[iq+1]->preecho_thresh[i]*dq; - g->preecho_thresh[i]=in[iq]->postecho_thresh[i]*(1.-dq)+in[iq+1]->postecho_thresh[i]*dq; + g->preecho_thresh[i]=in[iq].preecho_thresh[i]*(1.-dq)+in[iq+1].preecho_thresh[i]*dq; + g->preecho_thresh[i]=in[iq].postecho_thresh[i]*(1.-dq)+in[iq+1].postecho_thresh[i]*dq; } - g->ampmax_att_per_sec=in[iq]->ampmax_att_per_sec*(1.-dq)+in[iq+1]->ampmax_att_per_sec*dq; + g->ampmax_att_per_sec=in[iq].ampmax_att_per_sec*(1.-dq)+in[iq+1].ampmax_att_per_sec*dq; return(0); } static int vorbis_encode_psyset_init(vorbis_info *vi,double q,int block, vorbis_info_psy *in, ...){ - int i,j,iq=q*10; + int i,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -194,28 +199,28 @@ static int vorbis_encode_psyset_init(vorbis_info *vi,double q,int block, ci->psys=block+1; if(!p){ p=calloc(1,sizeof(*p)); - ci->psy_params[block]=p; + ci->psy_param[block]=p; } - memcpy(p,in[(int)(q*10.)],sizeof(*p)); + memcpy(p,in+(int)(q*10.),sizeof(*p)); - p->ath_adjatt=in[iq]->ath_adjatt*(1.-dq)+in[iq+1]->ath_adjatt*dq; - p->ath_maxatt=in[iq]->ath_maxatt*(1.-dq)+in[iq+1]->ath_maxatt*dq; + p->ath_adjatt=in[iq].ath_adjatt*(1.-dq)+in[iq+1].ath_adjatt*dq; + p->ath_maxatt=in[iq].ath_maxatt*(1.-dq)+in[iq+1].ath_maxatt*dq; - p->tone_masteratt=in[iq]->tone_masteratt*(1.-dq)+in[iq+1]->tone_masteratt*dq; - p->tone_guard=in[iq]->tone_guard*(1.-dq)+in[iq+1]->tone_guard*dq; - p->tone_abs_limit=in[iq]->tone_abs_limit*(1.-dq)+in[iq+1]->tone_abs_limit*dq; - - p->noisemaxsupp=in[iq]->noisemaxsupp*(1.-dq)+in[iq+1]->noisemaxsupp*dq; + p->tone_masteratt=in[iq].tone_masteratt*(1.-dq)+in[iq+1].tone_masteratt*dq; + p->tone_guard=in[iq].tone_guard*(1.-dq)+in[iq+1].tone_guard*dq; + p->tone_abs_limit=in[iq].tone_abs_limit*(1.-dq)+in[iq+1].tone_abs_limit*dq; + p->noisemaxsupp=in[iq].noisemaxsupp*(1.-dq)+in[iq+1].noisemaxsupp*dq; + return(0); } static int vorbis_encode_compand_init(vorbis_info *vi,double q,int block, - float **in, ...){ + float in[][NOISE_COMPAND_LEVELS], ...){ int i,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -233,14 +238,15 @@ static int vorbis_encode_compand_init(vorbis_info *vi,double q,int block, /* interpolate the compander settings */ for(i=0;i<NOISE_COMPAND_LEVELS;i++) p->noisecompand[i]=in[iq][i]*(1.-dq)+in[iq+1][i]*dq; + return(0); } static int vorbis_encode_tonemask_init(vorbis_info *vi,double q,int block, - int ***in, ...){ + vp_adjblock *in, ...){ int i,j,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -257,16 +263,17 @@ static int vorbis_encode_tonemask_init(vorbis_info *vi,double q,int block, for(i=0;i<P_BANDS;i++) for(j=0;j<P_LEVELS;j++) - p->toneatt[i][j]=(j<4?4:j)*-10.+ - in[iq][i][j]*(1.-dq)+in[iq+1][i][j]*dq; + p->toneatt.block[i][j]=(j<4?4:j)*-10.+ + in[iq].block[i][j]*(1.-dq)+in[iq+1].block[i][j]*dq; + return(0); } static int vorbis_encode_peak_init(vorbis_info *vi,double q,int block, - int ***in, ...){ + vp_adjblock *in, ...){ int i,j,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -283,16 +290,17 @@ static int vorbis_encode_peak_init(vorbis_info *vi,double q,int block, for(i=0;i<P_BANDS;i++) for(j=0;j<P_LEVELS;j++) - p->peakatt[i][j]=(j<4?4:j)*-10.+ - in[iq][i][j]*(1.-dq)+in[iq+1][i][j]*dq; + p->peakatt.block[i][j]=(j<4?4:j)*-10.+ + in[iq].block[i][j]*(1.-dq)+in[iq+1].block[i][j]*dq; + return(0); } static int vorbis_encode_noisebias_init(vorbis_info *vi,double q,int block, - int **in, ...){ + int in[][17], ...){ int i,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -309,14 +317,15 @@ static int vorbis_encode_noisebias_init(vorbis_info *vi,double q,int block, for(i=0;i<P_BANDS;i++) p->noiseoff[i]=in[iq][i]*(1.-dq)+in[iq+1][i]*dq; + return(0); } static int vorbis_encode_ath_init(vorbis_info *vi,double q,int block, - float **in, ...){ + float in[][27], ...){ int i,iq=q*10; double x[11],dq; - codec_setup_info *ci=vi->ci; - vorbis_info_psy *p=&ci->psy_param[block]; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_psy *p=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -333,6 +342,7 @@ static int vorbis_encode_ath_init(vorbis_info *vi,double q,int block, for(i=0;i<P_BANDS;i++) p->ath[i]=in[iq][i]*(1.-dq)+in[iq+1][i]*dq; + return(0); } static double stereo_threshholds[]={0.0, 2.5, 4.5, 7.5, 12.5, 22.5}; @@ -343,21 +353,18 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, int t[11]; int a[11]; double c[11]; - double dq; int coupled_p; int stereo_backfill_p; int residue_backfill_p; - int type; int n; int partition_position; int res_position; int iterations=1; - double amplitude; int amplitude_select; - codec_setup_info *ci=vi->ci; - vorbis_info_residue *r; - vorbis_info_psy *psy=ci->psys+block; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_residue0 *r; + vorbis_info_psy *psy=ci->psy_param[block]; va_list ap; va_start(ap,in); @@ -378,7 +385,7 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, residue_free_info(ci->residue_param[block],ci->residue_type[block]); r=ci->residue_param[block]=malloc(sizeof(*r)); - memcpy(r,in[t[iq]],sizeof(*r)); + memcpy(r,in+t[iq],sizeof(*r)); n=r->end=ci->blocksizes[block?1:0]>>1; /* to be adjusted by lowpass later */ @@ -395,52 +402,65 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, /* for uncoupled, we use type 1, else type 2 */ if(coupled_p){ - ci->map_param[block].coupling_steps=1; - ci->map_param[block].coupling_mag[0]=0; - ci->map_param[block].coupling_ang[0]=1; + vorbis_info_mapping0 *map=ci->map_param[block]; + + map->coupling_steps=1; + map->coupling_mag[0]=0; + map->coupling_ang[0]=1; ci->residue_type[block]=2; - psy->couple_pass[0]={1.,1., {{-1, 1,9e10, 0},{9999, 1,9e10, -1}}}; + psy->couple_pass[0].granulem=1.; + psy->couple_pass[0].igranulem=1.; + psy->couple_pass[0].couple_pass[0].limit=res_position; + psy->couple_pass[0].couple_pass[0].outofphase_redundant_flip_p=1; + psy->couple_pass[0].couple_pass[0].outofphase_requant_limit=9e10; + psy->couple_pass[0].couple_pass[0].amppost_point=0; + psy->couple_pass[0].couple_pass[0].limit=9999; + psy->couple_pass[0].couple_pass[1].outofphase_redundant_flip_p=1; + psy->couple_pass[0].couple_pass[1].outofphase_requant_limit=9e10; + psy->couple_pass[0].couple_pass[1].amppost_point=stereo_threshholds[a[iq]]; + amplitude_select=a[iq]; ci->passlimit[0]=3; - amplitude_select=a[qi]; - amplitude=psy->couple_pass[0].couple_pass[1].limit=stereo_threshholds[a[qi]]; - if(stereo_backfill_p && a[qi]){ - psy->couple_pass[1]={1.,1., {{-1, 1,9e10, 0},{9999, 1,9e10, -1}}}; - psy->couple_pass[1].couple_pass[0].limit=res_position; - amplitude_select=a[qi]-1; - amplitude=psy->couple_pass[1].couple_pass[1].limit=stereo_threshholds[a[qi]-1]; - psy->passlimit[1]=4; + if(stereo_backfill_p && a[iq]){ + memcpy(psy->couple_pass+iterations,psy->couple_pass+iterations-1, + sizeof(*psy->couple_pass)); + amplitude_select=a[iq]-1; + psy->couple_pass[1].couple_pass[1].limit=stereo_threshholds[a[iq]-1]; + ci->passlimit[1]=4; for(i=0;i<r->partitions;i++) - if(in[qi].books_stereo_backfill[a[qi]-1][i]) + if(in[iq].books_stereo_backfill[a[iq]-1][i]) r->secondstages[i]|=8; iterations++; } if(residue_backfill_p){ - psy->couple_pass[iterations]={.33333333,3., {{-1, 1,1., 0},{9999, 1,9e10, -1}}}; - psy->couple_pass[iterations].couple_pass[0].limit=res_position; - psy->couple_pass[iterations].couple_pass[1].limit=amplitude; - ci->passlimit[iterations]=ci->passlimit[iterations-1]+1; + memcpy(psy->couple_pass+iterations,psy->couple_pass+iterations-1, + sizeof(*psy->couple_pass)); + psy->couple_pass[iterations].granulem=.333333333; + psy->couple_pass[iterations].igranulem=3.; for(i=0;i<r->partitions;i++) - if(in[qi].books_residue_backfill[amplitude_select][i][0]) + if(in[iq].books_residue_backfill[amplitude_select][i][0]) r->secondstages[i]|=(1<<(iterations+2)); + ci->passlimit[iterations]=ci->passlimit[iterations-1]+1; iterations++; - psy->couple_pass[iterations]={.11111111,9., {{-1, 1,.3, 0},{9999, 1,9e10, -1}}}; - psy->couple_pass[iterations].couple_pass[0].limit=res_position; - psy->couple_pass[iterations].couple_pass[1].limit=amplitude; - ci->passlimit[iterations]=r->passlimit[iterations-1]+1; + + memcpy(psy->couple_pass+iterations,psy->couple_pass+iterations-1, + sizeof(*psy->couple_pass)); + psy->couple_pass[iterations].granulem=.1111111111; + psy->couple_pass[iterations].igranulem=9.; for(i=0;i<r->partitions;i++) - if(in[qi].books_residue_backfill[amplitude_select][i][1]) + if(in[iq].books_residue_backfill[amplitude_select][i][1]) r->secondstages[i]|=(1<<(iterations+2)); + ci->passlimit[iterations]=ci->passlimit[iterations-1]+1; iterations++; } ci->coupling_passes=iterations; if(block) - memcpy(ci->psys+block+1,psy,sizeof(*psy)); + memcpy(ci->psy_param[block+1],psy,sizeof(*psy)); }else{ ci->residue_type[block]=1; @@ -449,9 +469,9 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, if(residue_backfill_p){ for(i=0;i<r->partitions;i++){ - if(in[qi].books_residue_backfill[amplitude_select][i][0]) + if(in[iq].books_residue_backfill[amplitude_select][i][0]) r->secondstages[i]|=8; - if(in[qi].books_residue_backfill[amplitude_select][i][1]) + if(in[iq].books_residue_backfill[amplitude_select][i][1]) r->secondstages[i]|=16; } ci->passlimit[1]=4; @@ -463,27 +483,28 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, /* fill in all the books */ { - int booklist=0; + int booklist=0,k; r->groupbook=ci->books; - ci->book_param[ci->books++]=in[qi].book_aux[block]; + ci->book_param[ci->books++]=in[iq].book_aux[block]; for(i=0;i<r->partitions;i++){ for(k=0;k<3;k++){ - if(in[qi].books_base[a[qi]][i][k]){ + if(in[iq].books_base[a[iq]][i][k]){ r->booklist[booklist++]=ci->books; - ci->book_param[ci->books++]=in[qi].books_base[a[qi]][i][k]); + ci->book_param[ci->books++]=in[iq].books_base[a[iq]][i][k]; } - if(coupled_p && stereo_backfill_p && a[qi] && - in[qi].books_stereo_backfill[a[qi]][i]){ + if(coupled_p && stereo_backfill_p && a[iq] && + in[iq].books_stereo_backfill[a[iq]][i]){ r->booklist[booklist++]=ci->books; - ci->book_param[ci->books++]=in[qi].books_stereo_backfill[a[qi]][i]; + ci->book_param[ci->books++]=in[iq].books_stereo_backfill[a[iq]][i]; } if(residue_backfill_p) for(k=0;k<2;k++){ - if(in[qi].books_residue_backfill[amplitude_select][i][k]){ + if(in[iq].books_residue_backfill[amplitude_select][i][k]){ r->booklist[booklist++]=ci->books; - ci->book_param[ci->books++]=in[qi].books_residue_backfill[amplitude_select][i][k]; + ci->book_param[ci->books++]=in[iq].books_residue_backfill[amplitude_select][i][k]; } } + } } } @@ -494,9 +515,9 @@ static int vorbis_encode_lowpass_init(vorbis_info *vi,double q,int block,...){ int i,iq=q*10; double x[11],dq; double freq; - codec_setup_info *ci=vi->ci; - vorbis_info_floor1 *f=ci->floor_param+block; - vorbis_info_residue0 *r=ci->residue_param+block; + codec_setup_info *ci=vi->codec_setup; + vorbis_info_floor1 *f=ci->floor_param[block]; + vorbis_info_residue0 *r=ci->residue_param[block]; int blocksize=ci->blocksizes[block]>>1; double nyq=vi->rate/2.; va_list ap; @@ -584,11 +605,11 @@ int vorbis_encode_init_vbr(vorbis_info *vi, ret|=vorbis_encode_peak_init(vi,base_quality,2,_vp_peakguard, 0., .5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.); - ret|=vorbis_encode_noisebias_init(vi,base_quality,0,_vp_noisebias_other, + ret|=vorbis_encode_noisebias_init(vi,base_quality,0,_psy_noisebias_other, 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.); - ret|=vorbis_encode_noisebias_init(vi,base_quality,1,_vp_noisebias_other, + ret|=vorbis_encode_noisebias_init(vi,base_quality,1,_psy_noisebias_other, 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.); - ret|=vorbis_encode_noisebias_init(vi,base_quality,2,_vp_noisebias_long, + ret|=vorbis_encode_noisebias_init(vi,base_quality,2,_psy_noisebias_long, 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.); ret|=vorbis_encode_ath_init(vi,base_quality,0,ATH_Bark_dB, @@ -623,10 +644,10 @@ int vorbis_encode_init_vbr(vorbis_info *vi, 4., 6., 6., 10., 10., 4., 4., 4., 4., 4., 4.); ret|=vorbis_encode_lowpass_init(vi,base_quality,0, - 15.1,15.9,16.9,17.9.,19.9., + 15.1,15.9,16.9,17.9,19.9, 999.,999.,999.,999.,999.,999.); ret|=vorbis_encode_lowpass_init(vi,base_quality,1, - 15.1,15.9,16.9,17.9.,19.9., + 15.1,15.9,16.9,17.9,19.9, 999.,999.,999.,999.,999.,999.); return(ret); |