Updates livVorbis to v1.3.3

This commit is contained in:
thecelloman 2013-02-24 19:07:14 -05:00
parent 853b70255b
commit 44beb6210b
62 changed files with 32606 additions and 41208 deletions

View file

@ -11,7 +11,7 @@
********************************************************************
function: single-block PCM analysis mode dispatch
last mod: $Id: analysis.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $
********************************************************************/
@ -26,8 +26,6 @@
#include "os.h"
#include "misc.h"
int analysis_noisy=1;
/* decides between modes, dispatches to the appropriate mapping. */
int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
int ret,i;
@ -41,7 +39,7 @@ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
/* first things first. Make sure encode is ready */
for(i=0;i<PACKETBLOBS;i++)
oggpack_reset(vbi->packetblob[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 */
@ -54,7 +52,7 @@ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
/* 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;
@ -65,49 +63,50 @@ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
return(0);
}
#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];
/* if(i==5870){*/
sprintf(buffer,"%s_%d.m",base,i);
of=fopen(buffer,"w");
if(!of)perror("failed to open data dump file");
for(j=0;j<n;j++){
if(bark){
float b=toBARK((4000.f*j/n)+.25);
fprintf(of,"%f ",b);
}else
if(off!=0)
fprintf(of,"%f ",(double)(j+off)/8000.);
else
fprintf(of,"%f ",(double)j);
if(dB){
float val;
if(v[j]==0.)
val=-140.;
else
val=todB(v+j);
fprintf(of,"%f\n",val);
}else{
fprintf(of,"%f\n",v[j]);
}
sprintf(buffer,"%s_%d.m",base,i);
of=fopen(buffer,"w");
if(!of)perror("failed to open data dump file");
for(j=0;j<n;j++){
if(bark){
float b=toBARK((4000.f*j/n)+.25);
fprintf(of,"%f ",b);
}else
if(off!=0)
fprintf(of,"%f ",(double)(j+off)/8000.);
else
fprintf(of,"%f ",(double)j);
if(dB){
float val;
if(v[j]==0.)
val=-140.;
else
val=todB(v+j);
fprintf(of,"%f\n",val);
}else{
fprintf(of,"%f\n",v[j]);
}
fclose(of);
/* } */
}
fclose(of);
}
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
ogg_int64_t off){
ogg_int64_t off){
if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);
}
#endif

View file

@ -5,14 +5,14 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: libvorbis backend and mapping structures; needed for
function: libvorbis backend and mapping structures; needed for
static mode headers
last mod: $Id: backends.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
@ -35,7 +35,7 @@ typedef struct{
void (*free_look) (vorbis_look_floor *);
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
void *buffer,float *);
void *buffer,float *);
} vorbis_func_floor;
typedef struct{
@ -68,16 +68,16 @@ typedef struct{
int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
int mult; /* 1 2 3 or 4 */
int postlist[VIF_POSIT+2]; /* first two implicit */
int mult; /* 1 2 3 or 4 */
int postlist[VIF_POSIT+2]; /* first two implicit */
/* encode side analysis parameters */
float maxover;
float maxunder;
float maxerr;
float maxover;
float maxunder;
float maxerr;
float twofitweight;
float twofitweight;
float twofitatten;
int n;
@ -89,16 +89,16 @@ typedef struct{
void (*pack) (vorbis_info_residue *,oggpack_buffer *);
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_residue *(*look) (vorbis_dsp_state *,
vorbis_info_residue *);
vorbis_info_residue *);
void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *);
long **(*class) (struct vorbis_block *,vorbis_look_residue *,
float **,int *,int);
int **,int *,int);
int (*forward) (oggpack_buffer *,struct vorbis_block *,
vorbis_look_residue *,
float **,float **,int *,int,long **);
vorbis_look_residue *,
int **,int *,int,long **,int);
int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
float **,int *,int);
float **,int *,int);
} vorbis_func_residue;
typedef struct vorbis_info_residue0{
@ -109,19 +109,19 @@ typedef struct vorbis_info_residue0{
/* first stage (lossless partitioning) */
int grouping; /* group n vectors per partition */
int partitions; /* possible codebooks for a partition */
int partvals; /* partitions ^ groupbook dim */
int groupbook; /* huffbook for partitioning */
int secondstages[64]; /* expanded out to pointers in lookup */
int booklist[256]; /* list of second stage books */
float classmetric1[64];
float classmetric2[64];
int booklist[512]; /* list of second stage books */
const int classmetric1[64];
const int classmetric2[64];
} vorbis_info_residue0;
/* Mapping backend generic *****************************************/
typedef struct{
void (*pack) (vorbis_info *,vorbis_info_mapping *,
oggpack_buffer *);
oggpack_buffer *);
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
void (*free_info) (vorbis_info_mapping *);
int (*forward) (struct vorbis_block *vb);
@ -131,7 +131,7 @@ typedef struct{
typedef struct vorbis_info_mapping0{
int submaps; /* <= 16 */
int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
int floorsubmap[16]; /* [mux] submap to floors */
int residuesubmap[16]; /* [mux] submap to residue */
@ -142,5 +142,3 @@ typedef struct vorbis_info_mapping0{
} vorbis_info_mapping0;
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: bitrate tracking and management
last mod: $Id: bitrate.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: bitrate.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -31,7 +31,7 @@ void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){
bitrate_manager_info *bi=&ci->bi;
memset(bm,0,sizeof(*bm));
if(bi && (bi->reservoir_bits>0)){
long ratesamples=vi->rate;
int halfsamples=ci->blocksizes[0]>>1;
@ -42,8 +42,8 @@ void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){
bm->avg_bitsper= rint(1.*bi->avg_rate*halfsamples/ratesamples);
bm->min_bitsper= rint(1.*bi->min_rate*halfsamples/ratesamples);
bm->max_bitsper= rint(1.*bi->max_rate*halfsamples/ratesamples);
bm->avgfloat=PACKETBLOBS/2;
bm->avgfloat=PACKETBLOBS/2;
/* not a necessary fix, but one that leads to a more balanced
typical initialization */
@ -53,7 +53,7 @@ void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){
bm->avg_reservoir=desired_fill;
}
}
}
}
void vorbis_bitrate_clear(bitrate_manager_state *bm){
@ -63,7 +63,7 @@ void vorbis_bitrate_clear(bitrate_manager_state *bm){
int vorbis_bitrate_managed(vorbis_block *vb){
vorbis_dsp_state *vd=vb->vd;
private_state *b=vd->backend_state;
private_state *b=vd->backend_state;
bitrate_manager_state *bm=&b->bms;
if(bm && bm->managed)return(1);
@ -74,7 +74,7 @@ int vorbis_bitrate_managed(vorbis_block *vb){
int vorbis_bitrate_addblock(vorbis_block *vb){
vorbis_block_internal *vbi=vb->internal;
vorbis_dsp_state *vd=vb->vd;
private_state *b=vd->backend_state;
private_state *b=vd->backend_state;
bitrate_manager_state *bm=&b->bms;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=vi->codec_setup;
@ -89,15 +89,15 @@ int vorbis_bitrate_addblock(vorbis_block *vb){
if(!bm->managed){
/* not a bitrate managed stream, but for API simplicity, we'll
buffer the packet to keep the code path clean */
if(bm->vb)return(-1); /* one has been submitted without
being claimed */
being claimed */
bm->vb=vb;
return(0);
}
bm->vb=vb;
/* look ahead for avg floater */
if(bm->avg_bitsper>0){
double slew=0.;
@ -117,15 +117,15 @@ int vorbis_bitrate_addblock(vorbis_block *vb){
if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
while(choice>0 && this_bits>avg_target_bits &&
bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
choice--;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){
choice--;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
}
}else if(bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
while(choice+1<PACKETBLOBS && this_bits<avg_target_bits &&
bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
choice++;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){
choice++;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
}
}
@ -143,21 +143,21 @@ int vorbis_bitrate_addblock(vorbis_block *vb){
/* do we need to force the bitrate up? */
if(this_bits<min_target_bits){
while(bm->minmax_reservoir-(min_target_bits-this_bits)<0){
choice++;
if(choice>=PACKETBLOBS)break;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
choice++;
if(choice>=PACKETBLOBS)break;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
}
}
}
/* enforce max (if used) on the current floater (if used) */
if(bm->max_bitsper>0){
/* do we need to force the bitrate down? */
if(this_bits>max_target_bits){
while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){
choice--;
if(choice<0)break;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
choice--;
if(choice<0)break;
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
}
}
}
@ -170,9 +170,9 @@ int vorbis_bitrate_addblock(vorbis_block *vb){
frame will need to be truncated */
long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8;
bm->choice=choice=0;
if(oggpack_bytes(vbi->packetblob[choice])>maxsize){
oggpack_writetrunc(vbi->packetblob[choice],maxsize*8);
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
}
@ -201,26 +201,26 @@ int vorbis_bitrate_addblock(vorbis_block *vb){
}else{
/* inbetween; we want to take reservoir toward but not past desired_fill */
if(bm->minmax_reservoir>desired_fill){
if(max_target_bits>0){ /* logical bulletproofing against initialization state */
bm->minmax_reservoir+=(this_bits-max_target_bits);
if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill;
}else{
bm->minmax_reservoir=desired_fill;
}
if(max_target_bits>0){ /* logical bulletproofing against initialization state */
bm->minmax_reservoir+=(this_bits-max_target_bits);
if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill;
}else{
bm->minmax_reservoir=desired_fill;
}
}else{
if(min_target_bits>0){ /* logical bulletproofing against initialization state */
bm->minmax_reservoir+=(this_bits-min_target_bits);
if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill;
}else{
bm->minmax_reservoir=desired_fill;
}
if(min_target_bits>0){ /* logical bulletproofing against initialization state */
bm->minmax_reservoir+=(this_bits-min_target_bits);
if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill;
}else{
bm->minmax_reservoir=desired_fill;
}
}
}
}
/* avg reservoir */
if(bm->avg_bitsper>0){
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper);
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper);
bm->avg_reservoir+=this_bits-avg_target_bits;
}
@ -236,7 +236,7 @@ int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){
if(op){
vorbis_block_internal *vbi=vb->internal;
if(vorbis_bitrate_managed(vb))
choice=bm->choice;
@ -247,7 +247,7 @@ int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){
op->granulepos=vb->granulepos;
op->packetno=vb->sequence; /* for sake of completeness */
}
bm->vb=0;
return(1);
}

View file

@ -5,17 +5,17 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
last mod: $Id: block.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: block.c 17561 2010-10-23 10:34:24Z xiphmont $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
********************************************************************/
#include <stdio.h>
@ -50,33 +50,33 @@ static int ilog2(unsigned int v){
:.....''' |_____--- '''......| | \_______|
:.................|__________________|_______|__|______|
|<------ Sl ------>| > Sr < |endW
|beginSl |endSl | |endSr
|beginSl |endSl | |endSr
|beginW |endlW |beginSr
|< lW >|
|< lW >|
<--------------- W ---------------->
| | .. ______________ |
| | ' `/ | ---_ |
|___.'___/`. | ---_____|
|___.'___/`. | ---_____|
|_______|__|_______|_________________|
| >|Sl|< |<------ Sr ----->|endW
| | |endSl |beginSr |endSr
|beginW | |endlW
|beginW | |endlW
mult[0] |beginSl mult[n]
<-------------- lW ----------------->
|<--W-->|
: .............. ___ | |
: .''' |`/ \ | |
:.....''' |/`....\|...|
:.........................|___|___|___|
|Sl |Sr |endW
|<--W-->|
: .............. ___ | |
: .''' |`/ \ | |
:.....''' |/`....\|...|
:.........................|___|___|___|
|Sl |Sr |endW
| | |endSr
| |beginSr
| |endSl
|beginSl
|beginW
|beginSl
|beginW
*/
/* block abstraction setup *********************************************/
@ -98,13 +98,13 @@ int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
for(i=0;i<PACKETBLOBS;i++){
if(i==PACKETBLOBS/2){
vbi->packetblob[i]=&vb->opb;
vbi->packetblob[i]=&vb->opb;
}else{
vbi->packetblob[i]=
_ogg_calloc(1,sizeof(oggpack_buffer));
vbi->packetblob[i]=
_ogg_calloc(1,sizeof(oggpack_buffer));
}
oggpack_writeinit(vbi->packetblob[i]);
}
}
}
return(0);
@ -185,7 +185,7 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
int hs;
if(ci==NULL) return 1;
hs=ci->halfrate_flag;
hs=ci->halfrate_flag;
memset(v,0,sizeof(*v));
b=v->backend_state=_ogg_calloc(1,sizeof(*b));
@ -217,16 +217,16 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
if(!ci->fullbooks){
ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
for(i=0;i<ci->books;i++)
vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
}
b->psy=_ogg_calloc(ci->psys,sizeof(*b->psy));
for(i=0;i<ci->psys;i++){
_vp_psy_init(b->psy+i,
ci->psy_param[i],
&ci->psy_g_param,
ci->blocksizes[ci->psy_param[i]->blockflag]/2,
vi->rate);
ci->psy_param[i],
&ci->psy_g_param,
ci->blocksizes[ci->psy_param[i]->blockflag]/2,
vi->rate);
}
v->analysisp=1;
@ -235,10 +235,13 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
if(!ci->fullbooks){
ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
for(i=0;i<ci->books;i++){
vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]);
/* decode codebooks are now standalone after init */
vorbis_staticbook_destroy(ci->book_param[i]);
ci->book_param[i]=NULL;
if(ci->book_param[i]==NULL)
goto abort_books;
if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
goto abort_books;
/* decode codebooks are now standalone after init */
vorbis_staticbook_destroy(ci->book_param[i]);
ci->book_param[i]=NULL;
}
}
}
@ -274,9 +277,18 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
for(i=0;i<ci->residues;i++)
b->residue[i]=_residue_P[ci->residue_type[i]]->
look(v,ci->residue_param[i]);
look(v,ci->residue_param[i]);
return 0;
abort_books:
for(i=0;i<ci->books;i++){
if(ci->book_param[i]!=NULL){
vorbis_staticbook_destroy(ci->book_param[i]);
ci->book_param[i]=NULL;
}
}
vorbis_dsp_clear(v);
return -1;
}
/* arbitrary settings and spec-mandated numbers get filled in here */
@ -308,42 +320,42 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
private_state *b=v->backend_state;
if(b){
if(b->ve){
_ve_envelope_clear(b->ve);
_ogg_free(b->ve);
_ve_envelope_clear(b->ve);
_ogg_free(b->ve);
}
if(b->transform[0]){
mdct_clear(b->transform[0][0]);
_ogg_free(b->transform[0][0]);
_ogg_free(b->transform[0]);
mdct_clear(b->transform[0][0]);
_ogg_free(b->transform[0][0]);
_ogg_free(b->transform[0]);
}
if(b->transform[1]){
mdct_clear(b->transform[1][0]);
_ogg_free(b->transform[1][0]);
_ogg_free(b->transform[1]);
mdct_clear(b->transform[1][0]);
_ogg_free(b->transform[1][0]);
_ogg_free(b->transform[1]);
}
if(b->flr){
if(ci)
for(i=0;i<ci->floors;i++)
_floor_P[ci->floor_type[i]]->
free_look(b->flr[i]);
_ogg_free(b->flr);
if(ci)
for(i=0;i<ci->floors;i++)
_floor_P[ci->floor_type[i]]->
free_look(b->flr[i]);
_ogg_free(b->flr);
}
if(b->residue){
if(ci)
for(i=0;i<ci->residues;i++)
_residue_P[ci->residue_type[i]]->
free_look(b->residue[i]);
_ogg_free(b->residue);
if(ci)
for(i=0;i<ci->residues;i++)
_residue_P[ci->residue_type[i]]->
free_look(b->residue[i]);
_ogg_free(b->residue);
}
if(b->psy){
if(ci)
for(i=0;i<ci->psys;i++)
_vp_psy_clear(b->psy+i);
_ogg_free(b->psy);
if(ci)
for(i=0;i<ci->psys;i++)
_vp_psy_clear(b->psy+i);
_ogg_free(b->psy);
}
if(b->psy_g_look)_vp_global_free(b->psy_g_look);
@ -353,11 +365,11 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
drft_clear(&b->fft_look[1]);
}
if(v->pcm){
if(vi)
for(i=0;i<vi->channels;i++)
if(v->pcm[i])_ogg_free(v->pcm[i]);
for(i=0;i<vi->channels;i++)
if(v->pcm[i])_ogg_free(v->pcm[i]);
_ogg_free(v->pcm);
if(v->pcmret)_ogg_free(v->pcmret);
}
@ -369,7 +381,7 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
if(b->header2)_ogg_free(b->header2);
_ogg_free(b);
}
memset(v,0,sizeof(*v));
}
}
@ -386,10 +398,10 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
/* Do we have enough storage space for the requested buffer? If not,
expand the PCM (and envelope) storage */
if(v->pcm_current+vals>=v->pcm_storage){
v->pcm_storage=v->pcm_current+vals*2;
for(i=0;i<vi->channels;i++){
v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i]));
}
@ -397,13 +409,13 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
for(i=0;i<vi->channels;i++)
v->pcmret[i]=v->pcm[i]+v->pcm_current;
return(v->pcmret);
}
static void _preextrapolate_helper(vorbis_dsp_state *v){
int i;
int order=32;
int order=16;
float *lpc=alloca(order*sizeof(*lpc));
float *work=alloca(v->pcm_current*sizeof(*work));
long j;
@ -413,19 +425,30 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){
for(i=0;i<v->vi->channels;i++){
/* need to run the extrapolation in reverse! */
for(j=0;j<v->pcm_current;j++)
work[j]=v->pcm[i][v->pcm_current-j-1];
work[j]=v->pcm[i][v->pcm_current-j-1];
/* prime as above */
vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
#if 0
if(v->vi->channels==2){
if(i==0)
_analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0);
else
_analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0);
}else{
_analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0);
}
#endif
/* run the predictor filter */
vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
order,
work+v->pcm_current-v->centerW,
v->centerW);
order,
work+v->pcm_current-v->centerW,
v->centerW);
for(j=0;j<v->pcm_current;j++)
v->pcm[i][v->pcm_current-j-1]=work[j];
v->pcm[i][v->pcm_current-j-1]=work[j];
}
}
@ -453,29 +476,29 @@ int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){
amplitude off a cliff, creating spread spectrum noise that will
suck to encode. Extrapolate for the sake of cleanliness. */
vorbis_analysis_buffer(v,ci->blocksizes[1]*3);
vorbis_analysis_buffer(v,ci->blocksizes[1]*3);
v->eofflag=v->pcm_current;
v->pcm_current+=ci->blocksizes[1]*3;
for(i=0;i<vi->channels;i++){
if(v->eofflag>order*2){
/* extrapolate with LPC to fill in */
long n;
/* extrapolate with LPC to fill in */
long n;
/* make a predictor filter */
n=v->eofflag;
if(n>ci->blocksizes[1])n=ci->blocksizes[1];
vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
/* make a predictor filter */
n=v->eofflag;
if(n>ci->blocksizes[1])n=ci->blocksizes[1];
vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
/* run the predictor filter */
vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
/* run the predictor filter */
vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
}else{
/* not enough data to extrapolate (unlikely to happen due to
/* not enough data to extrapolate (unlikely to happen due to
guarding the overlap, but bulletproof in case that
assumtion goes away). zeroes will do. */
memset(v->pcm[i]+v->eofflag,0,
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
memset(v->pcm[i]+v->eofflag,0,
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
}
}
@ -520,19 +543,19 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
/* we do an envelope search even on a single blocksize; we may still
be throwing more bits at impulses, and envelope search handles
marking impulses too. */
{
{
long bp=_ve_envelope_search(v);
if(bp==-1){
if(v->eofflag==0)return(0); /* not enough data currently to search for a
full long block */
full long block */
v->nW=0;
}else{
if(ci->blocksizes[0]==ci->blocksizes[1])
v->nW=0;
v->nW=0;
else
v->nW=bp;
v->nW=bp;
}
}
@ -552,7 +575,7 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
}
/* fill in the block. Note that for a short window, lW and nW are *short*
regardless of actual settings in the stream */
@ -580,12 +603,12 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
}
}
vb->vd=v;
vb->sequence=v->sequence++;
vb->granulepos=v->granulepos;
vb->pcmend=ci->blocksizes[v->W];
/* copy the vectors; this uses the local storage in vb */
/* this tracks 'strongest peak' for later psychoacoustics */
@ -593,7 +616,7 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
if(vbi->ampmax>g->ampmax)g->ampmax=vbi->ampmax;
g->ampmax=_vp_ampmax_decay(g->ampmax,v);
vbi->ampmax=g->ampmax;
vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels);
for(i=0;i<vi->channels;i++){
@ -601,14 +624,14 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
_vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
vb->pcm[i]=vbi->pcmdelay[i]+beginW;
/* before we added the delay
/* before we added the delay
vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i]));
*/
}
/* handle eof detection: eof==0 means that we've not yet received EOF
eof>0 marks the last 'real' sample in pcm[]
eof<0 'no more to do'; doesn't get here */
@ -630,27 +653,27 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
_ve_envelope_shift(b->ve,movementW);
v->pcm_current-=movementW;
for(i=0;i<vi->channels;i++)
memmove(v->pcm[i],v->pcm[i]+movementW,
v->pcm_current*sizeof(*v->pcm[i]));
memmove(v->pcm[i],v->pcm[i]+movementW,
v->pcm_current*sizeof(*v->pcm[i]));
v->lW=v->W;
v->W=v->nW;
v->centerW=new_centerNext;
if(v->eofflag){
v->eofflag-=movementW;
if(v->eofflag<=0)v->eofflag=-1;
/* do not add padding to end of stream! */
if(v->centerW>=v->eofflag){
v->granulepos+=movementW-(v->centerW-v->eofflag);
}else{
v->granulepos+=movementW;
}
v->eofflag-=movementW;
if(v->eofflag<=0)v->eofflag=-1;
/* do not add padding to end of stream! */
if(v->centerW>=v->eofflag){
v->granulepos+=movementW-(v->centerW-v->eofflag);
}else{
v->granulepos+=movementW;
}
}else{
v->granulepos+=movementW;
v->granulepos+=movementW;
}
}
}
@ -668,11 +691,11 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){
if(!vi)return -1;
ci=vi->codec_setup;
if(!ci)return -1;
hs=ci->halfrate_flag;
hs=ci->halfrate_flag;
v->centerW=ci->blocksizes[1]>>(hs+1);
v->pcm_current=v->centerW>>hs;
v->pcm_returned=-1;
v->granulepos=-1;
v->sequence=-1;
@ -683,9 +706,11 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){
}
int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
if(_vds_shared_init(v,vi,0)) return 1;
if(_vds_shared_init(v,vi,0)){
vorbis_dsp_clear(v);
return 1;
}
vorbis_synthesis_restart(v);
return 0;
}
@ -697,16 +722,16 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
vorbis_info *vi=v->vi;
codec_setup_info *ci=vi->codec_setup;
private_state *b=v->backend_state;
int hs=ci->halfrate_flag;
int hs=ci->halfrate_flag;
int i,j;
if(!vb)return(OV_EINVAL);
if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL);
v->lW=v->W;
v->W=vb->W;
v->nW=-1;
if((v->sequence==-1)||
(v->sequence+1 != vb->sequence)){
v->granulepos=-1; /* out of sequence; lose count */
@ -714,21 +739,21 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
}
v->sequence=vb->sequence;
if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly
was called on block */
if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly
was called on block */
int n=ci->blocksizes[v->W]>>(hs+1);
int n0=ci->blocksizes[0]>>(hs+1);
int n1=ci->blocksizes[1]>>(hs+1);
int thisCenter;
int prevCenter;
v->glue_bits+=vb->glue_bits;
v->time_bits+=vb->time_bits;
v->floor_bits+=vb->floor_bits;
v->res_bits+=vb->res_bits;
if(v->centerW){
thisCenter=n1;
prevCenter=0;
@ -736,84 +761,84 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
thisCenter=0;
prevCenter=n1;
}
/* v->pcm is now used like a two-stage double buffer. We don't want
to have to constantly shift *or* adjust memory usage. Don't
accept a new block until the old is shifted out */
for(j=0;j<vi->channels;j++){
/* the overlap/add section */
if(v->lW){
if(v->W){
/* large/large */
float *w=_vorbis_window_get(b->window[1]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j];
for(i=0;i<n1;i++)
pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i];
}else{
/* large/small */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
float *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
}
if(v->W){
/* large/large */
float *w=_vorbis_window_get(b->window[1]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j];
for(i=0;i<n1;i++)
pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i];
}else{
/* large/small */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
float *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
}
}else{
if(v->W){
/* small/large */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j]+n1/2-n0/2;
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
for(;i<n1/2+n0/2;i++)
pcm[i]=p[i];
}else{
/* small/small */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
}
if(v->W){
/* small/large */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j]+n1/2-n0/2;
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
for(;i<n1/2+n0/2;i++)
pcm[i]=p[i];
}else{
/* small/small */
float *w=_vorbis_window_get(b->window[0]-hs);
float *pcm=v->pcm[j]+prevCenter;
float *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i];
}
}
/* the copy section */
{
float *pcm=v->pcm[j]+thisCenter;
float *p=vb->pcm[j]+n;
for(i=0;i<n;i++)
pcm[i]=p[i];
float *pcm=v->pcm[j]+thisCenter;
float *p=vb->pcm[j]+n;
for(i=0;i<n;i++)
pcm[i]=p[i];
}
}
if(v->centerW)
v->centerW=0;
else
v->centerW=n1;
/* deal with initial packet state; we do this using the explicit
pcm_returned==-1 flag otherwise we're sensitive to first block
being short or long */
if(v->pcm_returned==-1){
v->pcm_returned=thisCenter;
v->pcm_current=thisCenter;
}else{
v->pcm_returned=prevCenter;
v->pcm_current=prevCenter+
((ci->blocksizes[v->lW]/4+
ci->blocksizes[v->W]/4)>>hs);
((ci->blocksizes[v->lW]/4+
ci->blocksizes[v->W]/4)>>hs);
}
}
/* track the frame number... This is for convenience, but also
making sure our last packet doesn't end with added padding. If
the last packet is partial, the number of samples we'll have to
return will be past the vb->granulepos.
This is not foolproof! It will be confused if we begin
decoding at the last page after a seek or hole. In that case,
we don't have a starting point to judge where the last frame
@ -825,7 +850,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
}else{
b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4;
}
if(v->granulepos==-1){
if(vb->granulepos!=-1){ /* only set if we have a position to set to */
@ -833,22 +858,37 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
/* is this a short page? */
if(b->sample_count>v->granulepos){
/* corner case; if this is both the first and last audio page,
then spec says the end is cut, not beginning */
if(vb->eofflag){
/* trim the end */
/* no preceeding granulepos; assume we started at zero (we'd
have to in a short single-page stream) */
/* granulepos could be -1 due to a seek, but that would result
in a long count, not short count */
v->pcm_current-=(b->sample_count-v->granulepos)>>hs;
}else{
/* trim the beginning */
v->pcm_returned+=(b->sample_count-v->granulepos)>>hs;
if(v->pcm_returned>v->pcm_current)
v->pcm_returned=v->pcm_current;
}
/* corner case; if this is both the first and last audio page,
then spec says the end is cut, not beginning */
long extra=b->sample_count-vb->granulepos;
/* we use ogg_int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
if(extra<0)
extra=0;
if(vb->eofflag){
/* trim the end */
/* no preceding granulepos; assume we started at zero (we'd
have to in a short single-page stream) */
/* granulepos could be -1 due to a seek, but that would result
in a long count, not short count */
/* Guard against corrupt/malicious frames that set EOP and
a backdated granpos; don't rewind more samples than we
actually have */
if(extra > (v->pcm_current - v->pcm_returned)<<hs)
extra = (v->pcm_current - v->pcm_returned)<<hs;
v->pcm_current-=extra>>hs;
}else{
/* trim the beginning */
v->pcm_returned+=extra>>hs;
if(v->pcm_returned>v->pcm_current)
v->pcm_returned=v->pcm_current;
}
}
@ -856,27 +896,41 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
}else{
v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4;
if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){
if(v->granulepos>vb->granulepos){
long extra=v->granulepos-vb->granulepos;
if(extra)
if(vb->eofflag){
/* partial last frame. Strip the extra samples off */
v->pcm_current-=extra>>hs;
} /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */
if(v->granulepos>vb->granulepos){
long extra=v->granulepos-vb->granulepos;
if(extra)
if(vb->eofflag){
/* partial last frame. Strip the extra samples off */
/* Guard against corrupt/malicious frames that set EOP and
a backdated granpos; don't rewind more samples than we
actually have */
if(extra > (v->pcm_current - v->pcm_returned)<<hs)
extra = (v->pcm_current - v->pcm_returned)<<hs;
/* we use ogg_int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
if(extra<0)
extra=0;
v->pcm_current-=extra>>hs;
} /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */
} /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */
spec. Either way, believe the bitstream } */
v->granulepos=vb->granulepos;
}
}
/* Update, cleanup */
if(vb->eofflag)v->eofflag=1;
return(0);
}
/* pcm==NULL indicates we just want the pending samples, no more */
@ -887,7 +941,7 @@ int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){
if(pcm){
int i;
for(i=0;i<vi->channels;i++)
v->pcmret[i]=v->pcm[i]+v->pcm_returned;
v->pcmret[i]=v->pcm[i]+v->pcm_returned;
*pcm=v->pcmret;
}
return(v->pcm_current-v->pcm_returned);
@ -909,8 +963,8 @@ int vorbis_synthesis_read(vorbis_dsp_state *v,int n){
int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
vorbis_info *vi=v->vi;
codec_setup_info *ci=vi->codec_setup;
int hs=ci->halfrate_flag;
int hs=ci->halfrate_flag;
int n=ci->blocksizes[v->W]>>(hs+1);
int n0=ci->blocksizes[0]>>(hs+1);
int n1=ci->blocksizes[1]>>(hs+1);
@ -934,9 +988,9 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
for(j=0;j<vi->channels;j++){
float *p=v->pcm[j];
for(i=0;i<n1;i++){
float temp=p[i];
p[i]=p[i+n1];
p[i+n1]=temp;
float temp=p[i];
p[i]=p[i+n1];
p[i+n1]=temp;
}
}
@ -944,7 +998,7 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
v->pcm_returned-=n1;
v->centerW=0;
}
/* solidify buffer into contiguous space */
if((v->lW^v->W)==1){
/* long/short or short/long */
@ -952,7 +1006,7 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
float *s=v->pcm[j];
float *d=v->pcm[j]+(n1-n0)/2;
for(i=(n1+n0)/2-1;i>=0;--i)
d[i]=s[i];
d[i]=s[i];
}
v->pcm_returned+=(n1-n0)/2;
v->pcm_current+=(n1-n0)/2;
@ -960,16 +1014,16 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
if(v->lW==0){
/* short/short */
for(j=0;j<vi->channels;j++){
float *s=v->pcm[j];
float *d=v->pcm[j]+n1-n0;
for(i=n0-1;i>=0;--i)
d[i]=s[i];
float *s=v->pcm[j];
float *d=v->pcm[j]+n1-n0;
for(i=n0-1;i>=0;--i)
d[i]=s[i];
}
v->pcm_returned+=n1-n0;
v->pcm_current+=n1-n0;
}
}
if(pcm){
int i;
for(i=0;i<vi->channels;i++)
@ -984,10 +1038,9 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){
float *vorbis_window(vorbis_dsp_state *v,int W){
vorbis_info *vi=v->vi;
codec_setup_info *ci=vi->codec_setup;
int hs=ci->halfrate_flag;
int hs=ci->halfrate_flag;
private_state *b=v->backend_state;
if(b->window[W]-1<0)return NULL;
return _vorbis_window_get(b->window[W]-hs);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: basic codebook pack/unpack/code/decode operations
last mod: $Id: codebook.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: codebook.c 18183 2012-02-03 20:51:27Z xiphmont $
********************************************************************/
@ -38,11 +38,11 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* pack the codewords. There are two packings; length ordered and
length random. Decide between the two now. */
for(i=1;i<c->entries;i++)
if(c->lengthlist[i-1]==0 || c->lengthlist[i]<c->lengthlist[i-1])break;
if(i==c->entries)ordered=1;
if(ordered){
/* length ordered. We only need to say how many codewords of
each length. The actual codewords are generated
@ -56,19 +56,19 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
long this=c->lengthlist[i];
long last=c->lengthlist[i-1];
if(this>last){
for(j=last;j<this;j++){
oggpack_write(opb,i-count,_ilog(c->entries-count));
count=i;
}
for(j=last;j<this;j++){
oggpack_write(opb,i-count,_ilog(c->entries-count));
count=i;
}
}
}
oggpack_write(opb,i-count,_ilog(c->entries-count));
}else{
/* length random. Again, we don't code the codeword itself, just
the length. This time, though, we have to encode each length */
oggpack_write(opb,0,1); /* unordered */
/* algortihmic mapping has use for 'unused entries', which we tag
here. The algorithmic mapping happens as usual, but the unused
entry has no codeword. */
@ -78,16 +78,16 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
if(i==c->entries){
oggpack_write(opb,0,1); /* no unused entries */
for(i=0;i<c->entries;i++)
oggpack_write(opb,c->lengthlist[i]-1,5);
oggpack_write(opb,c->lengthlist[i]-1,5);
}else{
oggpack_write(opb,1,1); /* we have unused entries; thus we tag */
for(i=0;i<c->entries;i++){
if(c->lengthlist[i]==0){
oggpack_write(opb,0,1);
}else{
oggpack_write(opb,1,1);
oggpack_write(opb,c->lengthlist[i]-1,5);
}
if(c->lengthlist[i]==0){
oggpack_write(opb,0,1);
}else{
oggpack_write(opb,1,1);
oggpack_write(opb,c->lengthlist[i]-1,5);
}
}
}
}
@ -102,37 +102,37 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
case 1:case 2:
/* implicitly populated value mapping */
/* explicitly populated value mapping */
if(!c->quantlist){
/* no quantlist? error */
return(-1);
}
/* values that define the dequantization */
oggpack_write(opb,c->q_min,32);
oggpack_write(opb,c->q_delta,32);
oggpack_write(opb,c->q_quant-1,4);
oggpack_write(opb,c->q_sequencep,1);
{
int quantvals;
switch(c->maptype){
case 1:
/* a single column of (c->entries/c->dim) quantized values for
building a full value list algorithmically (square lattice) */
quantvals=_book_maptype1_quantvals(c);
break;
/* a single column of (c->entries/c->dim) quantized values for
building a full value list algorithmically (square lattice) */
quantvals=_book_maptype1_quantvals(c);
break;
case 2:
/* every value (c->entries*c->dim total) specified explicitly */
quantvals=c->entries*c->dim;
break;
/* every value (c->entries*c->dim total) specified explicitly */
quantvals=c->entries*c->dim;
break;
default: /* NOT_REACHABLE */
quantvals=-1;
quantvals=-1;
}
/* quantized values */
for(i=0;i<quantvals;i++)
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
}
break;
@ -146,9 +146,9 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* unpacks a codebook from the packet buffer into the codebook struct,
readies the codebook auxiliary structures for decode *************/
int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
long i,j;
memset(s,0,sizeof(*s));
static_codebook *s=_ogg_calloc(1,sizeof(*s));
s->allocedp=1;
/* make sure alignment is correct */
@ -159,54 +159,68 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->entries=oggpack_read(opb,24);
if(s->entries==-1)goto _eofout;
if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout;
/* codeword ordering.... length ordered or unordered? */
switch((int)oggpack_read(opb,1)){
case 0:
case 0:{
long unused;
/* allocated but unused entries? */
unused=oggpack_read(opb,1);
if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb))
goto _eofout;
/* unordered */
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
/* allocated but unused entries? */
if(oggpack_read(opb,1)){
if(unused){
/* yes, unused entries */
for(i=0;i<s->entries;i++){
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}else
s->lengthlist[i]=0;
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}else
s->lengthlist[i]=0;
}
}else{
/* all entries used; no tagging */
for(i=0;i<s->entries;i++){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}
}
break;
}
case 1:
/* ordered */
{
long length=oggpack_read(opb,5)+1;
if(length==0)goto _eofout;
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++)
s->lengthlist[i]=length;
length++;
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
if(length>32 || num>s->entries-i ||
(num>0 && (num-1)>>(length-1)>1)){
goto _errout;
}
if(length>32)goto _errout;
for(j=0;j<num;j++,i++)
s->lengthlist[i]=length;
length++;
}
}
break;
default:
/* EOF */
return(-1);
goto _eofout;
}
/* Do we have a mapping to unpack? */
switch((s->maptype=oggpack_read(opb,4))){
case 0:
@ -220,23 +234,26 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->q_delta=oggpack_read(opb,32);
s->q_quant=oggpack_read(opb,4)+1;
s->q_sequencep=oggpack_read(opb,1);
if(s->q_sequencep==-1)goto _eofout;
{
int quantvals=0;
switch(s->maptype){
case 1:
quantvals=_book_maptype1_quantvals(s);
break;
quantvals=(s->dim==0?0:_book_maptype1_quantvals(s));
break;
case 2:
quantvals=s->entries*s->dim;
break;
quantvals=s->entries*s->dim;
break;
}
/* quantized values */
if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb))
goto _eofout;
s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant);
s->quantlist[i]=oggpack_read(opb,s->q_quant);
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
}
break;
@ -245,12 +262,12 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
}
/* all set */
return(0);
return(s);
_errout:
_eofout:
vorbis_staticbook_clear(s);
return(-1);
vorbis_staticbook_destroy(s);
return(NULL);
}
/* returns the number of bits ************************************************/
@ -260,37 +277,6 @@ int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){
return(book->c->lengthlist[a]);
}
/* One the encode side, our vector writers are each designed for a
specific purpose, and the encoder is not flexible without modification:
The LSP vector coder uses a single stage nearest-match with no
interleave, so no step and no error return. This is specced by floor0
and doesn't change.
Residue0 encoding interleaves, uses multiple stages, and each stage
peels of a specific amount of resolution from a lattice (thus we want
to match by threshold, not nearest match). Residue doesn't *have* to
be encoded that way, but to change it, one will need to add more
infrastructure on the encode side (decode side is specced and simpler) */
/* floor0 LSP (single stage, non interleaved, nearest match) */
/* returns entry number and *modifies a* to the quantization value *****/
int vorbis_book_errorv(codebook *book,float *a){
int dim=book->dim,k;
int best=_best(book,a,1);
for(k=0;k<dim;k++)
a[k]=(book->valuelist+best*dim)[k];
return(best);
}
/* returns the number of bits and *modifies a* to the quantization value *****/
int vorbis_book_encodev(codebook *book,int best,float *a,oggpack_buffer *b){
int k,dim=book->dim;
for(k=0;k<dim;k++)
a[k]=(book->valuelist+best*dim)[k];
return(vorbis_book_encode(book,best,b));
}
/* the 'eliminate the decode tree' optimization actually requires the
codewords to be MSb first, not LSb. This is an annoying inelegancy
(and one of the first places where carefully thought out design
@ -311,7 +297,7 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
int read=book->dec_maxlength;
long lo,hi;
long lok = oggpack_look(b,book->dec_firsttablen);
if (lok >= 0) {
long entry = book->dec_firsttable[lok];
if(entry&0x80000000UL){
@ -325,30 +311,30 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
lo=0;
hi=book->used_entries;
}
lok = oggpack_look(b, read);
while(lok<0 && read>1)
lok = oggpack_look(b, --read);
if(lok<0)return -1;
/* bisect search for the codeword in the ordered list */
{
ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok);
while(hi-lo>1){
long p=(hi-lo)>>1;
long test=book->codelist[lo+p]>testword;
long test=book->codelist[lo+p]>testword;
lo+=p&(test-1);
hi-=p&(-test);
}
if(book->dec_codelengths[lo]<=read){
oggpack_adv(b, book->dec_codelengths[lo]);
return(lo);
}
}
oggpack_adv(b, read);
return(-1);
@ -357,13 +343,13 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
/* Decode side is specced and easier, because we don't need to find
matches using different criteria; we simply read and map. There are
two things we need to do 'depending':
We may need to support interleave. We don't really, but it's
convenient to do it here rather than rebuild the vector later.
Cascades may be additive or multiplicitive; this is not inherent in
the codebook, but set in the code using the codebook. Like
interleaving, it's easiest to do it here.
interleaving, it's easiest to do it here.
addmul==0 -> declarative (set the value)
addmul==1 -> additive
addmul==2 -> multiplicitive */
@ -381,13 +367,14 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
}
/* returns 0 on OK or -1 on eof *************************************/
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int step=n/book->dim;
long *entry = alloca(sizeof(*entry)*step);
float **t = alloca(sizeof(*t)*step);
int i,j,o;
for (i = 0; i < step; i++) {
entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1);
@ -395,81 +382,85 @@ long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
}
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++)
a[o+j]+=t[j][i];
a[o+j]+=t[j][i];
}
return(0);
}
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int i,j,entry;
float *t;
if(book->dim>8){
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++];
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++];
}
}else{
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
j=0;
switch((int)book->dim){
case 8:
a[i++]+=t[j++];
case 7:
a[i++]+=t[j++];
case 6:
a[i++]+=t[j++];
case 5:
a[i++]+=t[j++];
case 4:
a[i++]+=t[j++];
case 3:
a[i++]+=t[j++];
case 2:
a[i++]+=t[j++];
case 1:
a[i++]+=t[j++];
case 0:
break;
}
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
j=0;
switch((int)book->dim){
case 8:
a[i++]+=t[j++];
case 7:
a[i++]+=t[j++];
case 6:
a[i++]+=t[j++];
case 5:
a[i++]+=t[j++];
case 4:
a[i++]+=t[j++];
case 3:
a[i++]+=t[j++];
case 2:
a[i++]+=t[j++];
case 1:
a[i++]+=t[j++];
case 0:
break;
}
}
}
}
}
return(0);
}
/* unlike the others, we guard against n not being an integer number
of <dim> internally rather than in the upper layer (called only by
floor0) */
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){
int i,j,entry;
float *t;
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]=t[j++];
for (j=0;i<n && j<book->dim;){
a[i++]=t[j++];
}
}
}else{
int i,j;
for(i=0;i<n;){
for (j=0;j<book->dim;)
a[i++]=0.f;
a[i++]=0.f;
}
}
return(0);
}
long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
oggpack_buffer *b,int n){
oggpack_buffer *b,int n){
long i,j,entry;
int chptr=0;
@ -478,157 +469,16 @@ long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
{
const float *t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j];
if(chptr==ch){
chptr=0;
i++;
}
}
const float *t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j];
if(chptr==ch){
chptr=0;
i++;
}
}
}
}
}
return(0);
}
#ifdef _V_SELFTEST
/* Simple enough; pack a few candidate codebooks, unpack them. Code a
number of vectors through (keeping track of the quantized values),
and decode using the unpacked book. quantized version of in should
exactly equal out */
#include <stdio.h>
#include "vorbis/book/lsp20_0.vqh"
#include "vorbis/book/res0a_13.vqh"
#define TESTSIZE 40
float test1[TESTSIZE]={
0.105939f,
0.215373f,
0.429117f,
0.587974f,
0.181173f,
0.296583f,
0.515707f,
0.715261f,
0.162327f,
0.263834f,
0.342876f,
0.406025f,
0.103571f,
0.223561f,
0.368513f,
0.540313f,
0.136672f,
0.395882f,
0.587183f,
0.652476f,
0.114338f,
0.417300f,
0.525486f,
0.698679f,
0.147492f,
0.324481f,
0.643089f,
0.757582f,
0.139556f,
0.215795f,
0.324559f,
0.399387f,
0.120236f,
0.267420f,
0.446940f,
0.608760f,
0.115587f,
0.287234f,
0.571081f,
0.708603f,
};
float test3[TESTSIZE]={
0,1,-2,3,4,-5,6,7,8,9,
8,-2,7,-1,4,6,8,3,1,-9,
10,11,12,13,14,15,26,17,18,19,
30,-25,-30,-1,-5,-32,4,3,-2,0};
static_codebook *testlist[]={&_vq_book_lsp20_0,
&_vq_book_res0a_13,NULL};
float *testvec[]={test1,test3};
int main(){
oggpack_buffer write;
oggpack_buffer read;
long ptr=0,i;
oggpack_writeinit(&write);
fprintf(stderr,"Testing codebook abstraction...:\n");
while(testlist[ptr]){
codebook c;
static_codebook s;
float *qv=alloca(sizeof(*qv)*TESTSIZE);
float *iv=alloca(sizeof(*iv)*TESTSIZE);
memcpy(qv,testvec[ptr],sizeof(*qv)*TESTSIZE);
memset(iv,0,sizeof(*iv)*TESTSIZE);
fprintf(stderr,"\tpacking/coding %ld... ",ptr);
/* pack the codebook, write the testvector */
oggpack_reset(&write);
vorbis_book_init_encode(&c,testlist[ptr]); /* get it into memory
we can write */
vorbis_staticbook_pack(testlist[ptr],&write);
fprintf(stderr,"Codebook size %ld bytes... ",oggpack_bytes(&write));
for(i=0;i<TESTSIZE;i+=c.dim){
int best=_best(&c,qv+i,1);
vorbis_book_encodev(&c,best,qv+i,&write);
}
vorbis_book_clear(&c);
fprintf(stderr,"OK.\n");
fprintf(stderr,"\tunpacking/decoding %ld... ",ptr);
/* transfer the write data to a read buffer and unpack/read */
oggpack_readinit(&read,oggpack_get_buffer(&write),oggpack_bytes(&write));
if(vorbis_staticbook_unpack(&read,&s)){
fprintf(stderr,"Error unpacking codebook.\n");
exit(1);
}
if(vorbis_book_init_decode(&c,&s)){
fprintf(stderr,"Error initializing codebook.\n");
exit(1);
}
for(i=0;i<TESTSIZE;i+=c.dim)
if(vorbis_book_decodev_set(&c,iv+i,&read,c.dim)==-1){
fprintf(stderr,"Error reading codebook test data (EOP).\n");
exit(1);
}
for(i=0;i<TESTSIZE;i++)
if(fabs(qv[i]-iv[i])>.000001){
fprintf(stderr,"read (%g) != written (%g) at position (%ld)\n",
iv[i],qv[i],i);
exit(1);
}
fprintf(stderr,"OK\n");
ptr++;
}
/* The above is the trivial stuff; now try unquantizing a log scale codebook */
exit(0);
}
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: basic shared codebook operations
last mod: $Id: codebook.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $
********************************************************************/
@ -40,8 +40,8 @@ typedef struct static_codebook{
/* mapping ***************************************************************/
int maptype; /* 0=none
1=implicitly populated values from map column
2=listed arbitrary values */
1=implicitly populated values from map column
2=listed arbitrary values */
/* The below does a linear, single monotonic sequence mapping. */
long q_min; /* packed 32 bit float; quant value 0 maps to minval */
@ -50,52 +50,11 @@ typedef struct static_codebook{
int q_sequencep; /* bitflag */
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
map == 2: list of dim*entries quantized entry vals
*/
/* encode helpers ********************************************************/
struct encode_aux_nearestmatch *nearest_tree;
struct encode_aux_threshmatch *thresh_tree;
struct encode_aux_pigeonhole *pigeon_tree;
map == 2: list of dim*entries quantized entry vals
*/
int allocedp;
} static_codebook;
/* this structures an arbitrary trained book to quickly find the
nearest cell match */
typedef struct encode_aux_nearestmatch{
/* pre-calculated partitioning tree */
long *ptr0;
long *ptr1;
long *p; /* decision points (each is an entry) */
long *q; /* decision points (each is an entry) */
long aux; /* number of tree entries */
long alloc;
} encode_aux_nearestmatch;
/* assumes a maptype of 1; encode side only, so that's OK */
typedef struct encode_aux_threshmatch{
float *quantthresh;
long *quantmap;
int quantvals;
int threshvals;
} encode_aux_threshmatch;
typedef struct encode_aux_pigeonhole{
float min;
float del;
int mapentries;
int quantvals;
long *pigeonmap;
long fittotal;
long *fitlist;
long *fitmap;
long *fitlength;
} encode_aux_pigeonhole;
typedef struct codebook{
long dim; /* codebook dimensions (elements per vector) */
long entries; /* codebook entries */
@ -105,7 +64,7 @@ typedef struct codebook{
/* for encode, the below are entry-ordered, fully populated */
/* for decode, the below are ordered by bitreversed codeword and only
used entries are populated */
float *valuelist; /* list of dim*entries actual entry values */
float *valuelist; /* list of dim*entries actual entry values */
ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
int *dec_index; /* only used if sparseness collapsed */
@ -114,9 +73,12 @@ typedef struct codebook{
int dec_firsttablen;
int dec_maxlength;
/* The current encoder uses only centered, integer-only lattice books. */
int quantvals;
int minval;
int delta;
} codebook;
extern void vorbis_staticbook_clear(static_codebook *b);
extern void vorbis_staticbook_destroy(static_codebook *b);
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
@ -137,23 +99,20 @@ extern long vorbis_book_codelen(codebook *book,int entry);
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
extern int vorbis_book_errorv(codebook *book, float *a);
extern int vorbis_book_encodev(codebook *book, int best,float *a,
oggpack_buffer *b);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodev_set(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodev_add(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodevs_add(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodev_set(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodev_add(codebook *book, float *a,
oggpack_buffer *b,int n);
extern long vorbis_book_decodevv_add(codebook *book, float **a,
long off,int ch,
oggpack_buffer *b,int n);
long off,int ch,
oggpack_buffer *b,int n);

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: libvorbis codec headers
last mod: $Id: codec_internal.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -23,20 +23,20 @@
#define BLOCKTYPE_IMPULSE 0
#define BLOCKTYPE_PADDING 1
#define BLOCKTYPE_TRANSITION 0
#define BLOCKTYPE_TRANSITION 0
#define BLOCKTYPE_LONG 1
#define PACKETBLOBS 15
typedef struct vorbis_block_internal{
float **pcmdelay; /* this is a pointer into local storage */
float **pcmdelay; /* this is a pointer into local storage */
float ampmax;
int blocktype;
oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed;
blob [PACKETBLOBS/2] points to
the oggpack_buffer in the
main vorbis_block */
oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed;
blob [PACKETBLOBS/2] points to
the oggpack_buffer in the
main vorbis_block */
} vorbis_block_internal;
typedef void vorbis_look_floor;
@ -60,7 +60,7 @@ typedef void vorbis_info_mapping;
typedef struct private_state {
/* local lookup storage */
envelope_lookup *ve; /* envelope lookup */
envelope_lookup *ve; /* envelope lookup */
int window[2];
vorbis_look_transform **transform[2]; /* block, type */
drft_lookup fft_look[2];
@ -87,7 +87,7 @@ typedef struct private_state {
/* codec_setup_info contains all the setup information specific to the
specific compression/decompression mode in progress (eg,
psychoacoustic settings, channel setup, options, codebook
etc).
etc).
*********************************************************************/
#include "highlevel.h"
@ -127,11 +127,41 @@ typedef struct codec_setup_info {
highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a
highly redundant structure, but
improves clarity of program flow. */
int halfrate_flag; /* painless downsample for decode */
int halfrate_flag; /* painless downsample for decode */
} codec_setup_info;
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
extern void _vp_global_free(vorbis_look_psy_global *look);
#endif
typedef struct {
int sorted_index[VIF_POSIT+2];
int forward_index[VIF_POSIT+2];
int reverse_index[VIF_POSIT+2];
int hineighbor[VIF_POSIT];
int loneighbor[VIF_POSIT];
int posts;
int n;
int quant_q;
vorbis_info_floor1 *vi;
long phrasebits;
long postbits;
long frames;
} vorbis_look_floor1;
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
const float *logmdct, /* in */
const float *logmask);
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
int *A,int *B,
int del);
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
vorbis_look_floor1 *look,
int *post,int *ilogmask);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: PCM data envelope analysis
last mod: $Id: envelope.c 13293 2007-07-24 00:09:47Z xiphmont $
function: PCM data envelope analysis
last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -67,7 +67,7 @@ void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
}
e->band[j].total=1./e->band[j].total;
}
e->filter=_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter));
e->mark=_ogg_calloc(e->storage,sizeof(*e->mark));
@ -88,11 +88,10 @@ void _ve_envelope_clear(envelope_lookup *e){
that works better and isn't patented. */
static int _ve_amp(envelope_lookup *ve,
vorbis_info_psy_global *gi,
float *data,
envelope_band *bands,
envelope_filter_state *filters,
long pos){
vorbis_info_psy_global *gi,
float *data,
envelope_band *bands,
envelope_filter_state *filters){
long n=ve->winlength;
int ret=0;
long i,j;
@ -111,15 +110,15 @@ static int _ve_amp(envelope_lookup *ve,
float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH);
if(penalty<0.f)penalty=0.f;
if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty;
/*_analysis_output_always("lpcm",seq2,data,n,0,0,
totalshift+pos*ve->searchstep);*/
/* window and transform */
for(i=0;i<n;i++)
vec[i]=data[i]*ve->mdct_win[i];
mdct_forward(&ve->mdct,vec,vec);
/*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */
/* near-DC spreading function; this has nothing to do with
@ -145,7 +144,7 @@ static int _ve_amp(envelope_lookup *ve,
if(filters->nearptr>=VE_NEARDC)filters->nearptr=0;
decay=todB(&decay)*.5-15.f;
}
/* perform spreading and limiting, also smooth the spectrum. yes,
the MDCT results in all real coefficients, but it still *behaves*
like real/imaginary pairs */
@ -159,7 +158,7 @@ static int _ve_amp(envelope_lookup *ve,
}
/*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/
/* perform preecho/postecho triggering by band */
for(j=0;j<VE_BANDS;j++){
float acc=0.;
@ -168,27 +167,27 @@ static int _ve_amp(envelope_lookup *ve,
/* accumulate amplitude */
for(i=0;i<bands[j].end;i++)
acc+=vec[i+bands[j].begin]*bands[j].window[i];
acc*=bands[j].total;
/* convert amplitude to delta */
{
int p,this=filters[j].ampptr;
float postmax,postmin,premax=-99999.f,premin=99999.f;
p=this;
p--;
if(p<0)p+=VE_AMP;
postmax=max(acc,filters[j].ampbuf[p]);
postmin=min(acc,filters[j].ampbuf[p]);
for(i=0;i<stretch;i++){
p--;
if(p<0)p+=VE_AMP;
premax=max(premax,filters[j].ampbuf[p]);
premin=min(premin,filters[j].ampbuf[p]);
p--;
if(p<0)p+=VE_AMP;
premax=max(premax,filters[j].ampbuf[p]);
premin=min(premin,filters[j].ampbuf[p]);
}
valmin=postmin-premin;
valmax=postmax-premax;
@ -205,7 +204,7 @@ static int _ve_amp(envelope_lookup *ve,
}
if(valmin<gi->postecho_thresh[j]-penalty)ret|=2;
}
return(ret);
}
@ -237,10 +236,10 @@ long _ve_envelope_search(vorbis_dsp_state *v){
ve->stretch++;
if(ve->stretch>VE_MAXSTRETCH*2)
ve->stretch=VE_MAXSTRETCH*2;
for(i=0;i<ve->ch;i++){
float *pcm=v->pcm[i]+ve->searchstep*(j);
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS,j);
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS);
}
ve->mark[j+VE_POST]=0;
@ -266,65 +265,65 @@ long _ve_envelope_search(vorbis_dsp_state *v){
ci->blocksizes[v->W]/4+
ci->blocksizes[1]/2+
ci->blocksizes[0]/4;
j=ve->cursor;
while(j<ve->current-(ve->searchstep)){/* account for postecho
working back one window */
if(j>=testW)return(1);
ve->cursor=j;
if(ve->mark[j/ve->searchstep]){
if(j>centerW){
if(j>centerW){
#if 0
if(j>ve->curmark){
float *marker=alloca(v->pcm_current*sizeof(*marker));
int l,m;
memset(marker,0,sizeof(*marker)*v->pcm_current);
fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n",
seq,
(totalshift+ve->cursor)/44100.,
(totalshift+j)/44100.);
_analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift);
_analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift);
if(j>ve->curmark){
float *marker=alloca(v->pcm_current*sizeof(*marker));
int l,m;
memset(marker,0,sizeof(*marker)*v->pcm_current);
fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n",
seq,
(totalshift+ve->cursor)/44100.,
(totalshift+j)/44100.);
_analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift);
_analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift);
_analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift);
_analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift);
for(m=0;m<VE_BANDS;m++){
char buf[80];
sprintf(buf,"delL%d",m);
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
}
_analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift);
_analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift);
for(m=0;m<VE_BANDS;m++){
char buf[80];
sprintf(buf,"delR%d",m);
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
}
for(m=0;m<VE_BANDS;m++){
char buf[80];
sprintf(buf,"delL%d",m);
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
}
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
_analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
seq++;
}
for(m=0;m<VE_BANDS;m++){
char buf[80];
sprintf(buf,"delR%d",m);
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
}
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
_analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
seq++;
}
#endif
ve->curmark=j;
if(j>=testW)return(1);
return(0);
}
ve->curmark=j;
if(j>=testW)return(1);
return(0);
}
}
j+=ve->searchstep;
}
}
return(-1);
}
@ -356,27 +355,21 @@ int _ve_envelope_mark(vorbis_dsp_state *v){
void _ve_envelope_shift(envelope_lookup *e,long shift){
int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks
ahead of ve->current */
ahead of ve->current */
int smallshift=shift/e->searchstep;
memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark));
#if 0
for(i=0;i<VE_BANDS*e->ch;i++)
memmove(e->filter[i].markers,
e->filter[i].markers+smallshift,
(1024-smallshift)*sizeof(*(*e->filter).markers));
e->filter[i].markers+smallshift,
(1024-smallshift)*sizeof(*(*e->filter).markers));
totalshift+=shift;
#endif
#endif
e->current-=shift;
if(e->curmark>=0)
e->curmark-=shift;
e->cursor-=shift;
}

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: PCM data envelope analysis and manipulation
last mod: $Id: envelope.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: envelope.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -78,4 +78,3 @@ extern int _ve_envelope_mark(vorbis_dsp_state *v);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: floor backend 0 implementation
last mod: $Id: floor0.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: floor0.c 18184 2012-02-03 20:55:12Z xiphmont $
********************************************************************/
@ -82,15 +82,17 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
info->ampbits=oggpack_read(opb,6);
info->ampdB=oggpack_read(opb,8);
info->numbooks=oggpack_read(opb,4)+1;
if(info->order<1)goto err_out;
if(info->rate<1)goto err_out;
if(info->barkmap<1)goto err_out;
if(info->numbooks<1)goto err_out;
for(j=0;j<info->numbooks;j++){
info->books[j]=oggpack_read(opb,8);
if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out;
if(ci->book_param[info->books[j]]->maptype==0)goto err_out;
if(ci->book_param[info->books[j]]->dim<1)goto err_out;
}
return(info);
@ -108,8 +110,8 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
linear block and mapping sizes */
static void floor0_map_lazy_init(vorbis_block *vb,
vorbis_info_floor *infoX,
vorbis_look_floor0 *look){
vorbis_info_floor *infoX,
vorbis_look_floor0 *look){
if(!look->linearmap[vb->W]){
vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
@ -122,7 +124,7 @@ static void floor0_map_lazy_init(vorbis_block *vb,
floor(bark(rate/2-1)*C)=mapped-1
floor(bark(rate/2)*C)=mapped */
float scale=look->ln/toBARK(info->rate/2.f);
/* the mapping from a linear scale to a smaller bark scale is
straightforward. We do *not* make sure that the linear mapping
does not skip bark-scale bins; the decoder simply skips them and
@ -131,8 +133,8 @@ static void floor0_map_lazy_init(vorbis_block *vb,
accurate */
look->linearmap[W]=_ogg_malloc((n+1)*sizeof(**look->linearmap));
for(j=0;j<n;j++){
int val=floor( toBARK((info->rate/2.f)/n*j)
*scale); /* bark numbers represent band edges */
int val=floor( toBARK((info->rate/2.f)/n*j)
*scale); /* bark numbers represent band edges */
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
look->linearmap[W][j]=val;
}
@ -142,7 +144,7 @@ static void floor0_map_lazy_init(vorbis_block *vb,
}
static vorbis_look_floor *floor0_look(vorbis_dsp_state *vd,
vorbis_info_floor *i){
vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
vorbis_look_floor0 *look=_ogg_calloc(1,sizeof(*look));
look->m=info->order;
@ -164,7 +166,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
long maxval=(1<<info->ampbits)-1;
float amp=(float)ampraw/maxval*info->ampdB;
int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
codec_setup_info *ci=vb->vd->vi->codec_setup;
codebook *b=ci->fullbooks+info->books[booknum];
@ -174,14 +176,13 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
smash; b->dim is provably more than we can overflow the
vector */
float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1));
for(j=0;j<look->m;j+=b->dim)
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m)==-1)goto eop;
for(j=0;j<look->m;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
for(k=0;j<look->m && k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
}
lsp[look->m]=amp;
return(lsp);
}
@ -191,10 +192,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
}
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
void *memo,float *out){
void *memo,float *out){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
floor0_map_lazy_init(vb,info,look);
if(memo){
@ -203,10 +204,10 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
/* take the coefficients back to a spectral envelope curve */
vorbis_lsp_to_curve(out,
look->linearmap[vb->W],
look->n[vb->W],
look->ln,
lsp,look->m,amp,(float)info->ampdB);
look->linearmap[vb->W],
look->n[vb->W],
look->ln,
lsp,look->m,amp,(float)info->ampdB);
return(1);
}
memset(out,0,sizeof(*out)*look->n[vb->W]);
@ -214,10 +215,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
}
/* export hooks */
vorbis_func_floor floor0_exportbundle={
const vorbis_func_floor floor0_exportbundle={
NULL,&floor0_unpack,&floor0_look,&floor0_free_info,
&floor0_free_look,&floor0_inverse1,&floor0_inverse2
};

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: highlevel encoder setup struct seperated out for vorbisenc clarity
last mod: $Id: highlevel.h 13293 2007-07-24 00:09:47Z xiphmont $
function: highlevel encoder setup struct separated out for vorbisenc clarity
last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $
********************************************************************/
@ -21,16 +21,16 @@ typedef struct highlevel_byblocktype {
double noise_bias_setting;
double noise_compand_setting;
} highlevel_byblocktype;
typedef struct highlevel_encode_setup {
void *setup;
int set_in_stone;
typedef struct highlevel_encode_setup {
int set_in_stone;
const void *setup;
double base_setting;
double long_setting;
double short_setting;
double impulse_noisetune;
/* bitrate management below all settable */
float req;
int managed;
long bitrate_min;
long bitrate_av;
@ -38,20 +38,21 @@ typedef struct highlevel_encode_setup {
long bitrate_max;
long bitrate_reservoir;
double bitrate_reservoir_bias;
int impulse_block_p;
int noise_normalize_p;
int coupling_p;
double stereo_point_setting;
double lowpass_kHz;
int lowpass_altered;
double ath_floating_dB;
double ath_absolute_dB;
double amplitude_track_dBpersec;
double trigger_setting;
highlevel_byblocktype block[4]; /* padding, impulse, transition, long */
} highlevel_encode_setup;

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: maintain the info structure, info <-> header packets
last mod: $Id: info.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: info.c 18186 2012-02-03 22:08:44Z xiphmont $
********************************************************************/
@ -31,6 +31,9 @@
#include "misc.h"
#include "os.h"
#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.3"
#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20120203 (Omnipresent)"
/* helpers */
static int ilog2(unsigned int v){
int ret=0;
@ -42,7 +45,7 @@ static int ilog2(unsigned int v){
return(ret);
}
static void _v_writestring(oggpack_buffer *o,char *s, int bytes){
static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){
while(bytes--){
oggpack_write(o,*s++,8);
@ -59,11 +62,11 @@ void vorbis_comment_init(vorbis_comment *vc){
memset(vc,0,sizeof(*vc));
}
void vorbis_comment_add(vorbis_comment *vc,char *comment){
void vorbis_comment_add(vorbis_comment *vc,const char *comment){
vc->user_comments=_ogg_realloc(vc->user_comments,
(vc->comments+2)*sizeof(*vc->user_comments));
(vc->comments+2)*sizeof(*vc->user_comments));
vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
(vc->comments+2)*sizeof(*vc->comment_lengths));
(vc->comments+2)*sizeof(*vc->comment_lengths));
vc->comment_lengths[vc->comments]=strlen(comment);
vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
strcpy(vc->user_comments[vc->comments], comment);
@ -71,7 +74,7 @@ void vorbis_comment_add(vorbis_comment *vc,char *comment){
vc->user_comments[vc->comments]=NULL;
}
void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){
void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){
char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
strcpy(comment, tag);
strcat(comment, "=");
@ -91,7 +94,7 @@ static int tagcompare(const char *s1, const char *s2, int n){
return 0;
}
char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){
long i;
int found = 0;
int taglen = strlen(tag)+1; /* +1 for the = we append */
@ -99,20 +102,20 @@ char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
strcpy(fulltag, tag);
strcat(fulltag, "=");
for(i=0;i<vc->comments;i++){
if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
if(count == found)
/* We return a pointer to the data, not a copy */
return vc->user_comments[i] + taglen;
/* We return a pointer to the data, not a copy */
return vc->user_comments[i] + taglen;
else
found++;
found++;
}
}
return NULL; /* didn't find anything */
}
int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){
int i,count=0;
int taglen = strlen(tag)+1; /* +1 for the = we append */
char *fulltag = alloca(taglen+1);
@ -130,10 +133,12 @@ int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
void vorbis_comment_clear(vorbis_comment *vc){
if(vc){
long i;
for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
if(vc->user_comments)_ogg_free(vc->user_comments);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->user_comments){
for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
_ogg_free(vc->user_comments);
}
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor);
memset(vc,0,sizeof(*vc));
}
@ -163,33 +168,33 @@ void vorbis_info_clear(vorbis_info *vi){
for(i=0;i<ci->maps;i++) /* unpack does the range checking */
if(ci->map_param[i]) /* this may be cleaning up an aborted
unpack, in which case the below type
cannot be trusted */
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
unpack, in which case the below type
cannot be trusted */
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
for(i=0;i<ci->floors;i++) /* unpack does the range checking */
if(ci->floor_param[i]) /* this may be cleaning up an aborted
unpack, in which case the below type
cannot be trusted */
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
unpack, in which case the below type
cannot be trusted */
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
for(i=0;i<ci->residues;i++) /* unpack does the range checking */
if(ci->residue_param[i]) /* this may be cleaning up an aborted
unpack, in which case the below type
cannot be trusted */
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
unpack, in which case the below type
cannot be trusted */
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
for(i=0;i<ci->books;i++){
if(ci->book_param[i]){
/* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
/* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
}
if(ci->fullbooks)
vorbis_book_clear(ci->fullbooks+i);
vorbis_book_clear(ci->fullbooks+i);
}
if(ci->fullbooks)
_ogg_free(ci->fullbooks);
_ogg_free(ci->fullbooks);
for(i=0;i<ci->psys;i++)
_vi_psy_free(ci->psy_param[i]);
@ -217,10 +222,10 @@ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
ci->blocksizes[0]=1<<oggpack_read(opb,4);
ci->blocksizes[1]=1<<oggpack_read(opb,4);
if(vi->rate<1)goto err_out;
if(vi->channels<1)goto err_out;
if(ci->blocksizes[0]<64)goto err_out;
if(ci->blocksizes[0]<64)goto err_out;
if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out;
if(ci->blocksizes[1]>8192)goto err_out;
@ -236,20 +241,24 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
int i;
int vendorlen=oggpack_read(opb,32);
if(vendorlen<0)goto err_out;
if(vendorlen>opb->storage-8)goto err_out;
vc->vendor=_ogg_calloc(vendorlen+1,1);
_v_readstring(opb,vc->vendor,vendorlen);
vc->comments=oggpack_read(opb,32);
if(vc->comments<0)goto err_out;
i=oggpack_read(opb,32);
if(i<0)goto err_out;
if(i>((opb->storage-oggpack_bytes(opb))>>2))goto err_out;
vc->comments=i;
vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
for(i=0;i<vc->comments;i++){
int len=oggpack_read(opb,32);
if(len<0)goto err_out;
vc->comment_lengths[i]=len;
if(len>opb->storage-oggpack_bytes(opb))goto err_out;
vc->comment_lengths[i]=len;
vc->user_comments[i]=_ogg_calloc(len+1,1);
_v_readstring(opb,vc->user_comments[i],len);
}
}
if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
return(0);
@ -267,15 +276,16 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* codebooks */
ci->books=oggpack_read(opb,8)+1;
/*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/
if(ci->books<=0)goto err_out;
for(i=0;i<ci->books;i++){
ci->book_param[i]=_ogg_calloc(1,sizeof(*ci->book_param[i]));
if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out;
ci->book_param[i]=vorbis_staticbook_unpack(opb);
if(!ci->book_param[i])goto err_out;
}
/* time backend settings; hooks are unused */
{
int times=oggpack_read(opb,6)+1;
if(times<=0)goto err_out;
for(i=0;i<times;i++){
int test=oggpack_read(opb,16);
if(test<0 || test>=VI_TIMEB)goto err_out;
@ -284,8 +294,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* floor backend settings */
ci->floors=oggpack_read(opb,6)+1;
/*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/
/*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/
if(ci->floors<=0)goto err_out;
for(i=0;i<ci->floors;i++){
ci->floor_type[i]=oggpack_read(opb,16);
if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
@ -295,8 +304,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* residue backend settings */
ci->residues=oggpack_read(opb,6)+1;
/*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/
/*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/
if(ci->residues<=0)goto err_out;
for(i=0;i<ci->residues;i++){
ci->residue_type[i]=oggpack_read(opb,16);
if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
@ -306,18 +314,17 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* map backend settings */
ci->maps=oggpack_read(opb,6)+1;
/*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/
/*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/
if(ci->maps<=0)goto err_out;
for(i=0;i<ci->maps;i++){
ci->map_type[i]=oggpack_read(opb,16);
if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);
if(!ci->map_param[i])goto err_out;
}
/* mode settings */
ci->modes=oggpack_read(opb,6)+1;
/*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/
if(ci->modes<=0)goto err_out;
for(i=0;i<ci->modes;i++){
ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i]));
ci->mode_param[i]->blockflag=oggpack_read(opb,1);
@ -328,8 +335,9 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;
if(ci->mode_param[i]->mapping<0)goto err_out;
}
if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
return(0);
@ -370,7 +378,7 @@ int vorbis_synthesis_idheader(ogg_packet *op){
int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
oggpack_buffer opb;
if(op){
oggpack_readinit(&opb,op->packet,op->bytes);
@ -382,42 +390,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
memset(buffer,0,6);
_v_readstring(&opb,buffer,6);
if(memcmp(buffer,"vorbis",6)){
/* not a vorbis header */
return(OV_ENOTVORBIS);
/* not a vorbis header */
return(OV_ENOTVORBIS);
}
switch(packtype){
case 0x01: /* least significant *bit* is read first */
if(!op->b_o_s){
/* Not the initial packet */
return(OV_EBADHEADER);
}
if(vi->rate!=0){
/* previously initialized info header */
return(OV_EBADHEADER);
}
if(!op->b_o_s){
/* Not the initial packet */
return(OV_EBADHEADER);
}
if(vi->rate!=0){
/* previously initialized info header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_info(vi,&opb));
return(_vorbis_unpack_info(vi,&opb));
case 0x03: /* least significant *bit* is read first */
if(vi->rate==0){
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
if(vi->rate==0){
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_comment(vc,&opb));
return(_vorbis_unpack_comment(vc,&opb));
case 0x05: /* least significant *bit* is read first */
if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_books(vi,&opb));
return(_vorbis_unpack_books(vi,&opb));
default:
/* Not a valid vorbis header type */
return(OV_EBADHEADER);
break;
/* Not a valid vorbis header type */
return(OV_EBADHEADER);
break;
}
}
}
@ -430,7 +438,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup;
if(!ci)return(OV_EFAULT);
/* preamble */
/* preamble */
oggpack_write(opb,0x01,8);
_v_writestring(opb,"vorbis", 6);
@ -451,17 +459,16 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
}
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
char temp[]="Xiph.Org libVorbis I 20070622";
int bytes = strlen(temp);
int bytes = strlen(ENCODE_VENDOR_STRING);
/* preamble */
/* preamble */
oggpack_write(opb,0x03,8);
_v_writestring(opb,"vorbis", 6);
/* vendor */
oggpack_write(opb,bytes,32);
_v_writestring(opb,temp, bytes);
_v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
/* comments */
oggpack_write(opb,vc->comments,32);
@ -469,10 +476,10 @@ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
int i;
for(i=0;i<vc->comments;i++){
if(vc->user_comments[i]){
oggpack_write(opb,vc->comment_lengths[i],32);
_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
oggpack_write(opb,vc->comment_lengths[i],32);
_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
}else{
oggpack_write(opb,0,32);
oggpack_write(opb,0,32);
}
}
}
@ -480,7 +487,7 @@ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
return(0);
}
static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup;
int i;
@ -535,15 +542,18 @@ static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
return(0);
err_out:
return(-1);
}
}
int vorbis_commentheader_out(vorbis_comment *vc,
ogg_packet *op){
ogg_packet *op){
oggpack_buffer opb;
oggpack_writeinit(&opb);
if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
if(_vorbis_pack_comment(&opb,vc)){
oggpack_writeclear(&opb);
return OV_EIMPL;
}
op->packet = _ogg_malloc(oggpack_bytes(&opb));
memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
@ -554,14 +564,15 @@ int vorbis_commentheader_out(vorbis_comment *vc,
op->granulepos=0;
op->packetno=1;
oggpack_writeclear(&opb);
return 0;
}
int vorbis_analysis_headerout(vorbis_dsp_state *v,
vorbis_comment *vc,
ogg_packet *op,
ogg_packet *op_comm,
ogg_packet *op_code){
vorbis_comment *vc,
ogg_packet *op,
ogg_packet *op_comm,
ogg_packet *op_code){
int ret=OV_EIMPL;
vorbis_info *vi=v->vi;
oggpack_buffer opb;
@ -621,12 +632,12 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v,
oggpack_writeclear(&opb);
return(0);
err_out:
oggpack_writeclear(&opb);
memset(op,0,sizeof(*op));
memset(op_comm,0,sizeof(*op_comm));
memset(op_code,0,sizeof(*op_code));
if(b){
oggpack_writeclear(&opb);
if(b->header)_ogg_free(b->header);
if(b->header1)_ogg_free(b->header1);
if(b->header2)_ogg_free(b->header2);
@ -638,7 +649,20 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v,
}
double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){
if(granulepos>=0)
if(granulepos == -1) return -1;
/* We're not guaranteed a 64 bit unsigned type everywhere, so we
have to put the unsigned granpo in a signed type. */
if(granulepos>=0){
return((double)granulepos/v->vi->rate);
return(-1);
}else{
ogg_int64_t granuleoff=0xffffffff;
granuleoff<<=31;
granuleoff|=0x7ffffffff;
return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate);
}
}
const char *vorbis_version_string(void){
return GENERAL_VENDOR_STRING;
}

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: lookup based functions
last mod: $Id: lookup.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lookup.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -56,16 +56,16 @@ float vorbis_fromdBlook(float a){
#ifdef INT_LOOKUP
/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in
16.16 format
16.16 format
returns in m.8 format */
long vorbis_invsqlook_i(long a,long e){
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long d=(a&INVSQ_LOOKUP_I_MASK)<<(16-INVSQ_LOOKUP_I_SHIFT); /* 0.16 */
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */
(((INVSQ_LOOKUP_I[i]-INVSQ_LOOKUP_I[i+1])* /* 0.16 */
d)>>16); /* result 1.16 */
e+=32;
if(e&1)val=(val*5792)>>13; /* multiply val by 1/sqrt(2) */
e=(e>>1)-8;
@ -88,7 +88,7 @@ long vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
COS_LOOKUP_I_SHIFT);
COS_LOOKUP_I_SHIFT);
}
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: lookup based functions
last mod: $Id: lookup.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -27,6 +27,6 @@ extern float vorbis_fromdBlook(float a);
extern long vorbis_invsqlook_i(long a,long e);
extern long vorbis_coslook_i(long a);
extern float vorbis_fromdBlook_i(long a);
#endif
#endif
#endif

View file

@ -11,7 +11,7 @@
********************************************************************
function: lookup data; generated by lookups.pl; edit there
last mod: $Id: lookup_data.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lookup_data.h 16037 2009-05-26 21:10:58Z xiphmont $
********************************************************************/
@ -19,76 +19,76 @@
#ifdef FLOAT_LOOKUP
#define COS_LOOKUP_SZ 128
static float COS_LOOKUP[COS_LOOKUP_SZ+1]={
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
-1.0000000000000f,
static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
-1.0000000000000f,
};
#define INVSQ_LOOKUP_SZ 32
static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
1.000000000000f,
static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
1.000000000000f,
};
#define INVSQ2EXP_LOOKUP_MIN (-32)
#define INVSQ2EXP_LOOKUP_MAX 32
static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
INVSQ2EXP_LOOKUP_MIN+1]={
65536.f, 46340.95001f, 32768.f, 23170.47501f,
16384.f, 11585.2375f, 8192.f, 5792.618751f,
4096.f, 2896.309376f, 2048.f, 1448.154688f,
1024.f, 724.0773439f, 512.f, 362.038672f,
256.f, 181.019336f, 128.f, 90.50966799f,
64.f, 45.254834f, 32.f, 22.627417f,
16.f, 11.3137085f, 8.f, 5.656854249f,
4.f, 2.828427125f, 2.f, 1.414213562f,
1.f, 0.7071067812f, 0.5f, 0.3535533906f,
0.25f, 0.1767766953f, 0.125f, 0.08838834765f,
0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f,
0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f,
0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f,
0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f,
0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
1.525878906e-05f,
65536.f, 46340.95001f, 32768.f, 23170.47501f,
16384.f, 11585.2375f, 8192.f, 5792.618751f,
4096.f, 2896.309376f, 2048.f, 1448.154688f,
1024.f, 724.0773439f, 512.f, 362.038672f,
256.f, 181.019336f, 128.f, 90.50966799f,
64.f, 45.254834f, 32.f, 22.627417f,
16.f, 11.3137085f, 8.f, 5.656854249f,
4.f, 2.828427125f, 2.f, 1.414213562f,
1.f, 0.7071067812f, 0.5f, 0.3535533906f,
0.25f, 0.1767766953f, 0.125f, 0.08838834765f,
0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f,
0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f,
0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f,
0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f,
0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
1.525878906e-05f,
};
#endif
@ -98,90 +98,93 @@ static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
#define FROMdB_SHIFT 5
#define FROMdB2_SHIFT 3
#define FROMdB2_MASK 31
static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f,
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f,
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f,
0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f,
0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f,
2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f,
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
#ifdef FLOAT_LOOKUP
static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f,
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f,
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f,
0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f,
0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f,
2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f,
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
};
static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f,
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f,
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f,
0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f,
0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f,
0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f,
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f,
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,
static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f,
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f,
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f,
0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f,
0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f,
0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f,
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f,
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,
};
#endif
#ifdef INT_LOOKUP
#define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023
static long INVSQ_LOOKUP_I[64+1]={
92682l, 91966l, 91267l, 90583l,
89915l, 89261l, 88621l, 87995l,
87381l, 86781l, 86192l, 85616l,
85051l, 84497l, 83953l, 83420l,
82897l, 82384l, 81880l, 81385l,
80899l, 80422l, 79953l, 79492l,
79039l, 78594l, 78156l, 77726l,
77302l, 76885l, 76475l, 76072l,
75674l, 75283l, 74898l, 74519l,
74146l, 73778l, 73415l, 73058l,
72706l, 72359l, 72016l, 71679l,
71347l, 71019l, 70695l, 70376l,
70061l, 69750l, 69444l, 69141l,
68842l, 68548l, 68256l, 67969l,
67685l, 67405l, 67128l, 66855l,
66585l, 66318l, 66054l, 65794l,
65536l,
static const long INVSQ_LOOKUP_I[64+1]={
92682l, 91966l, 91267l, 90583l,
89915l, 89261l, 88621l, 87995l,
87381l, 86781l, 86192l, 85616l,
85051l, 84497l, 83953l, 83420l,
82897l, 82384l, 81880l, 81385l,
80899l, 80422l, 79953l, 79492l,
79039l, 78594l, 78156l, 77726l,
77302l, 76885l, 76475l, 76072l,
75674l, 75283l, 74898l, 74519l,
74146l, 73778l, 73415l, 73058l,
72706l, 72359l, 72016l, 71679l,
71347l, 71019l, 70695l, 70376l,
70061l, 69750l, 69444l, 69141l,
68842l, 68548l, 68256l, 67969l,
67685l, 67405l, 67128l, 66855l,
66585l, 66318l, 66054l, 65794l,
65536l,
};
#define COS_LOOKUP_I_SHIFT 9
#define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128
static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
16384l, 16379l, 16364l, 16340l,
16305l, 16261l, 16207l, 16143l,
16069l, 15986l, 15893l, 15791l,
15679l, 15557l, 15426l, 15286l,
15137l, 14978l, 14811l, 14635l,
14449l, 14256l, 14053l, 13842l,
13623l, 13395l, 13160l, 12916l,
12665l, 12406l, 12140l, 11866l,
11585l, 11297l, 11003l, 10702l,
10394l, 10080l, 9760l, 9434l,
9102l, 8765l, 8423l, 8076l,
7723l, 7366l, 7005l, 6639l,
6270l, 5897l, 5520l, 5139l,
4756l, 4370l, 3981l, 3590l,
3196l, 2801l, 2404l, 2006l,
1606l, 1205l, 804l, 402l,
0l, -401l, -803l, -1204l,
-1605l, -2005l, -2403l, -2800l,
-3195l, -3589l, -3980l, -4369l,
-4755l, -5138l, -5519l, -5896l,
-6269l, -6638l, -7004l, -7365l,
-7722l, -8075l, -8422l, -8764l,
-9101l, -9433l, -9759l, -10079l,
-10393l, -10701l, -11002l, -11296l,
-11584l, -11865l, -12139l, -12405l,
-12664l, -12915l, -13159l, -13394l,
-13622l, -13841l, -14052l, -14255l,
-14448l, -14634l, -14810l, -14977l,
-15136l, -15285l, -15425l, -15556l,
-15678l, -15790l, -15892l, -15985l,
-16068l, -16142l, -16206l, -16260l,
-16304l, -16339l, -16363l, -16378l,
-16383l,
static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
16384l, 16379l, 16364l, 16340l,
16305l, 16261l, 16207l, 16143l,
16069l, 15986l, 15893l, 15791l,
15679l, 15557l, 15426l, 15286l,
15137l, 14978l, 14811l, 14635l,
14449l, 14256l, 14053l, 13842l,
13623l, 13395l, 13160l, 12916l,
12665l, 12406l, 12140l, 11866l,
11585l, 11297l, 11003l, 10702l,
10394l, 10080l, 9760l, 9434l,
9102l, 8765l, 8423l, 8076l,
7723l, 7366l, 7005l, 6639l,
6270l, 5897l, 5520l, 5139l,
4756l, 4370l, 3981l, 3590l,
3196l, 2801l, 2404l, 2006l,
1606l, 1205l, 804l, 402l,
0l, -401l, -803l, -1204l,
-1605l, -2005l, -2403l, -2800l,
-3195l, -3589l, -3980l, -4369l,
-4755l, -5138l, -5519l, -5896l,
-6269l, -6638l, -7004l, -7365l,
-7722l, -8075l, -8422l, -8764l,
-9101l, -9433l, -9759l, -10079l,
-10393l, -10701l, -11002l, -11296l,
-11584l, -11865l, -12139l, -12405l,
-12664l, -12915l, -13159l, -13394l,
-13622l, -13841l, -14052l, -14255l,
-14448l, -14634l, -14810l, -14977l,
-15136l, -15285l, -15425l, -15556l,
-15678l, -15790l, -15892l, -15985l,
-16068l, -16142l, -16206l, -16260l,
-16304l, -16339l, -16363l, -16378l,
-16383l,
};
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: LPC low level routines
last mod: $Id: lpc.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -62,6 +62,7 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
double *aut=alloca(sizeof(*aut)*(m+1));
double *lpc=alloca(sizeof(*lpc)*(m));
double error;
double epsilon;
int i,j;
/* autocorrelation, p+1 lag coefficients */
@ -71,17 +72,19 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
aut[j]=d;
}
/* Generate lpc coefficients from autocorr values */
error=aut[0];
/* set our noise floor to about -100dB */
error=aut[0] * (1. + 1e-10);
epsilon=1e-9*aut[0]+1e-10;
for(i=0;i<m;i++){
double r= -aut[i+1];
if(error==0){
memset(lpci,0,m*sizeof(*lpci));
return 0;
if(error<epsilon){
memset(lpc+i,0,(m-i)*sizeof(*lpc));
goto done;
}
/* Sum up this iteration's reflection coefficient; note that in
@ -90,10 +93,10 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
each iteration. */
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
r/=error;
r/=error;
/* Update LPC coefficients and total error */
lpc[i]=r;
for(j=0;j<i/2;j++){
double tmp=lpc[j];
@ -101,23 +104,36 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp;
}
if(i%2)lpc[j]+=lpc[j]*r;
if(i&1)lpc[j]+=lpc[j]*r;
error*=1.f-r*r;
error*=1.-r*r;
}
done:
/* slightly damp the filter */
{
double g = .99;
double damp = g;
for(j=0;j<m;j++){
lpc[j]*=damp;
damp*=g;
}
}
for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
/* we need the error value to know how big an impulse to hit the
filter with later */
return error;
}
void vorbis_lpc_predict(float *coeff,float *prime,int m,
float *data,long n){
/* in: coeff[0...m-1] LPC coefficients
/* in: coeff[0...m-1] LPC coefficients
prime[0...m-1] initial values (allocated size of n+m-1)
out: data[0...n-1] data samples */
@ -138,12 +154,7 @@ void vorbis_lpc_predict(float *coeff,float *prime,int m,
p=m;
for(j=0;j<m;j++)
y-=work[o++]*coeff[--p];
data[i]=work[o]=y;
}
}

View file

@ -11,7 +11,7 @@
********************************************************************
function: LPC low level routines
last mod: $Id: lpc.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $
********************************************************************/
@ -24,6 +24,6 @@
extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m);
extern void vorbis_lpc_predict(float *coeff,float *prime,int m,
float *data,long n);
float *data,long n);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: LSP (also called LSF) conversion routines
last mod: $Id: lsp.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lsp.c 17538 2010-10-15 02:52:29Z tterribe $
The LSP generation code is taken (with minimal modification and a
few bugfixes) from "On the Computation of the LSP Frequencies" by
@ -46,14 +46,15 @@
implementation. The float lookup is likely the optimal choice on
any machine with an FPU. The integer implementation is *not* fixed
point (due to the need for a large dynamic range and thus a
seperately tracked exponent) and thus much more complex than the
separately tracked exponent) and thus much more complex than the
relatively simple float implementations. It's mostly for future
work on a fully fixed point implementation for processors like the
ARM family. */
/* undefine both for the 'old' but more precise implementation */
#define FLOAT_LOOKUP
#undef INT_LOOKUP
/* define either of these (preferably FLOAT_LOOKUP) to have faster
but less precise implementation. */
#undef FLOAT_LOOKUP
#undef INT_LOOKUP
#ifdef FLOAT_LOOKUP
#include "lookup.c" /* catch this in the build system; we #include for
@ -62,11 +63,11 @@
/* side effect: changes *lsp to cosines of lsp */
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
float amp,float ampoffset){
float amp,float ampoffset){
int i;
float wdel=M_PI/ln;
vorbis_fpu_control fpu;
vorbis_fpu_setround(&fpu);
for(i=0;i<m;i++)lsp[i]=vorbis_coslook(lsp[i]);
@ -80,11 +81,11 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
float *ftmp=lsp;
int c=m>>1;
do{
while(c--){
q*=ftmp[0]-w;
p*=ftmp[1]-w;
ftmp+=2;
}while(--c);
}
if(m&1){
/* odd order filter; slightly assymetric */
@ -99,10 +100,10 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
}
q=frexp(p+q,&qexp);
q=vorbis_fromdBlook(amp*
vorbis_invsqlook(q)*
vorbis_invsq2explook(qexp+m)-
ampoffset);
q=vorbis_fromdBlook(amp*
vorbis_invsqlook(q)*
vorbis_invsq2explook(qexp+m)-
ampoffset);
do{
curve[i++]*=q;
@ -118,26 +119,26 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
compilers (like gcc) that can't inline across
modules */
static int MLOOP_1[64]={
static const int MLOOP_1[64]={
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
};
static int MLOOP_2[64]={
static const int MLOOP_2[64]={
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
};
static int MLOOP_3[8]={0,1,2,2,3,3,3,3};
static const int MLOOP_3[8]={0,1,2,2,3,3,3,3};
/* side effect: changes *lsp to cosines of lsp */
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
float amp,float ampoffset){
float amp,float ampoffset){
/* 0 <= m < 256 */
@ -161,15 +162,15 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
for(j=3;j<m;j+=2){
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)*labs(ilsp[j]-wi);
qexp+=shift;
}
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
shift=MLOOP_3[(pi|qi)>>16];
/* pi,qi normalized collectively, both tracked using qexp */
@ -181,9 +182,9 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
qexp+=shift;
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
pi>>=shift;
qi>>=shift;
qexp+=shift-14*((m+1)>>1);
@ -199,8 +200,8 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
/* even order filter; still symmetric */
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
worth tracking step by step */
worth tracking step by step */
pi>>=shift;
qi>>=shift;
qexp+=shift-7*m;
@ -208,36 +209,36 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
pi=((pi*pi)>>16);
qi=((qi*qi)>>16);
qexp=qexp*2+m;
pi*=(1<<14)-wi;
qi*=(1<<14)+wi;
qi=(qi+pi)>>14;
}
/* we've let the normalization drift because it wasn't important;
however, for the lookup, things must be normalized again. We
need at most one right shift or a number of left shifts */
if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
qi>>=1; qexp++;
qi>>=1; qexp++;
}else
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
qi<<=1; qexp--;
qi<<=1; qexp--;
}
amp=vorbis_fromdBlook_i(ampi* /* n.4 */
vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
curve[i]*=amp;
while(map[++i]==k)curve[i]*=amp;
}
}
#else
#else
/* old, nonoptimized but simple version for any poor sap who needs to
figure out what the hell this code does, or wants the other
@ -245,7 +246,7 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
/* side effect: changes *lsp to cosines of lsp */
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
float amp,float ampoffset){
float amp,float ampoffset){
int i;
float wdel=M_PI/ln;
for(i=0;i<m;i++)lsp[i]=2.f*cos(lsp[i]);
@ -289,7 +290,7 @@ static void cheby(float *g, int ord) {
for(i=2; i<= ord; i++) {
for(j=ord; j >= i; j--) {
g[j-2] -= g[j];
g[j] += g[j];
g[j] += g[j];
}
}
}
@ -318,25 +319,25 @@ static int Laguerre_With_Deflation(float *a,int ord,float *r){
/* iterate a root */
while(1){
double p=defl[m],pp=0.f,ppp=0.f,denom;
/* eval the polynomial and its first two derivatives */
for(i=m;i>0;i--){
ppp = new*ppp + pp;
pp = new*pp + p;
p = new*p + defl[i-1];
ppp = new*ppp + pp;
pp = new*pp + p;
p = new*p + defl[i-1];
}
/* Laguerre's method */
denom=(m-1) * ((m-1)*pp*pp - m*p*ppp);
if(denom<0)
return(-1); /* complex root! The LPC generator handed us a bad filter */
return(-1); /* complex root! The LPC generator handed us a bad filter */
if(pp>0){
denom = pp + sqrt(denom);
if(denom<EPSILON)denom=EPSILON;
denom = pp + sqrt(denom);
if(denom<EPSILON)denom=EPSILON;
}else{
denom = pp - sqrt(denom);
if(denom>-(EPSILON))denom=-(EPSILON);
denom = pp - sqrt(denom);
if(denom>-(EPSILON))denom=-(EPSILON);
}
delta = m*p/denom;
@ -344,14 +345,14 @@ static int Laguerre_With_Deflation(float *a,int ord,float *r){
if(delta<0.f)delta*=-1;
if(fabs(delta/new)<10e-12)break;
if(fabs(delta/new)<10e-12)break;
lastdelta=delta;
}
r[m-1]=new;
/* forward deflation */
for(i=m;i>0;i--)
defl[i-1]+=new*defl[i];
defl++;
@ -368,27 +369,27 @@ static int Newton_Raphson(float *a,int ord,float *r){
double *root=alloca(ord*sizeof(*root));
for(i=0; i<ord;i++) root[i] = r[i];
while(error>1e-20){
error=0;
for(i=0; i<ord; i++) { /* Update each point. */
double pp=0.,delta;
double rooti=root[i];
double p=a[ord];
for(k=ord-1; k>= 0; k--) {
pp= pp* rooti + p;
p = p * rooti + a[k];
pp= pp* rooti + p;
p = p * rooti + a[k];
}
delta = p/pp;
root[i] -= delta;
error+= delta*delta;
}
if(count>40)return(-1);
count++;
}
@ -418,12 +419,12 @@ int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m){
/* Compute the first half of K & R F1 & F2 polynomials. */
/* Compute half of the symmetric and antisymmetric polynomials. */
/* Remove the roots at +1 and -1. */
g1[g1_order] = 1.f;
for(i=1;i<=g1_order;i++) g1[g1_order-i] = lpc[i-1]+lpc[m-i];
g2[g2_order] = 1.f;
for(i=1;i<=g2_order;i++) g2[g2_order-i] = lpc[i-1]-lpc[m-i];
if(g1_order>g2_order){
for(i=2; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+2];
}else{

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: LSP (also called LSF) conversion routines
last mod: $Id: lsp.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -22,7 +22,7 @@
extern int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m);
extern void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,
float *lsp,int m,
float amp,float ampoffset);
float *lsp,int m,
float amp,float ampoffset);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: channel mapping 0 implementation
last mod: $Id: mapping0.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: mapping0.c 17022 2010-03-25 03:45:42Z xiphmont $
********************************************************************/
@ -56,7 +56,7 @@ static int ilog(unsigned int v){
}
static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,
oggpack_buffer *opb){
oggpack_buffer *opb){
int i;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
@ -76,14 +76,14 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,
if(info->coupling_steps>0){
oggpack_write(opb,1,1);
oggpack_write(opb,info->coupling_steps-1,8);
for(i=0;i<info->coupling_steps;i++){
oggpack_write(opb,info->coupling_mag[i],ilog(vi->channels));
oggpack_write(opb,info->coupling_ang[i],ilog(vi->channels));
}
}else
oggpack_write(opb,0,1);
oggpack_write(opb,0,2); /* 2,3:reserved */
/* we don't write the channel submappings if we only have one... */
@ -100,46 +100,51 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,
/* also responsible for range checking */
static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int i;
int i,b;
vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info));
codec_setup_info *ci=vi->codec_setup;
memset(info,0,sizeof(*info));
if(oggpack_read(opb,1))
b=oggpack_read(opb,1);
if(b<0)goto err_out;
if(b){
info->submaps=oggpack_read(opb,4)+1;
else
if(info->submaps<=0)goto err_out;
}else
info->submaps=1;
if(oggpack_read(opb,1)){
b=oggpack_read(opb,1);
if(b<0)goto err_out;
if(b){
info->coupling_steps=oggpack_read(opb,8)+1;
if(info->coupling_steps<=0)goto err_out;
for(i=0;i<info->coupling_steps;i++){
int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels));
int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
if(testM<0 ||
testA<0 ||
testM==testA ||
testM>=vi->channels ||
testA>=vi->channels) goto err_out;
if(testM<0 ||
testA<0 ||
testM==testA ||
testM>=vi->channels ||
testA>=vi->channels) goto err_out;
}
}
if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */
if(info->submaps>1){
for(i=0;i<vi->channels;i++){
info->chmuxlist[i]=oggpack_read(opb,4);
if(info->chmuxlist[i]>=info->submaps)goto err_out;
if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out;
}
}
for(i=0;i<info->submaps;i++){
oggpack_read(opb,8); /* time submap unused */
info->floorsubmap[i]=oggpack_read(opb,8);
if(info->floorsubmap[i]>=ci->floors)goto err_out;
if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out;
info->residuesubmap[i]=oggpack_read(opb,8);
if(info->residuesubmap[i]>=ci->residues)goto err_out;
if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0)goto err_out;
}
return info;
@ -161,83 +166,73 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
static long seq=0;
static ogg_int64_t total=0;
static float FLOOR1_fromdB_LOOKUP[256]={
1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
0.82788260F, 0.88168307F, 0.9389798F, 1.F,
1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
0.82788260F, 0.88168307F, 0.9389798F, 1.F,
};
#endif
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor *look,
const float *logmdct, /* in */
const float *logmask);
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor *look,
int *A,int *B,
int del);
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
vorbis_look_floor *look,
int *post,int *ilogmask);
#endif
static int mapping0_forward(vorbis_block *vb){
@ -251,17 +246,16 @@ static int mapping0_forward(vorbis_block *vb){
int *nonzero = alloca(sizeof(*nonzero)*vi->channels);
float **gmdct = _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct));
int **ilogmaskch= _vorbis_block_alloc(vb,vi->channels*sizeof(*ilogmaskch));
int **iwork = _vorbis_block_alloc(vb,vi->channels*sizeof(*iwork));
int ***floor_posts = _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts));
float global_ampmax=vbi->ampmax;
float *local_ampmax=alloca(sizeof(*local_ampmax)*vi->channels);
int blocktype=vbi->blocktype;
int modenumber=vb->W;
vorbis_info_mapping0 *info=ci->map_param[modenumber];
vorbis_look_psy *psy_look=
b->psy+blocktype+(vb->W?2:0);
vorbis_look_psy *psy_look=b->psy+blocktype+(vb->W?2:0);
vb->mode=modenumber;
@ -269,9 +263,10 @@ static int mapping0_forward(vorbis_block *vb){
float scale=4.f/n;
float scale_dB;
float *pcm =vb->pcm[i];
float *pcm =vb->pcm[i];
float *logfft =pcm;
iwork[i]=_vorbis_block_alloc(vb,n/2*sizeof(**iwork));
gmdct[i]=_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original
@ -290,28 +285,34 @@ static int mapping0_forward(vorbis_block *vb){
next major model upgrade. */
#if 0
if(vi->channels==2)
if(vi->channels==2){
if(i==0)
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
else
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("pcm",seq,pcm,n,0,0,total-n/2);
}
#endif
/* window the PCM data */
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
#if 0
if(vi->channels==2)
if(vi->channels==2){
if(i==0)
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
else
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("windowed",seq,pcm,n,0,0,total-n/2);
}
#endif
/* transform the PCM data */
/* only MDCT right now.... */
mdct_forward(b->transform[vb->W][0],pcm,gmdct[i]);
/* FFT yields more accurate tonal estimation (not phase sensitive) */
drft_forward(&b->fft_look[vb->W],pcm);
logfft[0]=scale_dB+todB(pcm) + .345; /* + .345 is a hack; the
@ -355,29 +356,31 @@ static int mapping0_forward(vorbis_block *vb){
#if 0
if(vi->channels==2){
if(i==0){
_analysis_output("fftL",seq,logfft,n/2,1,0,0);
_analysis_output("fftL",seq,logfft,n/2,1,0,0);
}else{
_analysis_output("fftR",seq,logfft,n/2,1,0,0);
_analysis_output("fftR",seq,logfft,n/2,1,0,0);
}
}else{
_analysis_output("fft",seq,logfft,n/2,1,0,0);
}
#endif
}
{
float *noise = _vorbis_block_alloc(vb,n/2*sizeof(*noise));
float *tone = _vorbis_block_alloc(vb,n/2*sizeof(*tone));
for(i=0;i<vi->channels;i++){
/* the encoder setup assumes that all the modes used by any
specific bitrate tweaking use the same floor */
specific bitrate tweaking use the same floor */
int submap=info->chmuxlist[i];
/* the following makes things clearer to *me* anyway */
float *mdct =gmdct[i];
float *logfft =vb->pcm[i];
float *logmdct =logfft+n/2;
float *logmask =logfft;
@ -385,9 +388,9 @@ static int mapping0_forward(vorbis_block *vb){
floor_posts[i]=_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts));
memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS);
for(j=0;j<n/2;j++)
logmdct[j]=todB(mdct+j) + .345; /* + .345 is a hack; the original
logmdct[j]=todB(mdct+j) + .345; /* + .345 is a hack; the original
todB estimation used on IEEE 754
compliant machines had a bug that
returned dB values about a third
@ -404,15 +407,15 @@ static int mapping0_forward(vorbis_block *vb){
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("mdctL",seq,logmdct,n/2,1,0,0);
else
_analysis_output("mdctR",seq,logmdct,n/2,1,0,0);
if(i==0)
_analysis_output("mdctL",seq,logmdct,n/2,1,0,0);
else
_analysis_output("mdctR",seq,logmdct,n/2,1,0,0);
}else{
_analysis_output("mdct",seq,logmdct,n/2,1,0,0);
_analysis_output("mdct",seq,logmdct,n/2,1,0,0);
}
#endif
#endif
/* first step; noise masking. Not only does 'noise masking'
give us curves from which we can decide how much resolution
to give noise parts of the spectrum, it also implicitly hands
@ -420,15 +423,17 @@ static int mapping0_forward(vorbis_block *vb){
'noise_depth' vector, the more tonal that area is) */
_vp_noisemask(psy_look,
logmdct,
noise); /* noise does not have by-frequency offset
logmdct,
noise); /* noise does not have by-frequency offset
bias applied yet */
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("noiseL",seq,noise,n/2,1,0,0);
else
_analysis_output("noiseR",seq,noise,n/2,1,0,0);
if(i==0)
_analysis_output("noiseL",seq,noise,n/2,1,0,0);
else
_analysis_output("noiseR",seq,noise,n/2,1,0,0);
}else{
_analysis_output("noise",seq,noise,n/2,1,0,0);
}
#endif
@ -437,55 +442,61 @@ static int mapping0_forward(vorbis_block *vb){
vector. This includes tone masking, peak limiting and ATH */
_vp_tonemask(psy_look,
logfft,
tone,
global_ampmax,
local_ampmax[i]);
logfft,
tone,
global_ampmax,
local_ampmax[i]);
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("toneL",seq,tone,n/2,1,0,0);
else
_analysis_output("toneR",seq,tone,n/2,1,0,0);
if(i==0)
_analysis_output("toneL",seq,tone,n/2,1,0,0);
else
_analysis_output("toneR",seq,tone,n/2,1,0,0);
}else{
_analysis_output("tone",seq,tone,n/2,1,0,0);
}
#endif
/* third step; we offset the noise vectors, overlay tone
masking. We then do a floor1-specific line fit. If we're
performing bitrate management, the line fit is performed
multiple times for up/down tweakage on demand. */
masking. We then do a floor1-specific line fit. If we're
performing bitrate management, the line fit is performed
multiple times for up/down tweakage on demand. */
#if 0
{
float aotuv[psy_look->n];
#endif
_vp_offset_and_mix(psy_look,
noise,
tone,
1,
logmask,
mdct,
logmdct);
_vp_offset_and_mix(psy_look,
noise,
tone,
1,
logmask,
mdct,
logmdct);
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
else
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
}
if(vi->channels==2){
if(i==0)
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
else
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
}else{
_analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0);
}
}
#endif
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("mask1L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask1R",seq,logmask,n/2,1,0,0);
if(i==0)
_analysis_output("mask1L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask1R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask1",seq,logmask,n/2,1,0,0);
}
#endif
@ -495,73 +506,78 @@ static int mapping0_forward(vorbis_block *vb){
if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1);
floor_posts[i][PACKETBLOBS/2]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
/* are we managing bitrate? If so, perform two more fits for
later rate tweaking (fits represent hi/lo) */
if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){
/* higher rate by way of lower noise curve */
/* higher rate by way of lower noise curve */
_vp_offset_and_mix(psy_look,
noise,
tone,
2,
logmask,
mdct,
logmdct);
_vp_offset_and_mix(psy_look,
noise,
tone,
2,
logmask,
mdct,
logmdct);
#if 0
if(vi->channels==2){
if(i==0)
_analysis_output("mask2L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask2R",seq,logmask,n/2,1,0,0);
}
if(vi->channels==2){
if(i==0)
_analysis_output("mask2L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask2R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask2",seq,logmask,n/2,1,0,0);
}
#endif
floor_posts[i][PACKETBLOBS-1]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
/* lower rate by way of higher noise curve */
_vp_offset_and_mix(psy_look,
noise,
tone,
0,
logmask,
mdct,
logmdct);
floor_posts[i][PACKETBLOBS-1]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
/* lower rate by way of higher noise curve */
_vp_offset_and_mix(psy_look,
noise,
tone,
0,
logmask,
mdct,
logmdct);
#if 0
if(vi->channels==2)
if(i==0)
_analysis_output("mask0L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask0R",seq,logmask,n/2,1,0,0);
if(vi->channels==2){
if(i==0)
_analysis_output("mask0L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask0R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask0",seq,logmask,n/2,1,0,0);
}
#endif
floor_posts[i][0]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
/* we also interpolate a range of intermediate curves for
floor_posts[i][0]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
logmdct,
logmask);
/* we also interpolate a range of intermediate curves for
intermediate rates */
for(k=1;k<PACKETBLOBS/2;k++)
floor_posts[i][k]=
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][0],
floor_posts[i][PACKETBLOBS/2],
k*65536/(PACKETBLOBS/2));
for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
floor_posts[i][k]=
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][PACKETBLOBS/2],
floor_posts[i][PACKETBLOBS-1],
(k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
for(k=1;k<PACKETBLOBS/2;k++)
floor_posts[i][k]=
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][0],
floor_posts[i][PACKETBLOBS/2],
k*65536/(PACKETBLOBS/2));
for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
floor_posts[i][k]=
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][PACKETBLOBS/2],
floor_posts[i][PACKETBLOBS-1],
(k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
}
}
}
@ -570,55 +586,24 @@ static int mapping0_forward(vorbis_block *vb){
/*
the next phases are performed once for vbr-only and PACKETBLOB
times for bitrate managed modes.
1) encode actual mode being used
2) encode the floor for each channel, compute coded mask curve/res
3) normalize and couple.
4) encode residue
5) save packet bytes to the packetblob vector
*/
/* iterate over the many masking curve fits we've created */
{
float **res_bundle=alloca(sizeof(*res_bundle)*vi->channels);
float **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
int **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
int **sortindex=alloca(sizeof(*sortindex)*vi->channels);
float **mag_memo;
int **mag_sort;
if(info->coupling_steps){
mag_memo=_vp_quantize_couple_memo(vb,
&ci->psy_g_param,
psy_look,
info,
gmdct);
mag_sort=_vp_quantize_couple_sort(vb,
psy_look,
info,
mag_memo);
hf_reduction(&ci->psy_g_param,
psy_look,
info,
mag_memo);
}
memset(sortindex,0,sizeof(*sortindex)*vi->channels);
if(psy_look->vi->normal_channel_p){
for(i=0;i<vi->channels;i++){
float *mdct =gmdct[i];
sortindex[i]=alloca(sizeof(**sortindex)*n/2);
_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
}
}
for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
k++){
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
k++){
oggpack_buffer *opb=vbi->packetblob[k];
/* start out our new packet blob with packet type and mode */
@ -628,98 +613,87 @@ static int mapping0_forward(vorbis_block *vb){
/* Encode frame mode, pre,post windowsize, then dispatch */
oggpack_write(opb,modenumber,b->modebits);
if(vb->W){
oggpack_write(opb,vb->lW,1);
oggpack_write(opb,vb->nW,1);
oggpack_write(opb,vb->lW,1);
oggpack_write(opb,vb->nW,1);
}
/* encode floor, compute masking curve, sep out residue */
for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i];
float *mdct =gmdct[i];
float *res =vb->pcm[i];
int *ilogmask=ilogmaskch[i]=
_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][k],
ilogmask);
int submap=info->chmuxlist[i];
int *ilogmask=iwork[i];
nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][k],
ilogmask);
#if 0
{
char buf[80];
sprintf(buf,"maskI%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]];
_analysis_output(buf,seq,work,n/2,1,1,0);
}
#endif
_vp_remove_floor(psy_look,
mdct,
ilogmask,
res,
ci->psy_g_param.sliding_lowpass[vb->W][k]);
_vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]);
#if 0
{
char buf[80];
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]*(res+n/2)[j];
sprintf(buf,"resI%c%d",i?'R':'L',k);
_analysis_output(buf,seq,work,n/2,1,1,0);
}
{
char buf[80];
sprintf(buf,"maskI%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[iwork[i][j]];
_analysis_output(buf,seq,work,n/2,1,1,0);
}
#endif
}
/* our iteration is now based on masking curve, not prequant and
coupling. Only one prequant/coupling step */
coupling. Only one prequant/coupling step */
/* quantize/couple */
/* incomplete implementation that assumes the tree is all depth
one, or no tree at all */
if(info->coupling_steps){
_vp_couple(k,
&ci->psy_g_param,
psy_look,
info,
vb->pcm,
mag_memo,
mag_sort,
ilogmaskch,
nonzero,
ci->psy_g_param.sliding_lowpass[vb->W][k]);
_vp_couple_quantize_normalize(k,
&ci->psy_g_param,
psy_look,
info,
gmdct,
iwork,
nonzero,
ci->psy_g_param.sliding_lowpass[vb->W][k],
vi->channels);
#if 0
for(i=0;i<vi->channels;i++){
char buf[80];
sprintf(buf,"res%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=iwork[i][j];
_analysis_output(buf,seq,work,n/2,1,0,0);
}
#endif
/* classify and encode by submap */
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
long **classifications;
int resnum=info->residuesubmap[i];
int ch_in_bundle=0;
long **classifications;
int resnum=info->residuesubmap[i];
for(j=0;j<vi->channels;j++){
if(info->chmuxlist[j]==i){
zerobundle[ch_in_bundle]=0;
if(nonzero[j])zerobundle[ch_in_bundle]=1;
res_bundle[ch_in_bundle]=vb->pcm[j];
couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2;
}
}
classifications=_residue_P[ci->residue_type[resnum]]->
class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
_residue_P[ci->residue_type[resnum]]->
forward(opb,vb,b->residue[resnum],
couple_bundle,NULL,zerobundle,ch_in_bundle,classifications);
for(j=0;j<vi->channels;j++){
if(info->chmuxlist[j]==i){
zerobundle[ch_in_bundle]=0;
if(nonzero[j])zerobundle[ch_in_bundle]=1;
couple_bundle[ch_in_bundle++]=iwork[j];
}
}
classifications=_residue_P[ci->residue_type[resnum]]->
class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
ch_in_bundle=0;
for(j=0;j<vi->channels;j++)
if(info->chmuxlist[j]==i)
couple_bundle[ch_in_bundle++]=iwork[j];
_residue_P[ci->residue_type[resnum]]->
forward(opb,vb,b->residue[resnum],
couple_bundle,zerobundle,ch_in_bundle,classifications,i);
}
/* ok, done encoding. Next protopacket. */
}
}
#if 0
@ -735,7 +709,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
codec_setup_info *ci=vi->codec_setup;
private_state *b=vd->backend_state;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l;
int hs=ci->halfrate_flag;
int i,j;
long n=vb->pcmend=ci->blocksizes[vb->W];
@ -745,7 +718,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
int *nonzero =alloca(sizeof(*nonzero)*vi->channels);
void **floormemo=alloca(sizeof(*floormemo)*vi->channels);
/* recover the spectral envelope; store it in the PCM vector for now */
for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i];
@ -754,7 +727,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
if(floormemo[i])
nonzero[i]=1;
else
nonzero[i]=0;
nonzero[i]=0;
memset(vb->pcm[i],0,sizeof(*vb->pcm[i])*n/2);
}
@ -762,8 +735,8 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
for(i=0;i<info->coupling_steps;i++){
if(nonzero[info->coupling_mag[i]] ||
nonzero[info->coupling_ang[i]]){
nonzero[info->coupling_mag[i]]=1;
nonzero[info->coupling_ang[i]]=1;
nonzero[info->coupling_mag[i]]=1;
nonzero[info->coupling_ang[i]]=1;
}
}
@ -772,17 +745,17 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
int ch_in_bundle=0;
for(j=0;j<vi->channels;j++){
if(info->chmuxlist[j]==i){
if(nonzero[j])
zerobundle[ch_in_bundle]=1;
else
zerobundle[ch_in_bundle]=0;
pcmbundle[ch_in_bundle++]=vb->pcm[j];
if(nonzero[j])
zerobundle[ch_in_bundle]=1;
else
zerobundle[ch_in_bundle]=0;
pcmbundle[ch_in_bundle++]=vb->pcm[j];
}
}
_residue_P[ci->residue_type[info->residuesubmap[i]]]->
inverse(vb,b->residue[info->residuesubmap[i]],
pcmbundle,zerobundle,ch_in_bundle);
pcmbundle,zerobundle,ch_in_bundle);
}
/* channel coupling */
@ -795,21 +768,21 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
float ang=pcmA[j];
if(mag>0)
if(ang>0){
pcmM[j]=mag;
pcmA[j]=mag-ang;
}else{
pcmA[j]=mag;
pcmM[j]=mag+ang;
}
if(ang>0){
pcmM[j]=mag;
pcmA[j]=mag-ang;
}else{
pcmA[j]=mag;
pcmM[j]=mag+ang;
}
else
if(ang>0){
pcmM[j]=mag;
pcmA[j]=mag+ang;
}else{
pcmA[j]=mag;
pcmM[j]=mag-ang;
}
if(ang>0){
pcmM[j]=mag;
pcmA[j]=mag+ang;
}else{
pcmA[j]=mag;
pcmM[j]=mag-ang;
}
}
}
@ -819,7 +792,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
int submap=info->chmuxlist[i];
_floor_P[ci->floor_type[info->floorsubmap[submap]]]->
inverse2(vb,b->flr[info->floorsubmap[submap]],
floormemo[i],pcm);
floormemo[i],pcm);
}
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
@ -834,11 +807,10 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
}
/* export hooks */
vorbis_func_mapping mapping0_exportbundle={
const vorbis_func_mapping mapping0_exportbundle={
&mapping0_pack,
&mapping0_unpack,
&mapping0_free_info,
&mapping0_forward,
&mapping0_inverse
};

File diff suppressed because it is too large Load diff

View file

@ -5,14 +5,14 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
last mod: $Id: mdct.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: mdct.c 16227 2009-07-08 06:58:46Z xiphmont $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
@ -52,7 +52,7 @@
void mdct_init(mdct_lookup *lookup,int n){
int *bitrev=_ogg_malloc(sizeof(*bitrev)*(n/4));
DATA_TYPE *T=_ogg_malloc(sizeof(*T)*(n+n/4));
int i;
int n2=n>>1;
int log2n=lookup->log2n=rint(log((float)n)/log(2.f));
@ -81,7 +81,7 @@ void mdct_init(mdct_lookup *lookup,int n){
for(i=0;i<n/8;i++){
int acc=0;
for(j=0;msb>>j;j++)
if((msb>>j)&i)acc|=1<<j;
if((msb>>j)&i)acc|=1<<j;
bitrev[i*2]=((~acc)&mask)-1;
bitrev[i*2+1]=acc;
@ -97,21 +97,21 @@ STIN void mdct_butterfly_8(DATA_TYPE *x){
REG_TYPE r2 = x[4] + x[0];
REG_TYPE r3 = x[4] - x[0];
x[6] = r0 + r2;
x[4] = r0 - r2;
r0 = x[5] - x[1];
r2 = x[7] - x[3];
x[0] = r1 + r0;
x[2] = r1 - r0;
r0 = x[5] + x[1];
r1 = x[7] + x[3];
x[3] = r2 + r3;
x[1] = r2 - r3;
x[7] = r1 + r0;
x[5] = r1 - r0;
x[6] = r0 + r2;
x[4] = r0 - r2;
r0 = x[5] - x[1];
r2 = x[7] - x[3];
x[0] = r1 + r0;
x[2] = r1 - r0;
r0 = x[5] + x[1];
r1 = x[7] + x[3];
x[3] = r2 + r3;
x[1] = r2 - r3;
x[7] = r1 + r0;
x[5] = r1 - r0;
}
/* 16 point butterfly (in place, 4 register) */
@ -145,8 +145,8 @@ STIN void mdct_butterfly_16(DATA_TYPE *x){
x[6] = r0;
x[7] = r1;
mdct_butterfly_8(x);
mdct_butterfly_8(x+8);
mdct_butterfly_8(x);
mdct_butterfly_8(x+8);
}
/* 32 point butterfly (in place, 4 register) */
@ -154,105 +154,105 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){
REG_TYPE r0 = x[30] - x[14];
REG_TYPE r1 = x[31] - x[15];
x[30] += x[14];
x[31] += x[15];
x[14] = r0;
x[15] = r1;
x[30] += x[14];
x[31] += x[15];
x[14] = r0;
x[15] = r1;
r0 = x[28] - x[12];
r1 = x[29] - x[13];
x[28] += x[12];
x[29] += x[13];
r0 = x[28] - x[12];
r1 = x[29] - x[13];
x[28] += x[12];
x[29] += x[13];
x[12] = MULT_NORM( r0 * cPI1_8 - r1 * cPI3_8 );
x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 );
x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 );
r0 = x[26] - x[10];
r1 = x[27] - x[11];
x[26] += x[10];
x[27] += x[11];
x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8);
x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8);
r1 = x[27] - x[11];
x[26] += x[10];
x[27] += x[11];
x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8);
x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8);
r0 = x[24] - x[8];
r1 = x[25] - x[9];
x[24] += x[8];
x[25] += x[9];
x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 );
x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
r0 = x[24] - x[8];
r1 = x[25] - x[9];
x[24] += x[8];
x[25] += x[9];
x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 );
x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
r0 = x[22] - x[6];
r1 = x[7] - x[23];
x[22] += x[6];
x[23] += x[7];
x[6] = r1;
x[7] = r0;
r0 = x[22] - x[6];
r1 = x[7] - x[23];
x[22] += x[6];
x[23] += x[7];
x[6] = r1;
x[7] = r0;
r0 = x[4] - x[20];
r1 = x[5] - x[21];
x[20] += x[4];
x[21] += x[5];
x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 );
x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 );
r0 = x[4] - x[20];
r1 = x[5] - x[21];
x[20] += x[4];
x[21] += x[5];
x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 );
x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 );
r0 = x[2] - x[18];
r1 = x[3] - x[19];
x[18] += x[2];
x[19] += x[3];
x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8);
x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8);
r0 = x[2] - x[18];
r1 = x[3] - x[19];
x[18] += x[2];
x[19] += x[3];
x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8);
x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8);
r0 = x[0] - x[16];
r1 = x[1] - x[17];
x[16] += x[0];
x[17] += x[1];
x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 );
r0 = x[0] - x[16];
r1 = x[1] - x[17];
x[16] += x[0];
x[17] += x[1];
x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 );
x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 );
mdct_butterfly_16(x);
mdct_butterfly_16(x+16);
mdct_butterfly_16(x);
mdct_butterfly_16(x+16);
}
/* N point first stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_first(DATA_TYPE *T,
DATA_TYPE *x,
int points){
DATA_TYPE *x,
int points){
DATA_TYPE *x1 = x + points - 8;
DATA_TYPE *x2 = x + (points>>1) - 8;
REG_TYPE r0;
REG_TYPE r1;
do{
r0 = x1[6] - x2[6];
r1 = x1[7] - x2[7];
x1[6] += x2[6];
x1[7] += x2[7];
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
r0 = x1[4] - x2[4];
r1 = x1[5] - x2[5];
x1[4] += x2[4];
x1[5] += x2[5];
x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]);
x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]);
r0 = x1[2] - x2[2];
r1 = x1[3] - x2[3];
x1[2] += x2[2];
x1[3] += x2[3];
x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]);
x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]);
r0 = x1[0] - x2[0];
r1 = x1[1] - x2[1];
x1[0] += x2[0];
x1[1] += x2[1];
x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]);
x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]);
r1 = x1[7] - x2[7];
x1[6] += x2[6];
x1[7] += x2[7];
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
r0 = x1[4] - x2[4];
r1 = x1[5] - x2[5];
x1[4] += x2[4];
x1[5] += x2[5];
x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]);
x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]);
r0 = x1[2] - x2[2];
r1 = x1[3] - x2[3];
x1[2] += x2[2];
x1[3] += x2[3];
x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]);
x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]);
r0 = x1[0] - x2[0];
r1 = x1[1] - x2[1];
x1[0] += x2[0];
x1[1] += x2[1];
x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]);
x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]);
x1-=8;
x2-=8;
T+=16;
@ -262,52 +262,52 @@ STIN void mdct_butterfly_first(DATA_TYPE *T,
/* N/stage point generic N stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_generic(DATA_TYPE *T,
DATA_TYPE *x,
int points,
int trigint){
DATA_TYPE *x,
int points,
int trigint){
DATA_TYPE *x1 = x + points - 8;
DATA_TYPE *x2 = x + (points>>1) - 8;
REG_TYPE r0;
REG_TYPE r1;
do{
r0 = x1[6] - x2[6];
r1 = x1[7] - x2[7];
x1[6] += x2[6];
x1[7] += x2[7];
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[4] - x2[4];
r1 = x1[5] - x2[5];
x1[4] += x2[4];
x1[5] += x2[5];
x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[2] - x2[2];
r1 = x1[3] - x2[3];
x1[2] += x2[2];
x1[3] += x2[3];
x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[0] - x2[0];
r1 = x1[1] - x2[1];
x1[0] += x2[0];
x1[1] += x2[1];
x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[6] - x2[6];
r1 = x1[7] - x2[7];
x1[6] += x2[6];
x1[7] += x2[7];
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[4] - x2[4];
r1 = x1[5] - x2[5];
x1[4] += x2[4];
x1[5] += x2[5];
x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[2] - x2[2];
r1 = x1[3] - x2[3];
x1[2] += x2[2];
x1[3] += x2[3];
x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
r0 = x1[0] - x2[0];
r1 = x1[1] - x2[1];
x1[0] += x2[0];
x1[1] += x2[1];
x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]);
x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]);
T+=trigint;
x1-=8;
x2-=8;
@ -315,13 +315,13 @@ STIN void mdct_butterfly_generic(DATA_TYPE *T,
}
STIN void mdct_butterflies(mdct_lookup *init,
DATA_TYPE *x,
int points){
DATA_TYPE *x,
int points){
DATA_TYPE *T=init->trig;
int stages=init->log2n-5;
int i,j;
if(--stages>0){
mdct_butterfly_first(T,x,points);
}
@ -344,8 +344,8 @@ void mdct_clear(mdct_lookup *l){
}
}
STIN void mdct_bitreverse(mdct_lookup *init,
DATA_TYPE *x){
STIN void mdct_bitreverse(mdct_lookup *init,
DATA_TYPE *x){
int n = init->n;
int *bit = init->bitrev;
DATA_TYPE *w0 = x;
@ -361,15 +361,15 @@ STIN void mdct_bitreverse(mdct_lookup *init,
REG_TYPE r2 = MULT_NORM(r1 * T[0] + r0 * T[1]);
REG_TYPE r3 = MULT_NORM(r1 * T[1] - r0 * T[0]);
w1 -= 4;
w1 -= 4;
r0 = HALVE(x0[1] + x1[1]);
r1 = HALVE(x0[0] - x1[0]);
w0[0] = r0 + r2;
w1[2] = r0 - r2;
w0[1] = r1 + r3;
w1[3] = r3 - r1;
w0[0] = r0 + r2;
w1[2] = r0 - r2;
w0[1] = r1 + r3;
w1[3] = r3 - r1;
x0 = x+bit[2];
x1 = x+bit[3];
@ -381,15 +381,15 @@ STIN void mdct_bitreverse(mdct_lookup *init,
r0 = HALVE(x0[1] + x1[1]);
r1 = HALVE(x0[0] - x1[0]);
w0[2] = r0 + r2;
w1[0] = r0 - r2;
w0[3] = r1 + r3;
w1[1] = r3 - r1;
T += 4;
bit += 4;
w0 += 4;
w0[2] = r0 + r2;
w1[0] = r0 - r2;
w0[3] = r1 + r3;
w1[1] = r3 - r1;
T += 4;
bit += 4;
w0 += 4;
}while(w0<w1);
}
@ -439,7 +439,7 @@ void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
DATA_TYPE *oX2=out+n2+n4;
DATA_TYPE *iX =out;
T =init->trig+n2;
do{
oX1-=4;
@ -501,44 +501,44 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
/* rotate */
/* window + rotate + step 1 */
REG_TYPE r0;
REG_TYPE r1;
DATA_TYPE *x0=in+n2+n4;
DATA_TYPE *x1=x0+1;
DATA_TYPE *T=init->trig+n2;
int i=0;
for(i=0;i<n8;i+=2){
x0 -=4;
T-=2;
r0= x0[2] + x1[0];
r1= x0[0] + x1[2];
r1= x0[0] + x1[2];
w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
x1 +=4;
}
x1=in+1;
for(;i<n2-n8;i+=2){
T-=2;
x0 -=4;
r0= x0[2] - x1[0];
r1= x0[0] - x1[2];
r1= x0[0] - x1[2];
w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
x1 +=4;
}
x0=in+n;
for(;i<n2;i+=2){
T-=2;
x0 -=4;
r0= -x0[2] - x1[0];
r1= -x0[0] - x1[2];
r1= -x0[0] - x1[2];
w2[i]= MULT_NORM(r1*T[1] + r0*T[0]);
w2[i+1]= MULT_NORM(r1*T[0] - r0*T[1]);
x1 +=4;
@ -561,4 +561,3 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
T+=2;
}
}

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: modified discrete cosine transform prototypes
last mod: $Id: mdct.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -56,7 +56,7 @@
typedef struct {
int n;
int log2n;
DATA_TYPE *trig;
int *bitrev;
@ -69,15 +69,3 @@ extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: miscellaneous prototypes
last mod: $Id: misc.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: misc.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -19,20 +19,25 @@
#define _V_RANDOM_H_
#include "vorbis/codec.h"
extern int analysis_noisy;
extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
extern void _vorbis_block_ripcord(vorbis_block *vb);
#ifdef ANALYSIS
extern int analysis_noisy;
extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
ogg_int64_t off);
ogg_int64_t off);
extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,
ogg_int64_t off);
#endif
#ifdef DEBUG_MALLOC
#define _VDBG_GRAPHFILE "malloc.m"
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
extern void _VDBG_free(void *ptr,char *file,long line);
#undef _VDBG_GRAPHFILE
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
extern void _VDBG_free(void *ptr,char *file,long line);
#ifndef MISC_C
#ifndef MISC_C
#undef _ogg_malloc
#undef _ogg_calloc
#undef _ogg_realloc

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: key floor settings
last mod: $Id: floor_all.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: floor_all.h 17050 2010-03-26 01:34:42Z xiphmont $
********************************************************************/
@ -19,85 +19,85 @@
#include "backends.h"
#include "books/floor/floor_books.h"
static static_codebook *_floor_128x4_books[]={
static const static_codebook*const _floor_128x4_books[]={
&_huff_book_line_128x4_class0,
&_huff_book_line_128x4_0sub0,
&_huff_book_line_128x4_0sub1,
&_huff_book_line_128x4_0sub2,
&_huff_book_line_128x4_0sub3,
};
static static_codebook *_floor_256x4_books[]={
static const static_codebook*const _floor_256x4_books[]={
&_huff_book_line_256x4_class0,
&_huff_book_line_256x4_0sub0,
&_huff_book_line_256x4_0sub1,
&_huff_book_line_256x4_0sub2,
&_huff_book_line_256x4_0sub3,
};
static static_codebook *_floor_128x7_books[]={
static const static_codebook*const _floor_128x7_books[]={
&_huff_book_line_128x7_class0,
&_huff_book_line_128x7_class1,
&_huff_book_line_128x7_0sub1,
&_huff_book_line_128x7_0sub2,
&_huff_book_line_128x7_0sub3,
&_huff_book_line_128x7_1sub1,
&_huff_book_line_128x7_1sub2,
&_huff_book_line_128x7_1sub3,
&_huff_book_line_128x7_1sub3,
};
static static_codebook *_floor_256x7_books[]={
static const static_codebook*const _floor_256x7_books[]={
&_huff_book_line_256x7_class0,
&_huff_book_line_256x7_class1,
&_huff_book_line_256x7_0sub1,
&_huff_book_line_256x7_0sub2,
&_huff_book_line_256x7_0sub3,
&_huff_book_line_256x7_1sub1,
&_huff_book_line_256x7_1sub2,
&_huff_book_line_256x7_1sub3,
&_huff_book_line_256x7_1sub3,
};
static static_codebook *_floor_128x11_books[]={
static const static_codebook*const _floor_128x11_books[]={
&_huff_book_line_128x11_class1,
&_huff_book_line_128x11_class2,
&_huff_book_line_128x11_class3,
&_huff_book_line_128x11_0sub0,
&_huff_book_line_128x11_1sub0,
&_huff_book_line_128x11_1sub1,
&_huff_book_line_128x11_2sub1,
&_huff_book_line_128x11_2sub2,
&_huff_book_line_128x11_2sub3,
&_huff_book_line_128x11_2sub3,
&_huff_book_line_128x11_3sub1,
&_huff_book_line_128x11_3sub2,
&_huff_book_line_128x11_3sub3,
&_huff_book_line_128x11_3sub3,
};
static static_codebook *_floor_128x17_books[]={
static const static_codebook*const _floor_128x17_books[]={
&_huff_book_line_128x17_class1,
&_huff_book_line_128x17_class2,
&_huff_book_line_128x17_class3,
&_huff_book_line_128x17_0sub0,
&_huff_book_line_128x17_1sub0,
&_huff_book_line_128x17_1sub1,
&_huff_book_line_128x17_2sub1,
&_huff_book_line_128x17_2sub2,
&_huff_book_line_128x17_2sub3,
&_huff_book_line_128x17_2sub3,
&_huff_book_line_128x17_3sub1,
&_huff_book_line_128x17_3sub2,
&_huff_book_line_128x17_3sub3,
&_huff_book_line_128x17_3sub3,
};
static static_codebook *_floor_256x4low_books[]={
static const static_codebook*const _floor_256x4low_books[]={
&_huff_book_line_256x4low_class0,
&_huff_book_line_256x4low_0sub0,
&_huff_book_line_256x4low_0sub1,
&_huff_book_line_256x4low_0sub2,
&_huff_book_line_256x4low_0sub3,
};
static static_codebook *_floor_1024x27_books[]={
static const static_codebook*const _floor_1024x27_books[]={
&_huff_book_line_1024x27_class1,
&_huff_book_line_1024x27_class2,
&_huff_book_line_1024x27_class3,
&_huff_book_line_1024x27_class4,
&_huff_book_line_1024x27_0sub0,
&_huff_book_line_1024x27_1sub0,
&_huff_book_line_1024x27_1sub1,
@ -110,12 +110,12 @@ static static_codebook *_floor_1024x27_books[]={
&_huff_book_line_1024x27_4sub2,
&_huff_book_line_1024x27_4sub3,
};
static static_codebook *_floor_2048x27_books[]={
static const static_codebook*const _floor_2048x27_books[]={
&_huff_book_line_2048x27_class1,
&_huff_book_line_2048x27_class2,
&_huff_book_line_2048x27_class3,
&_huff_book_line_2048x27_class4,
&_huff_book_line_2048x27_0sub0,
&_huff_book_line_2048x27_1sub0,
&_huff_book_line_2048x27_1sub1,
@ -129,23 +129,27 @@ static static_codebook *_floor_2048x27_books[]={
&_huff_book_line_2048x27_4sub3,
};
static static_codebook *_floor_512x17_books[]={
static const static_codebook*const _floor_512x17_books[]={
&_huff_book_line_512x17_class1,
&_huff_book_line_512x17_class2,
&_huff_book_line_512x17_class3,
&_huff_book_line_512x17_0sub0,
&_huff_book_line_512x17_1sub0,
&_huff_book_line_512x17_1sub1,
&_huff_book_line_512x17_2sub1,
&_huff_book_line_512x17_2sub2,
&_huff_book_line_512x17_2sub3,
&_huff_book_line_512x17_2sub3,
&_huff_book_line_512x17_3sub1,
&_huff_book_line_512x17_3sub2,
&_huff_book_line_512x17_3sub3,
&_huff_book_line_512x17_3sub3,
};
static static_codebook **_floor_books[10]={
static const static_codebook*const _floor_Xx0_books[]={
0
};
static const static_codebook*const *const _floor_books[11]={
_floor_128x4_books,
_floor_256x4_books,
_floor_128x7_books,
@ -156,93 +160,101 @@ static static_codebook **_floor_books[10]={
_floor_1024x27_books,
_floor_2048x27_books,
_floor_512x17_books,
_floor_Xx0_books,
};
static vorbis_info_floor1 _floor[10]={
/* 128 x 4 */
static const vorbis_info_floor1 _floor[11]={
/* 0: 128 x 4 */
{
1,{0},{4},{2},{0},
{{1,2,3,4}},
4,{0,128, 33,8,16,70},
60,30,500, 1.,18., -1
60,30,500, 1.,18., 128
},
/* 256 x 4 */
/* 1: 256 x 4 */
{
1,{0},{4},{2},{0},
{{1,2,3,4}},
4,{0,256, 66,16,32,140},
60,30,500, 1.,18., -1
60,30,500, 1.,18., 256
},
/* 128 x 7 */
/* 2: 128 x 7 */
{
2,{0,1},{3,4},{2,2},{0,1},
{{-1,2,3,4},{-1,5,6,7}},
4,{0,128, 14,4,58, 2,8,28,90},
60,30,500, 1.,18., -1
60,30,500, 1.,18., 128
},
/* 256 x 7 */
/* 3: 256 x 7 */
{
2,{0,1},{3,4},{2,2},{0,1},
{{-1,2,3,4},{-1,5,6,7}},
4,{0,256, 28,8,116, 4,16,56,180},
60,30,500, 1.,18., -1
60,30,500, 1.,18., 256
},
/* 128 x 11 */
/* 4: 128 x 11 */
{
4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90},
60,30,500, 1,18., -1
60,30,500, 1,18., 128
},
/* 128 x 17 */
/* 5: 128 x 17 */
{
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90},
60,30,500, 1,18., -1
60,30,500, 1,18., 128
},
/* 256 x 4 (low bitrate version) */
/* 6: 256 x 4 (low bitrate version) */
{
1,{0},{4},{2},{0},
{{1,2,3,4}},
4,{0,256, 66,16,32,140},
60,30,500, 1.,18., -1
60,30,500, 1.,18., 256
},
/* 1024 x 27 */
/* 7: 1024 x 27 */
{
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3},
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}},
2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556,
3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850},
60,30,500, 3,18., -1 /* lowpass */
60,30,500, 3,18., 1024
},
/* 2048 x 27 */
/* 8: 2048 x 27 */
{
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3},
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}},
2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112,
6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700},
60,30,500, 3,18., -1 /* lowpass */
60,30,500, 3,18., 2048
},
/* 512 x 17 */
/* 9: 512 x 17 */
{
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,512, 46,186, 16,33,65, 93,130,278,
2,{0,512, 46,186, 16,33,65, 93,130,278,
7,23,39, 55,79,110, 156,232,360},
60,30,500, 1,18., -1 /* lowpass! */
60,30,500, 1,18., 512
},
/* 10: X x 0 (LFE floor; edge posts only) */
{
0,{0}, {0},{0},{-1},
{{-1}},
2,{0,12},
60,30,500, 1.,18., 10
},
};

View file

@ -5,25 +5,25 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 11kHz settings
last mod: $Id: psych_11.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 11kHz settings
last mod: $Id: psych_11.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
static double _psy_lowpass_11[3]={4.5,5.5,30.,};
static const double _psy_lowpass_11[3]={4.5,5.5,30.,};
static att3 _psy_tone_masteratt_11[3]={
static const att3 _psy_tone_masteratt_11[3]={
{{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 20, 0, -14}, 0, 0}, /* 0 */
};
static vp_adjblock _vp_tonemask_adj_11[3]={
static const vp_adjblock _vp_tonemask_adj_11[3]={
/* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */
@ -32,7 +32,7 @@ static vp_adjblock _vp_tonemask_adj_11[3]={
};
static noise3 _psy_noisebias_11[3]={
static const noise3 _psy_noisebias_11[3]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99},
{-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99},
@ -47,5 +47,5 @@ static noise3 _psy_noisebias_11[3]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}},
};
static double _noise_thresh_11[3]={ .3,.5,.5 };
static const double _noise_thresh_11[3]={ .3,.5,.5 };

View file

@ -5,18 +5,18 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 16kHz settings
last mod: $Id: psych_16.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 16kHz settings
last mod: $Id: psych_16.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
/* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_16[4]={
static const adj_stereo _psy_stereo_modes_16[4]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
@ -36,16 +36,16 @@ static adj_stereo _psy_stereo_modes_16[4]={
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
};
static double _psy_lowpass_16[4]={6.5,8,30.,99.};
static const double _psy_lowpass_16[4]={6.5,8,30.,99.};
static att3 _psy_tone_masteratt_16[4]={
static const att3 _psy_tone_masteratt_16[4]={
{{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 25, 22, 12}, 0, 0}, /* 0 */
{{ 20, 12, 0}, 0, 0}, /* 0 */
{{ 15, 0, -14}, 0, 0}, /* 0 */
};
static vp_adjblock _vp_tonemask_adj_16[4]={
static const vp_adjblock _vp_tonemask_adj_16[4]={
/* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */
@ -55,7 +55,7 @@ static vp_adjblock _vp_tonemask_adj_16[4]={
};
static noise3 _psy_noisebias_16_short[4]={
static const noise3 _psy_noisebias_16_short[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20},
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15},
@ -74,7 +74,7 @@ static noise3 _psy_noisebias_16_short[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
};
static noise3 _psy_noisebias_16_impulse[4]={
static const noise3 _psy_noisebias_16_impulse[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20},
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15},
@ -93,7 +93,7 @@ static noise3 _psy_noisebias_16_impulse[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
};
static noise3 _psy_noisebias_16[4]={
static const noise3 _psy_noisebias_16[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20},
{-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15},
@ -112,25 +112,22 @@ static noise3 _psy_noisebias_16[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
};
static noiseguard _psy_noiseguards_16[4]={
static const noiseguard _psy_noiseguards_16[4]={
{10,10,-1},
{10,10,-1},
{20,20,-1},
{20,20,-1},
};
static double _noise_thresh_16[4]={ .3,.5,.5,.5 };
static const double _noise_thresh_16[4]={ .3,.5,.5,.5 };
static int _noise_start_16[3]={ 256,256,9999 };
static int _noise_part_16[4]={ 8,8,8,8 };
static const int _noise_start_16[3]={ 256,256,9999 };
static const int _noise_part_16[4]={ 8,8,8,8 };
static int _psy_ath_floater_16[4]={
static const int _psy_ath_floater_16[4]={
-100,-100,-100,-105,
};
static int _psy_ath_abs_16[4]={
static const int _psy_ath_abs_16[4]={
-130,-130,-130,-140,
};

View file

@ -5,47 +5,47 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: key psychoacoustic settings for 44.1/48kHz
last mod: $Id: psych_44.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: psych_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
/* preecho trigger settings *****************************************/
static vorbis_info_psy_global _psy_global_44[5]={
static const vorbis_info_psy_global _psy_global_44[5]={
{8, /* lines per eighth octave */
{20.f,14.f,12.f,12.f,12.f,12.f,12.f},
{20.f,14.f,12.f,12.f,12.f,12.f,12.f},
{-60.f,-30.f,-40.f,-40.f,-40.f,-40.f,-40.f}, 2,-75.f,
-6.f,
{99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
},
{8, /* lines per eighth octave */
{14.f,10.f,10.f,10.f,10.f,10.f,10.f},
{14.f,10.f,10.f,10.f,10.f,10.f,10.f},
{-40.f,-30.f,-25.f,-25.f,-25.f,-25.f,-25.f}, 2,-80.f,
-6.f,
{99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
},
{8, /* lines per eighth octave */
{12.f,10.f,10.f,10.f,10.f,10.f,10.f},
{12.f,10.f,10.f,10.f,10.f,10.f,10.f},
{-20.f,-20.f,-15.f,-15.f,-15.f,-15.f,-15.f}, 0,-80.f,
-6.f,
{99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
},
{8, /* lines per eighth octave */
{10.f,8.f,8.f,8.f,8.f,8.f,8.f},
{10.f,8.f,8.f,8.f,8.f,8.f,8.f},
{-20.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-80.f,
-6.f,
{99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
},
{8, /* lines per eighth octave */
{10.f,6.f,6.f,6.f,6.f,6.f,6.f},
{10.f,6.f,6.f,6.f,6.f,6.f,6.f},
{-15.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-85.f,
-6.f,
{99.},{{99.},{99.}},{0},{0},{{0.},{0.}}
@ -53,7 +53,7 @@ static vorbis_info_psy_global _psy_global_44[5]={
};
/* noise compander lookups * low, mid, high quality ****************/
static compandblock _psy_compand_44[6]={
static const compandblock _psy_compand_44[6]={
/* sub-mode Z short */
{{
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */
@ -106,7 +106,7 @@ static compandblock _psy_compand_44[6]={
/* tonal masking curve level adjustments *************************/
static vp_adjblock _vp_tonemask_adj_longblock[12]={
static const vp_adjblock _vp_tonemask_adj_longblock[12]={
/* 63 125 250 500 1 2 4 8 16 */
@ -146,7 +146,7 @@ static vp_adjblock _vp_tonemask_adj_longblock[12]={
{{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */
};
static vp_adjblock _vp_tonemask_adj_otherblock[12]={
static const vp_adjblock _vp_tonemask_adj_otherblock[12]={
/* 63 125 250 500 1 2 4 8 16 */
{{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9, 1, 1, 1, 1, 1, 1}}, /* -1 */
@ -186,76 +186,76 @@ static vp_adjblock _vp_tonemask_adj_otherblock[12]={
};
/* noise bias (transition block) */
static noise3 _psy_noisebias_trans[12]={
static const noise3 _psy_noisebias_trans[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20},
{-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2, 2, 2, 3, 6, 6, 15},
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},
/* 0
/* 0
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10},
{-30,-30,-30,-30,-26,-22,-20,-14, -8, -4, 0, 0, 0, 0, 2, 4, 10},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4, -2}}},*/
{{{-15,-15,-15,-15,-15,-12, -6, -4, 0, 2, 4, 4, 5, 5, 5, 8, 10},
{-30,-30,-30,-30,-26,-22,-20,-14, -8, -4, 0, 0, 0, 0, 2, 3, 6},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4, -2}}},
/* 1
/* 1
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 8},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},*/
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 1, 4},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},
/* 2
/* 2
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 6},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}}, */
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -2, -1, 0, 3},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -7, -4}}},
/* 3
/* 3
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 6},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2, 0, 2},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
/* 4
/* 4
{{{-20,-20,-20,-20,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 5},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/
{{{-20,-20,-20,-20,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2, -1, 1},
{-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},
/* 5
/* 5
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-22,-16,-12, -6, -4, -4, -4, -4, -2, -1, 2},
{-34,-34,-34,-34,-30,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -5}}}, */
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-22,-16,-12, -6, -4, -4, -4, -4, -3, -1, 0},
{-34,-34,-34,-34,-30,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -5}}},
/* 6
/* 6
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-24,-18,-14, -8, -6, -6, -6, -6, -4, -2, 1},
{-34,-34,-34,-34,-30,-26,-24,-18,-17,-15,-15,-15,-15,-13,-13,-12, -8}}},*/
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-24,-18,-14, -8, -6, -6, -6, -6, -5, -2, 0},
{-34,-34,-34,-34,-30,-26,-26,-24,-22,-19,-19,-19,-19,-18,-17,-16,-12}}},
/* 7
/* 7
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-24,-18,-14,-12,-10, -8, -8, -8, -6, -4, 0},
{-34,-34,-34,-34,-30,-26,-26,-24,-22,-19,-19,-19,-19,-18,-17,-16,-12}}},*/
{{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7},
{-32,-32,-32,-32,-28,-24,-24,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2},
{-34,-34,-34,-34,-30,-26,-26,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},
/* 8
/* 8
{{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2, 0, 0, 0, 1, 2, 3, 7},
{-36,-36,-36,-36,-30,-30,-30,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2},
{-36,-36,-36,-36,-34,-30,-28,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},*/
{{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2, 0, 0, 0, 1, 2, 3, 7},
{{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2, 0, 0, 0, 1, 2, 3, 7},
{-36,-36,-36,-36,-30,-30,-30,-24,-20,-16,-16,-16,-16,-14,-12,-10, -7},
{-36,-36,-36,-36,-34,-30,-28,-26,-24,-30,-30,-30,-30,-30,-30,-24,-20}}},
/* 9
/* 9
{{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2, 2},
{-36,-36,-36,-36,-34,-32,-32,-28,-20,-16,-16,-16,-16,-14,-12,-10, -7},
{-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},*/
@ -269,7 +269,7 @@ static noise3 _psy_noisebias_trans[12]={
};
/* noise bias (long block) */
static noise3 _psy_noisebias_long[12]={
static const noise3 _psy_noisebias_long[12]={
/*63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 0, 6, 6, 6, 6, 10, 10, 12, 20},
@ -344,7 +344,7 @@ static noise3 _psy_noisebias_long[12]={
};
/* noise bias (impulse block) */
static noise3 _psy_noisebias_impulse[12]={
static const noise3 _psy_noisebias_impulse[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20},
@ -378,7 +378,7 @@ static noise3 _psy_noisebias_impulse[12]={
{{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 4, 6, 11},
{-32,-32,-32,-32,-28,-24,-22,-16,-10, -6, -8, -8, -6, -6, -6, -4, -2},
{-34,-34,-34,-34,-30,-26,-24,-18,-14,-12,-12,-12,-12,-12,-10, -9, -5}}},
/* 6
/* 6
{{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 4, 6, 11},
{-34,-34,-34,-34,-30,-30,-24,-20,-12,-12,-14,-14,-10, -9, -8, -6, -4},
{-34,-34,-34,-34,-34,-30,-26,-20,-16,-15,-15,-15,-15,-15,-13,-12, -8}}},*/
@ -413,9 +413,9 @@ static noise3 _psy_noisebias_impulse[12]={
};
/* noise bias (padding block) */
static noise3 _psy_noisebias_padding[12]={
static const noise3 _psy_noisebias_padding[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20},
{-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2, 2, 2, 3, 6, 6, 15},
@ -471,45 +471,45 @@ static noise3 _psy_noisebias_padding[12]={
};
static noiseguard _psy_noiseguards_44[4]={
static const noiseguard _psy_noiseguards_44[4]={
{3,3,15},
{3,3,15},
{10,10,100},
{10,10,100},
};
static int _psy_tone_suppress[12]={
static const int _psy_tone_suppress[12]={
-20,-20,-20,-20,-20,-24,-30,-40,-40,-45,-45,-45,
};
static int _psy_tone_0dB[12]={
static const int _psy_tone_0dB[12]={
90,90,95,95,95,95,105,105,105,105,105,105,
};
static int _psy_noise_suppress[12]={
static const int _psy_noise_suppress[12]={
-20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45,
};
static vorbis_info_psy _psy_info_template={
static const vorbis_info_psy _psy_info_template={
/* blockflag */
-1,
/* ath_adjatt, ath_maxatt */
-140.,-140.,
/* tonemask att boost/decay,suppr,curves */
{0.f,0.f,0.f}, 0.,0., -40.f, {0.},
{0.f,0.f,0.f}, 0.,0., -40.f, {0.},
/*noisemaskp,supp, low/high window, low/hi guard, minimum */
1, -0.f, .5f, .5f, 0,0,0,
/* noiseoffset*3, noisecompand, max_curve_dB */
{{-1},{-1},{-1}},{-1},105.f,
/* noise normalization - channel_p, point_p, start, partition, thresh. */
0,0,-1,-1,0.,
/* noise normalization - noise_p, start, partition, thresh. */
0,-1,-1,0.,
};
/* ath ****************/
static int _psy_ath_floater[12]={
static const int _psy_ath_floater[12]={
-100,-100,-100,-100,-100,-100,-105,-105,-105,-105,-110,-120,
};
static int _psy_ath_abs[12]={
static const int _psy_ath_abs[12]={
-130,-130,-130,-130,-140,-140,-140,-140,-140,-140,-140,-150,
};
@ -522,7 +522,7 @@ static int _psy_ath_abs[12]={
/* various stereo possibilities */
/* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_44[12]={
static const adj_stereo _psy_stereo_modes_44[12]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1 */
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3},
@ -530,10 +530,6 @@ static adj_stereo _psy_stereo_modes_44[12]={
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 */
/*{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3},
{ 1, 2, 3, 4, 5, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8},
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3},
{ 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8},
@ -548,10 +544,6 @@ static adj_stereo _psy_stereo_modes_44[12]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 */
/* {{ 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 0, 0, 0, 0, 0},
{ 8, 8, 8, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1},
{ 3, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, */
{{ 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0},
{ 8, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 1},
{ 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8},
@ -567,37 +559,21 @@ static adj_stereo _psy_stereo_modes_44[12]={
{ 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 */
/* {{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0},
{ 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0},
{ 6, 7, 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, */
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 8 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
@ -615,7 +591,7 @@ static adj_stereo _psy_stereo_modes_44[12]={
};
/* tone master attenuation by base quality mode and bitrate tweak */
static att3 _psy_tone_masteratt_44[12]={
static const att3 _psy_tone_masteratt_44[12]={
{{ 35, 21, 9}, 0, 0}, /* -1 */
{{ 30, 20, 8}, -2, 1.25}, /* 0 */
/* {{ 25, 14, 4}, 0, 0}, *//* 1 */
@ -633,34 +609,34 @@ static att3 _psy_tone_masteratt_44[12]={
};
/* lowpass by mode **************/
static double _psy_lowpass_44[12]={
static const double _psy_lowpass_44[12]={
/* 15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */
13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999.
};
/* noise normalization **********/
static int _noise_start_short_44[11]={
static const int _noise_start_short_44[11]={
/* 16,16,16,16,32,32,9999,9999,9999,9999 */
32,16,16,16,32,9999,9999,9999,9999,9999,9999
};
static int _noise_start_long_44[11]={
static const int _noise_start_long_44[11]={
/* 128,128,128,256,512,512,9999,9999,9999,9999 */
256,128,128,256,512,9999,9999,9999,9999,9999,9999
};
static int _noise_part_short_44[11]={
static const int _noise_part_short_44[11]={
8,8,8,8,8,8,8,8,8,8,8
};
static int _noise_part_long_44[11]={
static const int _noise_part_long_44[11]={
32,32,32,32,32,32,32,32,32,32,32
};
static double _noise_thresh_44[11]={
static const double _noise_thresh_44[11]={
/* .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */
.2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999.,
};
static double _noise_thresh_5only[2]={
static const double _noise_thresh_5only[2]={
.5,.5,
};

View file

@ -5,23 +5,23 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 8kHz psychoacoustic settings
last mod: $Id: psych_8.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 8kHz psychoacoustic settings
last mod: $Id: psych_8.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
static att3 _psy_tone_masteratt_8[3]={
static const att3 _psy_tone_masteratt_8[3]={
{{ 32, 25, 12}, 0, 0}, /* 0 */
{{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 20, 0, -14}, 0, 0}, /* 0 */
};
static vp_adjblock _vp_tonemask_adj_8[3]={
static const vp_adjblock _vp_tonemask_adj_8[3]={
/* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */
@ -30,7 +30,7 @@ static vp_adjblock _vp_tonemask_adj_8[3]={
};
static noise3 _psy_noisebias_8[3]={
static const noise3 _psy_noisebias_8[3]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99},
{-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99},
@ -46,7 +46,7 @@ static noise3 _psy_noisebias_8[3]={
};
/* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_8[3]={
static const adj_stereo _psy_stereo_modes_8[3]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
@ -62,12 +62,12 @@ static adj_stereo _psy_stereo_modes_8[3]={
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
};
static noiseguard _psy_noiseguards_8[2]={
static const noiseguard _psy_noiseguards_8[2]={
{10,10,-1},
{10,10,-1},
};
static compandblock _psy_compand_8[2]={
static const compandblock _psy_compand_8[2]={
{{
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */
8, 8, 9, 9,10,10,11, 11, /* 15dB */
@ -84,19 +84,18 @@ static compandblock _psy_compand_8[2]={
}},
};
static double _psy_lowpass_8[3]={3.,4.,4.};
static int _noise_start_8[2]={
static const double _psy_lowpass_8[3]={3.,4.,4.};
static const int _noise_start_8[2]={
64,64,
};
static int _noise_part_8[2]={
static const int _noise_part_8[2]={
8,8,
};
static int _psy_ath_floater_8[3]={
static const int _psy_ath_floater_8[3]={
-100,-100,-105,
};
static int _psy_ath_abs_8[3]={
static const int _psy_ath_abs_8[3]={
-130,-130,-140,
};

View file

@ -1,23 +1,23 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel residue templates 16/22kHz
last mod: $Id: residue_16.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: residue_16.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
/***** residue backends *********************************************/
static static_bookblock _resbook_16s_0={
static const static_bookblock _resbook_16s_0={
{
{0},
{0,0,&_16c0_s_p1_0},
@ -31,7 +31,7 @@ static static_bookblock _resbook_16s_0={
{&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2}
}
};
static static_bookblock _resbook_16s_1={
static const static_bookblock _resbook_16s_1={
{
{0},
{0,0,&_16c1_s_p1_0},
@ -45,7 +45,7 @@ static static_bookblock _resbook_16s_1={
{&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2}
}
};
static static_bookblock _resbook_16s_2={
static const static_bookblock _resbook_16s_2={
{
{0},
{0,0,&_16c2_s_p1_0},
@ -60,37 +60,37 @@ static static_bookblock _resbook_16s_2={
}
};
static vorbis_residue_template _res_16s_0[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_16s_0[]={
{2,0,32, &_residue_44_mid,
&_huff_book__16c0_s_single,&_huff_book__16c0_s_single,
&_resbook_16s_0,&_resbook_16s_0},
};
static vorbis_residue_template _res_16s_1[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_16s_1[]={
{2,0,32, &_residue_44_mid,
&_huff_book__16c1_s_short,&_huff_book__16c1_s_short,
&_resbook_16s_1,&_resbook_16s_1},
{2,0, &_residue_44_mid,
{2,0,32, &_residue_44_mid,
&_huff_book__16c1_s_long,&_huff_book__16c1_s_long,
&_resbook_16s_1,&_resbook_16s_1}
};
static vorbis_residue_template _res_16s_2[]={
{2,0, &_residue_44_high,
static const vorbis_residue_template _res_16s_2[]={
{2,0,32, &_residue_44_high,
&_huff_book__16c2_s_short,&_huff_book__16c2_s_short,
&_resbook_16s_2,&_resbook_16s_2},
{2,0, &_residue_44_high,
{2,0,32, &_residue_44_high,
&_huff_book__16c2_s_long,&_huff_book__16c2_s_long,
&_resbook_16s_2,&_resbook_16s_2}
};
static vorbis_mapping_template _mapres_template_16_stereo[3]={
static const vorbis_mapping_template _mapres_template_16_stereo[3]={
{ _map_nominal, _res_16s_0 }, /* 0 */
{ _map_nominal, _res_16s_1 }, /* 1 */
{ _map_nominal, _res_16s_2 }, /* 2 */
};
static static_bookblock _resbook_16u_0={
static const static_bookblock _resbook_16u_0={
{
{0},
{0,0,&_16u0__p1_0},
@ -102,7 +102,7 @@ static static_bookblock _resbook_16u_0={
{&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2}
}
};
static static_bookblock _resbook_16u_1={
static const static_bookblock _resbook_16u_1={
{
{0},
{0,0,&_16u1__p1_0},
@ -116,7 +116,7 @@ static static_bookblock _resbook_16u_1={
{&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2}
}
};
static static_bookblock _resbook_16u_2={
static const static_bookblock _resbook_16u_2={
{
{0},
{0,0,&_16u2_p1_0},
@ -131,32 +131,32 @@ static static_bookblock _resbook_16u_2={
}
};
static vorbis_residue_template _res_16u_0[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_16u_0[]={
{1,0,32, &_residue_44_low_un,
&_huff_book__16u0__single,&_huff_book__16u0__single,
&_resbook_16u_0,&_resbook_16u_0},
};
static vorbis_residue_template _res_16u_1[]={
{1,0, &_residue_44_mid_un,
static const vorbis_residue_template _res_16u_1[]={
{1,0,32, &_residue_44_mid_un,
&_huff_book__16u1__short,&_huff_book__16u1__short,
&_resbook_16u_1,&_resbook_16u_1},
{1,0, &_residue_44_mid_un,
{1,0,32, &_residue_44_mid_un,
&_huff_book__16u1__long,&_huff_book__16u1__long,
&_resbook_16u_1,&_resbook_16u_1}
};
static vorbis_residue_template _res_16u_2[]={
{1,0, &_residue_44_hi_un,
static const vorbis_residue_template _res_16u_2[]={
{1,0,32, &_residue_44_hi_un,
&_huff_book__16u2__short,&_huff_book__16u2__short,
&_resbook_16u_2,&_resbook_16u_2},
{1,0, &_residue_44_hi_un,
{1,0,32, &_residue_44_hi_un,
&_huff_book__16u2__long,&_huff_book__16u2__long,
&_resbook_16u_2,&_resbook_16u_2}
};
static vorbis_mapping_template _mapres_template_16_uncoupled[3]={
static const vorbis_mapping_template _mapres_template_16_uncoupled[3]={
{ _map_nominal_u, _res_16u_0 }, /* 0 */
{ _map_nominal_u, _res_16u_1 }, /* 1 */
{ _map_nominal_u, _res_16u_2 }, /* 2 */

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel residue templates for 32/44.1/48kHz
last mod: $Id: residue_44.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: residue_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
@ -21,34 +21,34 @@
/***** residue backends *********************************************/
static vorbis_info_residue0 _residue_44_low={
0,-1, -1, 9,-1,
/* 0 1 2 3 4 5 6 7 */
static const vorbis_info_residue0 _residue_44_low={
0,-1, -1, 9,-1,-1,
/* 0 1 2 3 4 5 6 7 */
{0},
{-1},
{ .5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5},
{ .5, .5, .5, 999., 4.5, 8.5, 16.5, 32.5},
{ 0, 1, 2, 2, 4, 8, 16, 32},
{ 0, 0, 0,999, 4, 8, 16, 32},
};
static vorbis_info_residue0 _residue_44_mid={
0,-1, -1, 10,-1,
/* 0 1 2 3 4 5 6 7 8 */
static const vorbis_info_residue0 _residue_44_mid={
0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 */
{0},
{-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5},
{ .5, .5, 999., .5, 999., 4.5, 8.5, 16.5, 32.5},
{ 0, 1, 1, 2, 2, 4, 8, 16, 32},
{ 0, 0,999, 0,999, 4, 8, 16, 32},
};
static vorbis_info_residue0 _residue_44_high={
0,-1, -1, 10,-1,
/* 0 1 2 3 4 5 6 7 8 */
static const vorbis_info_residue0 _residue_44_high={
0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 */
{0},
{-1},
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5},
{ .5, 1.5, 2.5, 3.5, 4.5, 8.5, 16.5, 71.5,157.5},
{ 0, 1, 2, 4, 8, 16, 32, 71,157},
{ 0, 1, 2, 3, 4, 8, 16, 71,157},
};
static static_bookblock _resbook_44s_n1={
static const static_bookblock _resbook_44s_n1={
{
{0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0},
{0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0},
@ -56,7 +56,7 @@ static static_bookblock _resbook_44s_n1={
{&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2}
}
};
static static_bookblock _resbook_44sm_n1={
static const static_bookblock _resbook_44sm_n1={
{
{0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0},
{0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0},
@ -65,7 +65,7 @@ static static_bookblock _resbook_44sm_n1={
}
};
static static_bookblock _resbook_44s_0={
static const static_bookblock _resbook_44s_0={
{
{0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0},
{0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0},
@ -73,7 +73,7 @@ static static_bookblock _resbook_44s_0={
{&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2}
}
};
static static_bookblock _resbook_44sm_0={
static const static_bookblock _resbook_44sm_0={
{
{0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0},
{0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0},
@ -82,7 +82,7 @@ static static_bookblock _resbook_44sm_0={
}
};
static static_bookblock _resbook_44s_1={
static const static_bookblock _resbook_44s_1={
{
{0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0},
{0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0},
@ -90,7 +90,7 @@ static static_bookblock _resbook_44s_1={
{&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2}
}
};
static static_bookblock _resbook_44sm_1={
static const static_bookblock _resbook_44sm_1={
{
{0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0},
{0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0},
@ -99,7 +99,7 @@ static static_bookblock _resbook_44sm_1={
}
};
static static_bookblock _resbook_44s_2={
static const static_bookblock _resbook_44s_2={
{
{0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0},
{0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0},
@ -107,7 +107,7 @@ static static_bookblock _resbook_44s_2={
{&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2}
}
};
static static_bookblock _resbook_44s_3={
static const static_bookblock _resbook_44s_3={
{
{0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0},
{0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0},
@ -115,7 +115,7 @@ static static_bookblock _resbook_44s_3={
{&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2}
}
};
static static_bookblock _resbook_44s_4={
static const static_bookblock _resbook_44s_4={
{
{0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0},
{0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0},
@ -123,7 +123,7 @@ static static_bookblock _resbook_44s_4={
{&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2}
}
};
static static_bookblock _resbook_44s_5={
static const static_bookblock _resbook_44s_5={
{
{0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0},
{0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0},
@ -131,7 +131,7 @@ static static_bookblock _resbook_44s_5={
{&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2}
}
};
static static_bookblock _resbook_44s_6={
static const static_bookblock _resbook_44s_6={
{
{0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0},
{0,0,&_44c6_s_p4_0},
@ -142,7 +142,7 @@ static static_bookblock _resbook_44s_6={
{&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2}
}
};
static static_bookblock _resbook_44s_7={
static const static_bookblock _resbook_44s_7={
{
{0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0},
{0,0,&_44c7_s_p4_0},
@ -153,7 +153,7 @@ static static_bookblock _resbook_44s_7={
{&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2}
}
};
static static_bookblock _resbook_44s_8={
static const static_bookblock _resbook_44s_8={
{
{0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0},
{0,0,&_44c8_s_p4_0},
@ -164,7 +164,7 @@ static static_bookblock _resbook_44s_8={
{&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2}
}
};
static static_bookblock _resbook_44s_9={
static const static_bookblock _resbook_44s_9={
{
{0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0},
{0,0,&_44c9_s_p4_0},
@ -176,108 +176,108 @@ static static_bookblock _resbook_44s_9={
}
};
static vorbis_residue_template _res_44s_n1[]={
{2,0, &_residue_44_low,
static const vorbis_residue_template _res_44s_n1[]={
{2,0,32, &_residue_44_low,
&_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short,
&_resbook_44s_n1,&_resbook_44sm_n1},
{2,0, &_residue_44_low,
{2,0,32, &_residue_44_low,
&_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long,
&_resbook_44s_n1,&_resbook_44sm_n1}
};
static vorbis_residue_template _res_44s_0[]={
{2,0, &_residue_44_low,
static const vorbis_residue_template _res_44s_0[]={
{2,0,16, &_residue_44_low,
&_huff_book__44c0_s_short,&_huff_book__44c0_sm_short,
&_resbook_44s_0,&_resbook_44sm_0},
{2,0, &_residue_44_low,
{2,0,32, &_residue_44_low,
&_huff_book__44c0_s_long,&_huff_book__44c0_sm_long,
&_resbook_44s_0,&_resbook_44sm_0}
};
static vorbis_residue_template _res_44s_1[]={
{2,0, &_residue_44_low,
static const vorbis_residue_template _res_44s_1[]={
{2,0,16, &_residue_44_low,
&_huff_book__44c1_s_short,&_huff_book__44c1_sm_short,
&_resbook_44s_1,&_resbook_44sm_1},
{2,0, &_residue_44_low,
{2,0,32, &_residue_44_low,
&_huff_book__44c1_s_long,&_huff_book__44c1_sm_long,
&_resbook_44s_1,&_resbook_44sm_1}
};
static vorbis_residue_template _res_44s_2[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_44s_2[]={
{2,0,16, &_residue_44_mid,
&_huff_book__44c2_s_short,&_huff_book__44c2_s_short,
&_resbook_44s_2,&_resbook_44s_2},
{2,0, &_residue_44_mid,
{2,0,32, &_residue_44_mid,
&_huff_book__44c2_s_long,&_huff_book__44c2_s_long,
&_resbook_44s_2,&_resbook_44s_2}
};
static vorbis_residue_template _res_44s_3[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_44s_3[]={
{2,0,16, &_residue_44_mid,
&_huff_book__44c3_s_short,&_huff_book__44c3_s_short,
&_resbook_44s_3,&_resbook_44s_3},
{2,0, &_residue_44_mid,
{2,0,32, &_residue_44_mid,
&_huff_book__44c3_s_long,&_huff_book__44c3_s_long,
&_resbook_44s_3,&_resbook_44s_3}
};
static vorbis_residue_template _res_44s_4[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_44s_4[]={
{2,0,16, &_residue_44_mid,
&_huff_book__44c4_s_short,&_huff_book__44c4_s_short,
&_resbook_44s_4,&_resbook_44s_4},
{2,0, &_residue_44_mid,
{2,0,32, &_residue_44_mid,
&_huff_book__44c4_s_long,&_huff_book__44c4_s_long,
&_resbook_44s_4,&_resbook_44s_4}
};
static vorbis_residue_template _res_44s_5[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_44s_5[]={
{2,0,16, &_residue_44_mid,
&_huff_book__44c5_s_short,&_huff_book__44c5_s_short,
&_resbook_44s_5,&_resbook_44s_5},
{2,0, &_residue_44_mid,
{2,0,32, &_residue_44_mid,
&_huff_book__44c5_s_long,&_huff_book__44c5_s_long,
&_resbook_44s_5,&_resbook_44s_5}
};
static vorbis_residue_template _res_44s_6[]={
{2,0, &_residue_44_high,
static const vorbis_residue_template _res_44s_6[]={
{2,0,16, &_residue_44_high,
&_huff_book__44c6_s_short,&_huff_book__44c6_s_short,
&_resbook_44s_6,&_resbook_44s_6},
{2,0, &_residue_44_high,
{2,0,32, &_residue_44_high,
&_huff_book__44c6_s_long,&_huff_book__44c6_s_long,
&_resbook_44s_6,&_resbook_44s_6}
};
static vorbis_residue_template _res_44s_7[]={
{2,0, &_residue_44_high,
static const vorbis_residue_template _res_44s_7[]={
{2,0,16, &_residue_44_high,
&_huff_book__44c7_s_short,&_huff_book__44c7_s_short,
&_resbook_44s_7,&_resbook_44s_7},
{2,0, &_residue_44_high,
{2,0,32, &_residue_44_high,
&_huff_book__44c7_s_long,&_huff_book__44c7_s_long,
&_resbook_44s_7,&_resbook_44s_7}
};
static vorbis_residue_template _res_44s_8[]={
{2,0, &_residue_44_high,
static const vorbis_residue_template _res_44s_8[]={
{2,0,16, &_residue_44_high,
&_huff_book__44c8_s_short,&_huff_book__44c8_s_short,
&_resbook_44s_8,&_resbook_44s_8},
{2,0, &_residue_44_high,
{2,0,32, &_residue_44_high,
&_huff_book__44c8_s_long,&_huff_book__44c8_s_long,
&_resbook_44s_8,&_resbook_44s_8}
};
static vorbis_residue_template _res_44s_9[]={
{2,0, &_residue_44_high,
static const vorbis_residue_template _res_44s_9[]={
{2,0,16, &_residue_44_high,
&_huff_book__44c9_s_short,&_huff_book__44c9_s_short,
&_resbook_44s_9,&_resbook_44s_9},
{2,0, &_residue_44_high,
{2,0,32, &_residue_44_high,
&_huff_book__44c9_s_long,&_huff_book__44c9_s_long,
&_resbook_44s_9,&_resbook_44s_9}
};
static vorbis_mapping_template _mapres_template_44_stereo[]={
static const vorbis_mapping_template _mapres_template_44_stereo[]={
{ _map_nominal, _res_44s_n1 }, /* -1 */
{ _map_nominal, _res_44s_0 }, /* 0 */
{ _map_nominal, _res_44s_1 }, /* 1 */
@ -290,5 +290,3 @@ static vorbis_mapping_template _mapres_template_44_stereo[]={
{ _map_nominal, _res_44s_8 }, /* 8 */
{ _map_nominal, _res_44s_9 }, /* 9 */
};

View file

@ -11,7 +11,7 @@
********************************************************************
function: toplevel residue templates for 32/44.1/48kHz uncoupled
last mod: $Id: residue_44u.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: residue_44u.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
@ -22,41 +22,41 @@
/***** residue backends *********************************************/
static vorbis_info_residue0 _residue_44_low_un={
0,-1, -1, 8,-1,
static const vorbis_info_residue0 _residue_44_low_un={
0,-1, -1, 8,-1,-1,
{0},
{-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 28.5},
{ -1, 25, -1, 45, -1, -1, -1}
{ 0, 1, 1, 2, 2, 4, 28},
{ -1, 25, -1, 45, -1, -1, -1}
};
static vorbis_info_residue0 _residue_44_mid_un={
0,-1, -1, 10,-1,
/* 0 1 2 3 4 5 6 7 8 9 */
static const vorbis_info_residue0 _residue_44_mid_un={
0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 9 */
{0},
{-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 4.5, 16.5, 60.5},
{ -1, 30, -1, 50, -1, 80, -1, -1, -1}
{ 0, 1, 1, 2, 2, 4, 4, 16, 60},
{ -1, 30, -1, 50, -1, 80, -1, -1, -1}
};
static vorbis_info_residue0 _residue_44_hi_un={
0,-1, -1, 10,-1,
/* 0 1 2 3 4 5 6 7 8 9 */
static const vorbis_info_residue0 _residue_44_hi_un={
0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 9 */
{0},
{-1},
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5},
{ -1, -1, -1, -1, -1, -1, -1, -1, -1}
{ 0, 1, 2, 4, 8, 16, 32, 71,157},
{ -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
/* mapping conventions:
only one submap (this would change for efficient 5.1 support for example)*/
/* Four psychoacoustic profiles are used, one for each blocktype */
static vorbis_info_mapping0 _map_nominal_u[2]={
{1, {0,0}, {0}, {0}, 0,{0},{0}},
{1, {0,0}, {1}, {1}, 0,{0},{0}}
static const vorbis_info_mapping0 _map_nominal_u[2]={
{1, {0,0,0,0,0,0}, {0}, {0}, 0,{0},{0}},
{1, {0,0,0,0,0,0}, {1}, {1}, 0,{0},{0}}
};
static static_bookblock _resbook_44u_n1={
static const static_bookblock _resbook_44u_n1={
{
{0},
{0,0,&_44un1__p1_0},
@ -68,7 +68,7 @@ static static_bookblock _resbook_44u_n1={
{&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2}
}
};
static static_bookblock _resbook_44u_0={
static const static_bookblock _resbook_44u_0={
{
{0},
{0,0,&_44u0__p1_0},
@ -80,7 +80,7 @@ static static_bookblock _resbook_44u_0={
{&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2}
}
};
static static_bookblock _resbook_44u_1={
static const static_bookblock _resbook_44u_1={
{
{0},
{0,0,&_44u1__p1_0},
@ -92,7 +92,7 @@ static static_bookblock _resbook_44u_1={
{&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2}
}
};
static static_bookblock _resbook_44u_2={
static const static_bookblock _resbook_44u_2={
{
{0},
{0,0,&_44u2__p1_0},
@ -104,7 +104,7 @@ static static_bookblock _resbook_44u_2={
{&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2}
}
};
static static_bookblock _resbook_44u_3={
static const static_bookblock _resbook_44u_3={
{
{0},
{0,0,&_44u3__p1_0},
@ -116,7 +116,7 @@ static static_bookblock _resbook_44u_3={
{&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2}
}
};
static static_bookblock _resbook_44u_4={
static const static_bookblock _resbook_44u_4={
{
{0},
{0,0,&_44u4__p1_0},
@ -128,7 +128,7 @@ static static_bookblock _resbook_44u_4={
{&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2}
}
};
static static_bookblock _resbook_44u_5={
static const static_bookblock _resbook_44u_5={
{
{0},
{0,0,&_44u5__p1_0},
@ -142,7 +142,7 @@ static static_bookblock _resbook_44u_5={
{&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2}
}
};
static static_bookblock _resbook_44u_6={
static const static_bookblock _resbook_44u_6={
{
{0},
{0,0,&_44u6__p1_0},
@ -156,7 +156,7 @@ static static_bookblock _resbook_44u_6={
{&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2}
}
};
static static_bookblock _resbook_44u_7={
static const static_bookblock _resbook_44u_7={
{
{0},
{0,0,&_44u7__p1_0},
@ -170,7 +170,7 @@ static static_bookblock _resbook_44u_7={
{&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2}
}
};
static static_bookblock _resbook_44u_8={
static const static_bookblock _resbook_44u_8={
{
{0},
{0,0,&_44u8_p1_0},
@ -184,7 +184,7 @@ static static_bookblock _resbook_44u_8={
{&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2}
}
};
static static_bookblock _resbook_44u_9={
static const static_bookblock _resbook_44u_9={
{
{0},
{0,0,&_44u9_p1_0},
@ -199,111 +199,111 @@ static static_bookblock _resbook_44u_9={
}
};
static vorbis_residue_template _res_44u_n1[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_n1[]={
{1,0,32, &_residue_44_low_un,
&_huff_book__44un1__short,&_huff_book__44un1__short,
&_resbook_44u_n1,&_resbook_44u_n1},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44un1__long,&_huff_book__44un1__long,
&_resbook_44u_n1,&_resbook_44u_n1}
};
static vorbis_residue_template _res_44u_0[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_0[]={
{1,0,16, &_residue_44_low_un,
&_huff_book__44u0__short,&_huff_book__44u0__short,
&_resbook_44u_0,&_resbook_44u_0},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44u0__long,&_huff_book__44u0__long,
&_resbook_44u_0,&_resbook_44u_0}
};
static vorbis_residue_template _res_44u_1[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_1[]={
{1,0,16, &_residue_44_low_un,
&_huff_book__44u1__short,&_huff_book__44u1__short,
&_resbook_44u_1,&_resbook_44u_1},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44u1__long,&_huff_book__44u1__long,
&_resbook_44u_1,&_resbook_44u_1}
};
static vorbis_residue_template _res_44u_2[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_2[]={
{1,0,16, &_residue_44_low_un,
&_huff_book__44u2__short,&_huff_book__44u2__short,
&_resbook_44u_2,&_resbook_44u_2},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44u2__long,&_huff_book__44u2__long,
&_resbook_44u_2,&_resbook_44u_2}
};
static vorbis_residue_template _res_44u_3[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_3[]={
{1,0,16, &_residue_44_low_un,
&_huff_book__44u3__short,&_huff_book__44u3__short,
&_resbook_44u_3,&_resbook_44u_3},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44u3__long,&_huff_book__44u3__long,
&_resbook_44u_3,&_resbook_44u_3}
};
static vorbis_residue_template _res_44u_4[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_44u_4[]={
{1,0,16, &_residue_44_low_un,
&_huff_book__44u4__short,&_huff_book__44u4__short,
&_resbook_44u_4,&_resbook_44u_4},
{1,0, &_residue_44_low_un,
{1,0,32, &_residue_44_low_un,
&_huff_book__44u4__long,&_huff_book__44u4__long,
&_resbook_44u_4,&_resbook_44u_4}
};
static vorbis_residue_template _res_44u_5[]={
{1,0, &_residue_44_mid_un,
static const vorbis_residue_template _res_44u_5[]={
{1,0,16, &_residue_44_mid_un,
&_huff_book__44u5__short,&_huff_book__44u5__short,
&_resbook_44u_5,&_resbook_44u_5},
{1,0, &_residue_44_mid_un,
{1,0,32, &_residue_44_mid_un,
&_huff_book__44u5__long,&_huff_book__44u5__long,
&_resbook_44u_5,&_resbook_44u_5}
};
static vorbis_residue_template _res_44u_6[]={
{1,0, &_residue_44_mid_un,
static const vorbis_residue_template _res_44u_6[]={
{1,0,16, &_residue_44_mid_un,
&_huff_book__44u6__short,&_huff_book__44u6__short,
&_resbook_44u_6,&_resbook_44u_6},
{1,0, &_residue_44_mid_un,
{1,0,32, &_residue_44_mid_un,
&_huff_book__44u6__long,&_huff_book__44u6__long,
&_resbook_44u_6,&_resbook_44u_6}
};
static vorbis_residue_template _res_44u_7[]={
{1,0, &_residue_44_mid_un,
static const vorbis_residue_template _res_44u_7[]={
{1,0,16, &_residue_44_mid_un,
&_huff_book__44u7__short,&_huff_book__44u7__short,
&_resbook_44u_7,&_resbook_44u_7},
{1,0, &_residue_44_mid_un,
{1,0,32, &_residue_44_mid_un,
&_huff_book__44u7__long,&_huff_book__44u7__long,
&_resbook_44u_7,&_resbook_44u_7}
};
static vorbis_residue_template _res_44u_8[]={
{1,0, &_residue_44_hi_un,
static const vorbis_residue_template _res_44u_8[]={
{1,0,16, &_residue_44_hi_un,
&_huff_book__44u8__short,&_huff_book__44u8__short,
&_resbook_44u_8,&_resbook_44u_8},
{1,0, &_residue_44_hi_un,
{1,0,32, &_residue_44_hi_un,
&_huff_book__44u8__long,&_huff_book__44u8__long,
&_resbook_44u_8,&_resbook_44u_8}
};
static vorbis_residue_template _res_44u_9[]={
{1,0, &_residue_44_hi_un,
static const vorbis_residue_template _res_44u_9[]={
{1,0,16, &_residue_44_hi_un,
&_huff_book__44u9__short,&_huff_book__44u9__short,
&_resbook_44u_9,&_resbook_44u_9},
{1,0, &_residue_44_hi_un,
{1,0,32, &_residue_44_hi_un,
&_huff_book__44u9__long,&_huff_book__44u9__long,
&_resbook_44u_9,&_resbook_44u_9}
};
static vorbis_mapping_template _mapres_template_44_uncoupled[]={
static const vorbis_mapping_template _mapres_template_44_uncoupled[]={
{ _map_nominal_u, _res_44u_n1 }, /* -1 */
{ _map_nominal_u, _res_44u_0 }, /* 0 */
{ _map_nominal_u, _res_44u_1 }, /* 1 */

View file

@ -11,7 +11,7 @@
********************************************************************
function: toplevel residue templates 8/11kHz
last mod: $Id: residue_8.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: residue_8.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
@ -20,7 +20,7 @@
/***** residue backends *********************************************/
static static_bookblock _resbook_8s_0={
static const static_bookblock _resbook_8s_0={
{
{0},
{0,0,&_8c0_s_p1_0},
@ -34,7 +34,7 @@ static static_bookblock _resbook_8s_0={
{&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2}
}
};
static static_bookblock _resbook_8s_1={
static const static_bookblock _resbook_8s_1={
{
{0},
{0,0,&_8c1_s_p1_0},
@ -49,23 +49,23 @@ static static_bookblock _resbook_8s_1={
}
};
static vorbis_residue_template _res_8s_0[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_8s_0[]={
{2,0,32, &_residue_44_mid,
&_huff_book__8c0_s_single,&_huff_book__8c0_s_single,
&_resbook_8s_0,&_resbook_8s_0},
};
static vorbis_residue_template _res_8s_1[]={
{2,0, &_residue_44_mid,
static const vorbis_residue_template _res_8s_1[]={
{2,0,32, &_residue_44_mid,
&_huff_book__8c1_s_single,&_huff_book__8c1_s_single,
&_resbook_8s_1,&_resbook_8s_1},
};
static vorbis_mapping_template _mapres_template_8_stereo[2]={
static const vorbis_mapping_template _mapres_template_8_stereo[2]={
{ _map_nominal, _res_8s_0 }, /* 0 */
{ _map_nominal, _res_8s_1 }, /* 1 */
};
static static_bookblock _resbook_8u_0={
static const static_bookblock _resbook_8u_0={
{
{0},
{0,0,&_8u0__p1_0},
@ -77,7 +77,7 @@ static static_bookblock _resbook_8u_0={
{&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2}
}
};
static static_bookblock _resbook_8u_1={
static const static_bookblock _resbook_8u_1={
{
{0},
{0,0,&_8u1__p1_0},
@ -92,18 +92,18 @@ static static_bookblock _resbook_8u_1={
}
};
static vorbis_residue_template _res_8u_0[]={
{1,0, &_residue_44_low_un,
static const vorbis_residue_template _res_8u_0[]={
{1,0,32, &_residue_44_low_un,
&_huff_book__8u0__single,&_huff_book__8u0__single,
&_resbook_8u_0,&_resbook_8u_0},
};
static vorbis_residue_template _res_8u_1[]={
{1,0, &_residue_44_mid_un,
static const vorbis_residue_template _res_8u_1[]={
{1,0,32, &_residue_44_mid_un,
&_huff_book__8u1__single,&_huff_book__8u1__single,
&_resbook_8u_1,&_resbook_8u_1},
};
static vorbis_mapping_template _mapres_template_8_uncoupled[2]={
static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={
{ _map_nominal_u, _res_8u_0 }, /* 0 */
{ _map_nominal_u, _res_8u_1 }, /* 1 */
};

View file

@ -5,46 +5,49 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 11kHz settings
last mod: $Id: setup_11.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 11kHz settings
last mod: $Id: setup_11.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/
#include "psych_11.h"
static int blocksize_11[2]={
static const int blocksize_11[2]={
512,512
};
static int _floor_mapping_11[2]={
6,6,
static const int _floor_mapping_11a[]={
6,6
};
static const int *_floor_mapping_11[]={
_floor_mapping_11a
};
static double rate_mapping_11[3]={
static const double rate_mapping_11[3]={
8000.,13000.,44000.,
};
static double rate_mapping_11_uncoupled[3]={
static const double rate_mapping_11_uncoupled[3]={
12000.,20000.,50000.,
};
static double quality_mapping_11[3]={
static const double quality_mapping_11[3]={
-.1,.0,1.
};
ve_setup_data_template ve_setup_11_stereo={
static const ve_setup_data_template ve_setup_11_stereo={
2,
rate_mapping_11,
quality_mapping_11,
2,
9000,
15000,
blocksize_11,
blocksize_11,
@ -62,7 +65,7 @@ ve_setup_data_template ve_setup_11_stereo={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -73,7 +76,7 @@ ve_setup_data_template ve_setup_11_stereo={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_11,
_psy_global_44,
@ -82,20 +85,20 @@ ve_setup_data_template ve_setup_11_stereo={
_floor_books,
_floor,
1,
_floor_mapping_11,
NULL,
_mapres_template_8_stereo
};
ve_setup_data_template ve_setup_11_uncoupled={
static const ve_setup_data_template ve_setup_11_uncoupled={
2,
rate_mapping_11_uncoupled,
quality_mapping_11,
-1,
9000,
15000,
blocksize_11,
blocksize_11,
@ -113,7 +116,7 @@ ve_setup_data_template ve_setup_11_uncoupled={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -124,7 +127,7 @@ ve_setup_data_template ve_setup_11_uncoupled={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_11,
_psy_global_44,
@ -133,9 +136,8 @@ ve_setup_data_template ve_setup_11_uncoupled={
_floor_books,
_floor,
1,
_floor_mapping_11,
NULL,
_mapres_template_8_uncoupled
};

View file

@ -5,55 +5,59 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 16kHz settings
last mod: $Id: setup_16.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 16kHz settings
last mod: $Id: setup_16.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/
#include "psych_16.h"
#include "residue_16.h"
static int blocksize_16_short[3]={
static const int blocksize_16_short[3]={
1024,512,512
};
static int blocksize_16_long[3]={
static const int blocksize_16_long[3]={
1024,1024,1024
};
static int _floor_mapping_16_short[3]={
static const int _floor_mapping_16a[]={
9,3,3
};
static int _floor_mapping_16[3]={
static const int _floor_mapping_16b[]={
9,9,9
};
static const int *_floor_mapping_16[]={
_floor_mapping_16a,
_floor_mapping_16b
};
static double rate_mapping_16[4]={
static const double rate_mapping_16[4]={
12000.,20000.,44000.,86000.
};
static double rate_mapping_16_uncoupled[4]={
static const double rate_mapping_16_uncoupled[4]={
16000.,28000.,64000.,100000.
};
static double _global_mapping_16[4]={ 1., 2., 3., 4. };
static const double _global_mapping_16[4]={ 1., 2., 3., 4. };
static double quality_mapping_16[4]={ -.1,.05,.5,1. };
static const double quality_mapping_16[4]={ -.1,.05,.5,1. };
static double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.};
static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.};
ve_setup_data_template ve_setup_16_stereo={
static const ve_setup_data_template ve_setup_16_stereo={
3,
rate_mapping_16,
quality_mapping_16,
2,
15000,
19000,
blocksize_16_short,
blocksize_16_long,
@ -71,7 +75,7 @@ ve_setup_data_template ve_setup_16_stereo={
_psy_noisebias_16_short,
_psy_noisebias_16,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_16_mapping,
_psy_compand_16_mapping,
@ -82,7 +86,7 @@ ve_setup_data_template ve_setup_16_stereo={
_psy_ath_floater_16,
_psy_ath_abs_16,
_psy_lowpass_16,
_psy_global_44,
@ -91,20 +95,20 @@ ve_setup_data_template ve_setup_16_stereo={
_floor_books,
_floor,
_floor_mapping_16_short,
2,
_floor_mapping_16,
_mapres_template_16_stereo
};
ve_setup_data_template ve_setup_16_uncoupled={
static const ve_setup_data_template ve_setup_16_uncoupled={
3,
rate_mapping_16_uncoupled,
quality_mapping_16,
-1,
15000,
19000,
blocksize_16_short,
blocksize_16_long,
@ -116,13 +120,13 @@ ve_setup_data_template ve_setup_16_uncoupled={
_vp_tonemask_adj_16,
_vp_tonemask_adj_16,
_psy_noiseguards_8,
_psy_noiseguards_16,
_psy_noisebias_16_impulse,
_psy_noisebias_16_short,
_psy_noisebias_16_short,
_psy_noisebias_16,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_16_mapping,
_psy_compand_16_mapping,
@ -133,7 +137,7 @@ ve_setup_data_template ve_setup_16_uncoupled={
_psy_ath_floater_16,
_psy_ath_abs_16,
_psy_lowpass_16,
_psy_global_44,
@ -142,7 +146,7 @@ ve_setup_data_template ve_setup_16_uncoupled={
_floor_books,
_floor,
_floor_mapping_16_short,
2,
_floor_mapping_16,
_mapres_template_16_uncoupled

View file

@ -5,34 +5,34 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 22kHz settings
last mod: $Id: setup_22.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 22kHz settings
last mod: $Id: setup_22.h 17026 2010-03-25 05:00:27Z xiphmont $
********************************************************************/
static double rate_mapping_22[4]={
static const double rate_mapping_22[4]={
15000.,20000.,44000.,86000.
};
static double rate_mapping_22_uncoupled[4]={
static const double rate_mapping_22_uncoupled[4]={
16000.,28000.,50000.,90000.
};
static double _psy_lowpass_22[4]={9.5,11.,30.,99.};
static const double _psy_lowpass_22[4]={9.5,11.,30.,99.};
ve_setup_data_template ve_setup_22_stereo={
static const ve_setup_data_template ve_setup_22_stereo={
3,
rate_mapping_22,
quality_mapping_16,
2,
19000,
26000,
blocksize_16_short,
blocksize_16_long,
@ -50,10 +50,10 @@ ve_setup_data_template ve_setup_22_stereo={
_psy_noisebias_16_short,
_psy_noisebias_16,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
_psy_compand_8_mapping,
_psy_compand_16_mapping,
_psy_compand_16_mapping,
{_noise_start_16,_noise_start_16},
{ _noise_part_16, _noise_part_16},
@ -61,7 +61,7 @@ ve_setup_data_template ve_setup_22_stereo={
_psy_ath_floater_16,
_psy_ath_abs_16,
_psy_lowpass_22,
_psy_global_44,
@ -70,20 +70,20 @@ ve_setup_data_template ve_setup_22_stereo={
_floor_books,
_floor,
_floor_mapping_16_short,
2,
_floor_mapping_16,
_mapres_template_16_stereo
};
ve_setup_data_template ve_setup_22_uncoupled={
static const ve_setup_data_template ve_setup_22_uncoupled={
3,
rate_mapping_22_uncoupled,
quality_mapping_16,
-1,
19000,
26000,
blocksize_16_short,
blocksize_16_long,
@ -95,16 +95,16 @@ ve_setup_data_template ve_setup_22_uncoupled={
_vp_tonemask_adj_16,
_vp_tonemask_adj_16,
_psy_noiseguards_8,
_psy_noiseguards_16,
_psy_noisebias_16_impulse,
_psy_noisebias_16_short,
_psy_noisebias_16_short,
_psy_noisebias_16,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
_psy_compand_8_mapping,
_psy_compand_16_mapping,
_psy_compand_16_mapping,
{_noise_start_16,_noise_start_16},
{ _noise_part_16, _noise_part_16},
@ -112,7 +112,7 @@ ve_setup_data_template ve_setup_22_uncoupled={
_psy_ath_floater_16,
_psy_ath_abs_16,
_psy_lowpass_22,
_psy_global_44,
@ -121,7 +121,7 @@ ve_setup_data_template ve_setup_22_uncoupled={
_floor_books,
_floor,
_floor_mapping_16_short,
2,
_floor_mapping_16,
_mapres_template_16_uncoupled

View file

@ -5,38 +5,38 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel settings for 32kHz
last mod: $Id: setup_32.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: setup_32.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/
static double rate_mapping_32[12]={
static const double rate_mapping_32[12]={
18000.,28000.,35000.,45000.,56000.,60000.,
75000.,90000.,100000.,115000.,150000.,190000.,
};
static double rate_mapping_32_un[12]={
static const double rate_mapping_32_un[12]={
30000.,42000.,52000.,64000.,72000.,78000.,
86000.,92000.,110000.,120000.,140000.,190000.,
};
static double _psy_lowpass_32[12]={
static const double _psy_lowpass_32[12]={
12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.
};
ve_setup_data_template ve_setup_32_stereo={
static const ve_setup_data_template ve_setup_32_stereo={
11,
rate_mapping_32,
quality_mapping_44,
2,
26000,
40000,
blocksize_short_44,
blocksize_long_44,
@ -54,7 +54,7 @@ ve_setup_data_template ve_setup_32_stereo={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -65,7 +65,7 @@ ve_setup_data_template ve_setup_32_stereo={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_32,
_psy_global_44,
@ -74,20 +74,20 @@ ve_setup_data_template ve_setup_32_stereo={
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_stereo
};
ve_setup_data_template ve_setup_32_uncoupled={
static const ve_setup_data_template ve_setup_32_uncoupled={
11,
rate_mapping_32_un,
quality_mapping_44,
-1,
26000,
40000,
blocksize_short_44,
blocksize_long_44,
@ -105,7 +105,7 @@ ve_setup_data_template ve_setup_32_uncoupled={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -116,7 +116,7 @@ ve_setup_data_template ve_setup_32_uncoupled={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_32,
_psy_global_44,
@ -125,8 +125,8 @@ ve_setup_data_template ve_setup_32_uncoupled={
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_uncoupled
};

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel settings for 44.1/48kHz
last mod: $Id: setup_44.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: setup_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
@ -19,49 +19,60 @@
#include "modes/residue_44.h"
#include "modes/psych_44.h"
static double rate_mapping_44_stereo[12]={
static const double rate_mapping_44_stereo[12]={
22500.,32000.,40000.,48000.,56000.,64000.,
80000.,96000.,112000.,128000.,160000.,250001.
};
static double quality_mapping_44[12]={
static const double quality_mapping_44[12]={
-.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0
};
static int blocksize_short_44[11]={
static const int blocksize_short_44[11]={
512,256,256,256,256,256,256,256,256,256,256
};
static int blocksize_long_44[11]={
static const int blocksize_long_44[11]={
4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048
};
static double _psy_compand_short_mapping[12]={
static const double _psy_compand_short_mapping[12]={
0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.
};
static double _psy_compand_long_mapping[12]={
static const double _psy_compand_long_mapping[12]={
3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5.
};
static double _global_mapping_44[12]={
static const double _global_mapping_44[12]={
/* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */
0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4.
};
static int _floor_short_mapping_44[11]={
static const int _floor_mapping_44a[11]={
1,0,0,2,2,4,5,5,5,5,5
};
static int _floor_long_mapping_44[11]={
static const int _floor_mapping_44b[11]={
8,7,7,7,7,7,7,7,7,7,7
};
ve_setup_data_template ve_setup_44_stereo={
static const int _floor_mapping_44c[11]={
10,10,10,10,10,10,10,10,10,10,10
};
static const int *_floor_mapping_44[]={
_floor_mapping_44a,
_floor_mapping_44b,
_floor_mapping_44c,
};
static const ve_setup_data_template ve_setup_44_stereo={
11,
rate_mapping_44_stereo,
quality_mapping_44,
2,
40000,
50000,
blocksize_short_44,
blocksize_long_44,
@ -79,7 +90,7 @@ ve_setup_data_template ve_setup_44_stereo={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -90,7 +101,7 @@ ve_setup_data_template ve_setup_44_stereo={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_44,
_psy_global_44,
@ -99,9 +110,8 @@ ve_setup_data_template ve_setup_44_stereo={
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_stereo
};

View file

@ -5,31 +5,31 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: toplevel settings for 44.1/48kHz uncoupled modes
last mod: $Id: setup_44u.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/
#include "modes/residue_44u.h"
static double rate_mapping_44_un[12]={
static const double rate_mapping_44_un[12]={
32000.,48000.,60000.,70000.,80000.,86000.,
96000.,110000.,120000.,140000.,160000.,240001.
};
ve_setup_data_template ve_setup_44_uncoupled={
static const ve_setup_data_template ve_setup_44_uncoupled={
11,
rate_mapping_44_un,
quality_mapping_44,
-1,
40000,
50000,
blocksize_short_44,
blocksize_long_44,
@ -47,7 +47,7 @@ ve_setup_data_template ve_setup_44_uncoupled={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -58,17 +58,17 @@ ve_setup_data_template ve_setup_44_uncoupled={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_44,
_psy_global_44,
_global_mapping_44,
NULL,
_psy_stereo_modes_44,
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_uncoupled
};

View file

@ -5,51 +5,55 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: 8kHz settings
last mod: $Id: setup_8.h 13293 2007-07-24 00:09:47Z xiphmont $
function: 8kHz settings
last mod: $Id: setup_8.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/
#include "psych_8.h"
#include "residue_8.h"
static int blocksize_8[2]={
static const int blocksize_8[2]={
512,512
};
static int _floor_mapping_8[2]={
6,6,
static const int _floor_mapping_8a[]={
6,6
};
static double rate_mapping_8[3]={
static const int *_floor_mapping_8[]={
_floor_mapping_8a
};
static const double rate_mapping_8[3]={
6000.,9000.,32000.,
};
static double rate_mapping_8_uncoupled[3]={
static const double rate_mapping_8_uncoupled[3]={
8000.,14000.,42000.,
};
static double quality_mapping_8[3]={
static const double quality_mapping_8[3]={
-.1,.0,1.
};
static double _psy_compand_8_mapping[3]={ 0., 1., 1.};
static const double _psy_compand_8_mapping[3]={ 0., 1., 1.};
static double _global_mapping_8[3]={ 1., 2., 3. };
static const double _global_mapping_8[3]={ 1., 2., 3. };
ve_setup_data_template ve_setup_8_stereo={
static const ve_setup_data_template ve_setup_8_stereo={
2,
rate_mapping_8,
quality_mapping_8,
2,
8000,
9000,
blocksize_8,
blocksize_8,
@ -67,7 +71,7 @@ ve_setup_data_template ve_setup_8_stereo={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -78,7 +82,7 @@ ve_setup_data_template ve_setup_8_stereo={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_8,
_psy_global_44,
@ -87,20 +91,20 @@ ve_setup_data_template ve_setup_8_stereo={
_floor_books,
_floor,
1,
_floor_mapping_8,
NULL,
_mapres_template_8_stereo
};
ve_setup_data_template ve_setup_8_uncoupled={
static const ve_setup_data_template ve_setup_8_uncoupled={
2,
rate_mapping_8_uncoupled,
quality_mapping_8,
-1,
8000,
9000,
blocksize_8,
blocksize_8,
@ -118,7 +122,7 @@ ve_setup_data_template ve_setup_8_uncoupled={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -129,7 +133,7 @@ ve_setup_data_template ve_setup_8_uncoupled={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_8,
_psy_global_44,
@ -138,9 +142,8 @@ ve_setup_data_template ve_setup_8_uncoupled={
_floor_books,
_floor,
1,
_floor_mapping_8,
NULL,
_mapres_template_8_uncoupled
};

View file

@ -5,29 +5,29 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: catch-all toplevel settings for q modes only
last mod: $Id: setup_X.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: setup_X.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/
static double rate_mapping_X[12]={
static const double rate_mapping_X[12]={
-1.,-1.,-1.,-1.,-1.,-1.,
-1.,-1.,-1.,-1.,-1.,-1.
};
ve_setup_data_template ve_setup_X_stereo={
static const ve_setup_data_template ve_setup_X_stereo={
11,
rate_mapping_X,
quality_mapping_44,
2,
50000,
200000,
blocksize_short_44,
blocksize_long_44,
@ -45,7 +45,7 @@ ve_setup_data_template ve_setup_X_stereo={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -56,7 +56,7 @@ ve_setup_data_template ve_setup_X_stereo={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_44,
_psy_global_44,
@ -65,20 +65,20 @@ ve_setup_data_template ve_setup_X_stereo={
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_stereo
};
ve_setup_data_template ve_setup_X_uncoupled={
static const ve_setup_data_template ve_setup_X_uncoupled={
11,
rate_mapping_X,
quality_mapping_44,
-1,
50000,
200000,
blocksize_short_44,
blocksize_long_44,
@ -96,7 +96,7 @@ ve_setup_data_template ve_setup_X_uncoupled={
_psy_noisebias_trans,
_psy_noisebias_long,
_psy_noise_suppress,
_psy_compand_44,
_psy_compand_short_mapping,
_psy_compand_long_mapping,
@ -107,7 +107,7 @@ ve_setup_data_template ve_setup_X_uncoupled={
_psy_ath_floater,
_psy_ath_abs,
_psy_lowpass_44,
_psy_global_44,
@ -116,20 +116,20 @@ ve_setup_data_template ve_setup_X_uncoupled={
_floor_books,
_floor,
_floor_short_mapping_44,
_floor_long_mapping_44,
2,
_floor_mapping_44,
_mapres_template_44_uncoupled
};
ve_setup_data_template ve_setup_XX_stereo={
static const ve_setup_data_template ve_setup_XX_stereo={
2,
rate_mapping_X,
quality_mapping_8,
2,
0,
8000,
blocksize_8,
blocksize_8,
@ -147,7 +147,7 @@ ve_setup_data_template ve_setup_XX_stereo={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -158,7 +158,7 @@ ve_setup_data_template ve_setup_XX_stereo={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_8,
_psy_global_44,
@ -167,20 +167,20 @@ ve_setup_data_template ve_setup_XX_stereo={
_floor_books,
_floor,
1,
_floor_mapping_8,
NULL,
_mapres_template_8_stereo
};
ve_setup_data_template ve_setup_XX_uncoupled={
static const ve_setup_data_template ve_setup_XX_uncoupled={
2,
rate_mapping_X,
quality_mapping_8,
-1,
0,
8000,
blocksize_8,
blocksize_8,
@ -198,7 +198,7 @@ ve_setup_data_template ve_setup_XX_uncoupled={
NULL,
NULL,
_psy_noise_suppress,
_psy_compand_8,
_psy_compand_8_mapping,
NULL,
@ -209,7 +209,7 @@ ve_setup_data_template ve_setup_XX_uncoupled={
_psy_ath_floater_8,
_psy_ath_abs_8,
_psy_lowpass_8,
_psy_global_44,
@ -218,9 +218,8 @@ ve_setup_data_template ve_setup_XX_uncoupled={
_floor_books,
_floor,
1,
_floor_mapping_8,
NULL,
_mapres_template_8_uncoupled
};

View file

@ -7,13 +7,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
last mod: $Id: os.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: os.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -47,7 +47,7 @@
#if defined(_WIN32) && !defined(__SYMBIAN32__)
# include <malloc.h>
# define rint(x) (floor((x)+0.5f))
# define rint(x) (floor((x)+0.5f))
# define NO_FLOAT_MATH_LIB
# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
#endif
@ -79,6 +79,8 @@ void *_alloca(size_t size);
# define max(x,y) ((x)<(y)?(y):(x))
#endif
/* Special i386 GCC implementation */
#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__)
# define VORBIS_FPU_CONTROL
/* both GCC and MSVC are kinda stupid about rounding/casting to int.
@ -94,10 +96,10 @@ static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
ogg_int16_t ret;
ogg_int16_t temp;
__asm__ __volatile__("fnstcw %0\n\t"
"movw %0,%%dx\n\t"
"orw $62463,%%dx\n\t"
"movw %%dx,%1\n\t"
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
"movw %0,%%dx\n\t"
"andw $62463,%%dx\n\t"
"movw %%dx,%1\n\t"
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
*fpu=ret;
}
@ -113,21 +115,23 @@ static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise,
__asm__("fistl %0": "=m"(i) : "t"(f));
return(i);
}
#endif
#endif /* Special i386 GCC implementation */
#if defined(_WIN32) && !defined(__GNUC__) && !defined(__BORLANDC__) && !defined(_XBOX_VER)
/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the
* 64 bit compiler */
#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_WIN32_WCE)
# define VORBIS_FPU_CONTROL
typedef ogg_int16_t vorbis_fpu_control;
static __inline int vorbis_ftoi(double f){
int i;
__asm{
fld f
fistp i
}
return i;
int i;
__asm{
fld f
fistp i
}
return i;
}
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
@ -136,21 +140,47 @@ static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
}
#endif
#endif /* Special MSVC 32 bit implementation */
/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be
done safely because all x86_64 CPUs supports SSE2. */
#if (defined(_MSC_VER) && defined(_WIN64)) || (defined(__GNUC__) && defined (__x86_64__))
# define VORBIS_FPU_CONTROL
typedef ogg_int16_t vorbis_fpu_control;
#include <emmintrin.h>
static __inline int vorbis_ftoi(double f){
return _mm_cvtsd_si32(_mm_load_sd(&f));
}
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
}
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
}
#endif /* Special MSVC x64 implementation */
/* If no special implementation was found for the current compiler / platform,
use the default implementation here: */
#ifndef VORBIS_FPU_CONTROL
typedef int vorbis_fpu_control;
static int vorbis_ftoi(double f){
return (int)(f+.5);
/* Note: MSVC and GCC (at least on some systems) round towards zero, thus,
the floor() call is required to ensure correct roudning of
negative numbers */
return (int)floor(f+.5);
}
/* We don't have special code for this compiler/arch, so do it the slow way */
# define vorbis_fpu_setround(vorbis_fpu_control) {}
# define vorbis_fpu_restore(vorbis_fpu_control) {}
#endif
#endif /* default implementation */
#endif /* _OS_H */

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: random psychoacoustics (not including preecho)
last mod: $Id: psy.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $
********************************************************************/
@ -57,8 +57,7 @@ typedef struct vorbis_info_psy{
float max_curve_dB;
int normal_channel_p;
int normal_point_p;
int normal_p;
int normal_start;
int normal_partition;
double normal_thresh;
@ -76,11 +75,11 @@ typedef struct{
float ampmax_att_per_sec;
/* channel coupling config */
int coupling_pkHz[PACKETBLOBS];
int coupling_pointlimit[2][PACKETBLOBS];
int coupling_prepointamp[PACKETBLOBS];
int coupling_postpointamp[PACKETBLOBS];
int sliding_lowpass[2][PACKETBLOBS];
int coupling_pkHz[PACKETBLOBS];
int coupling_pointlimit[2][PACKETBLOBS];
int coupling_prepointamp[PACKETBLOBS];
int coupling_postpointamp[PACKETBLOBS];
int sliding_lowpass[2][PACKETBLOBS];
} vorbis_info_psy_global;
@ -89,7 +88,7 @@ typedef struct {
int channels;
vorbis_info_psy_global *gi;
int coupling_pointlimit[2][P_NOISECURVES];
int coupling_pointlimit[2][P_NOISECURVES];
} vorbis_look_psy_global;
@ -107,7 +106,7 @@ typedef struct {
long firstoc;
long shiftoc;
int eighth_octave_lines; /* power of two, please */
int total_octave_lines;
int total_octave_lines;
long rate; /* cache it */
float m_val; /* Masking compensation value */
@ -115,72 +114,41 @@ typedef struct {
} vorbis_look_psy;
extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
vorbis_info_psy_global *gi,int n,long rate);
vorbis_info_psy_global *gi,int n,long rate);
extern void _vp_psy_clear(vorbis_look_psy *p);
extern void *_vi_psy_dup(void *source);
extern void _vi_psy_free(vorbis_info_psy *i);
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
extern void _vp_remove_floor(vorbis_look_psy *p,
float *mdct,
int *icodedflr,
float *residue,
int sliding_lowpass);
extern void _vp_noisemask(vorbis_look_psy *p,
float *logmdct,
float *logmask);
float *logmdct,
float *logmask);
extern void _vp_tonemask(vorbis_look_psy *p,
float *logfft,
float *logmask,
float global_specmax,
float local_specmax);
float *logfft,
float *logmask,
float global_specmax,
float local_specmax);
extern void _vp_offset_and_mix(vorbis_look_psy *p,
float *noise,
float *tone,
int offset_select,
float *logmask,
float *mdct,
float *logmdct);
float *noise,
float *tone,
int offset_select,
float *logmask,
float *mdct,
float *logmdct);
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
extern float **_vp_quantize_couple_memo(vorbis_block *vb,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct);
extern void _vp_couple(int blobno,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **res,
float **mag_memo,
int **mag_sort,
int **ifloor,
int *nonzero,
int sliding_lowpass);
extern void _vp_noise_normalize(vorbis_look_psy *p,
float *in,float *out,int *sortedindex);
extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
float *magnitudes,int *sortedindex);
extern int **_vp_quantize_couple_sort(vorbis_block *vb,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mags);
extern void hf_reduction(vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct);
extern void _vp_couple_quantize_normalize(int blobno,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct,
int **iwork,
int *nonzero,
int sliding_lowpass,
int ch);
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: registry for time, floor, res backends and channel mappings
last mod: $Id: registry.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -22,25 +22,24 @@
/* seems like major overkill now; the backend numbers will grow into
the infrastructure soon enough */
extern vorbis_func_floor floor0_exportbundle;
extern vorbis_func_floor floor1_exportbundle;
extern vorbis_func_residue residue0_exportbundle;
extern vorbis_func_residue residue1_exportbundle;
extern vorbis_func_residue residue2_exportbundle;
extern vorbis_func_mapping mapping0_exportbundle;
extern const vorbis_func_floor floor0_exportbundle;
extern const vorbis_func_floor floor1_exportbundle;
extern const vorbis_func_residue residue0_exportbundle;
extern const vorbis_func_residue residue1_exportbundle;
extern const vorbis_func_residue residue2_exportbundle;
extern const vorbis_func_mapping mapping0_exportbundle;
vorbis_func_floor *_floor_P[]={
const vorbis_func_floor *const _floor_P[]={
&floor0_exportbundle,
&floor1_exportbundle,
};
vorbis_func_residue *_residue_P[]={
const vorbis_func_residue *const _residue_P[]={
&residue0_exportbundle,
&residue1_exportbundle,
&residue2_exportbundle,
};
vorbis_func_mapping *_mapping_P[]={
const vorbis_func_mapping *const _mapping_P[]={
&mapping0_exportbundle,
};

View file

@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
last mod: $Id: registry.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $
********************************************************************/
@ -25,8 +25,8 @@
#define VI_RESB 3
#define VI_MAPB 1
extern vorbis_func_floor *_floor_P[];
extern vorbis_func_residue *_residue_P[];
extern vorbis_func_mapping *_mapping_P[];
extern const vorbis_func_floor *const _floor_P[];
extern const vorbis_func_residue *const _residue_P[];
extern const vorbis_func_mapping *const _mapping_P[];
#endif

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: linear scale -> dB, Bark and Mel scales
last mod: $Id: scales.h 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -21,11 +21,16 @@
#include <math.h>
#include "os.h"
#ifdef _MSC_VER
/* MS Visual Studio doesn't have C99 inline keyword. */
#define inline __inline
#endif
/* 20log10(x) */
#define VORBIS_IEEE_FLOAT32 1
#ifdef VORBIS_IEEE_FLOAT32
static float unitnorm(float x){
static inline float unitnorm(float x){
union {
ogg_uint32_t i;
float f;
@ -36,7 +41,7 @@ static float unitnorm(float x){
}
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */
static float todB(const float *x){
static inline float todB(const float *x){
union {
ogg_uint32_t i;
float f;
@ -58,9 +63,9 @@ static float unitnorm(float x){
#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
#endif
#endif
#define fromdB(x) (exp((x)*.11512925f))
#define fromdB(x) (exp((x)*.11512925f))
/* The bark scale equations are approximations, since the original
table was somewhat hand rolled. The below are chosen to have the
@ -83,4 +88,3 @@ static float unitnorm(float x){
#define fromOC(o) (exp(((o)+5.965784f)*.693147f))
#endif

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: basic shared codebook operations
last mod: $Id: sharedbook.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: sharedbook.c 17030 2010-03-25 06:52:55Z xiphmont $
********************************************************************/
@ -36,7 +36,7 @@ int _ilog(unsigned int v){
}
/* 32 bit float (not IEEE; nonnormalized mantissa +
biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
Why not IEEE? It's just not that important here. */
#define VQ_FEXP 10
@ -52,7 +52,7 @@ long _float32_pack(float val){
sign=0x80000000;
val= -val;
}
exp= floor(log(val)/log(2.f));
exp= floor(log(val)/log(2.f)+.001); //+epsilon
mant=rint(ldexp(val,(VQ_FMAN-1)-exp));
exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN;
@ -80,51 +80,64 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
long length=l[i];
if(length>0){
ogg_uint32_t entry=marker[length];
/* when we claim a node for an entry, we also claim the nodes
below it (pruning off the imagined tree that may have dangled
from it) as well as blocking the use of any nodes directly
above for leaves */
below it (pruning off the imagined tree that may have dangled
from it) as well as blocking the use of any nodes directly
above for leaves */
/* update ourself */
if(length<32 && (entry>>length)){
/* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r);
return(NULL);
/* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r);
return(NULL);
}
r[count++]=entry;
/* Look to see if the next shorter marker points to the node
above. if so, update it and repeat. */
above. if so, update it and repeat. */
{
for(j=length;j>0;j--){
if(marker[j]&1){
/* have to jump branches */
if(j==1)
marker[1]++;
else
marker[j]=marker[j-1]<<1;
break; /* invariant says next upper marker would already
have been moved if it was on the same path */
}
marker[j]++;
}
for(j=length;j>0;j--){
if(marker[j]&1){
/* have to jump branches */
if(j==1)
marker[1]++;
else
marker[j]=marker[j-1]<<1;
break; /* invariant says next upper marker would already
have been moved if it was on the same path */
}
marker[j]++;
}
}
/* prune the tree; the implicit invariant says all the longer
markers were dangling from our just-taken node. Dangle them
from our *new* node. */
markers were dangling from our just-taken node. Dangle them
from our *new* node. */
for(j=length+1;j<33;j++)
if((marker[j]>>1) == entry){
entry=marker[j];
marker[j]=marker[j-1]<<1;
}else
break;
if((marker[j]>>1) == entry){
entry=marker[j];
marker[j]=marker[j-1]<<1;
}else
break;
}else
if(sparsecount==0)count++;
}
/* sanity check the huffman tree; an underpopulated tree must be
rejected. The only exception is the one-node pseudo-nil tree,
which appears to be underpopulated because the tree doesn't
really exist; there's only one possible 'codeword' or zero bits,
but the above tree-gen code doesn't mark that. */
if(sparsecount != 1){
for(i=1;i<33;i++)
if(marker[i] & (0xffffffffUL>>(32-i))){
_ogg_free(r);
return(NULL);
}
}
/* bitreverse the words because our bitwise packer/unpacker is LSb
endian */
for(i=0,count=0;i<n;i++){
@ -136,7 +149,7 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
if(sparsecount){
if(l[i])
r[count++]=temp;
r[count++]=temp;
}else
r[count++]=temp;
}
@ -167,9 +180,9 @@ long _book_maptype1_quantvals(const static_codebook *b){
return(vals);
}else{
if(acc>b->entries){
vals--;
vals--;
}else{
vals++;
vals++;
}
}
}
@ -193,49 +206,49 @@ float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){
switch(b->maptype){
case 1:
/* most of the time, entries%dimensions == 0, but we need to be
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
float last=0.f;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
float val=b->quantlist[index];
val=fabs(val)*delta+mindel+last;
if(b->q_sequencep)last=val;
if(sparsemap)
r[sparsemap[count]*b->dim+k]=val;
else
r[count*b->dim+k]=val;
indexdiv*=quantvals;
}
count++;
}
if((sparsemap && b->lengthlist[j]) || !sparsemap){
float last=0.f;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
float val=b->quantlist[index];
val=fabs(val)*delta+mindel+last;
if(b->q_sequencep)last=val;
if(sparsemap)
r[sparsemap[count]*b->dim+k]=val;
else
r[count*b->dim+k]=val;
indexdiv*=quantvals;
}
count++;
}
}
break;
case 2:
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
float last=0.f;
for(k=0;k<b->dim;k++){
float val=b->quantlist[j*b->dim+k];
val=fabs(val)*delta+mindel+last;
if(b->q_sequencep)last=val;
if(sparsemap)
r[sparsemap[count]*b->dim+k]=val;
else
r[count*b->dim+k]=val;
}
count++;
}
if((sparsemap && b->lengthlist[j]) || !sparsemap){
float last=0.f;
for(k=0;k<b->dim;k++){
float val=b->quantlist[j*b->dim+k];
val=fabs(val)*delta+mindel+last;
if(b->q_sequencep)last=val;
if(sparsemap)
r[sparsemap[count]*b->dim+k]=val;
else
r[count*b->dim+k]=val;
}
count++;
}
}
break;
}
@ -245,34 +258,13 @@ float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){
return(NULL);
}
void vorbis_staticbook_clear(static_codebook *b){
void vorbis_staticbook_destroy(static_codebook *b){
if(b->allocedp){
if(b->quantlist)_ogg_free(b->quantlist);
if(b->lengthlist)_ogg_free(b->lengthlist);
if(b->nearest_tree){
_ogg_free(b->nearest_tree->ptr0);
_ogg_free(b->nearest_tree->ptr1);
_ogg_free(b->nearest_tree->p);
_ogg_free(b->nearest_tree->q);
memset(b->nearest_tree,0,sizeof(*b->nearest_tree));
_ogg_free(b->nearest_tree);
}
if(b->thresh_tree){
_ogg_free(b->thresh_tree->quantthresh);
_ogg_free(b->thresh_tree->quantmap);
memset(b->thresh_tree,0,sizeof(*b->thresh_tree));
_ogg_free(b->thresh_tree);
}
memset(b,0,sizeof(*b));
}
}
void vorbis_staticbook_destroy(static_codebook *b){
if(b->allocedp){
vorbis_staticbook_clear(b);
_ogg_free(b);
}
} /* otherwise, it is in static memory */
}
void vorbis_book_clear(codebook *b){
@ -296,7 +288,10 @@ int vorbis_book_init_encode(codebook *c,const static_codebook *s){
c->used_entries=s->entries;
c->dim=s->dim;
c->codelist=_make_words(s->lengthlist,s->entries,0);
c->valuelist=_book_unquantize(s,s->entries,NULL);
//c->valuelist=_book_unquantize(s,s->entries,NULL);
c->quantvals=_book_maptype1_quantvals(s);
c->minval=(int)rint(_float32_unpack(s->q_min));
c->delta=(int)rint(_float32_unpack(s->q_delta));
return(0);
}
@ -310,7 +305,7 @@ static ogg_uint32_t bitreverse(ogg_uint32_t x){
}
static int sort32a(const void *a,const void *b){
return ( **(ogg_uint32_t **)a>**(ogg_uint32_t **)b)-
return ( **(ogg_uint32_t **)a>**(ogg_uint32_t **)b)-
( **(ogg_uint32_t **)a<**(ogg_uint32_t **)b);
}
@ -319,7 +314,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
int i,j,n=0,tabn;
int *sortindex;
memset(c,0,sizeof(*c));
/* count actually used entries */
for(i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
@ -330,30 +325,30 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
c->dim=s->dim;
if(n>0){
/* two different remappings go on here.
/* two different remappings go on here.
First, we collapse the likely sparse codebook down only to
actually represented values/words. This collapsing needs to be
indexed as map-valueless books are used to encode original entry
positions as integers.
Second, we reorder all vectors, including the entry index above,
by sorted bitreversed codeword to allow treeless decode. */
/* perform sort */
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
ogg_uint32_t **codep=alloca(sizeof(*codep)*n);
if(codes==NULL)goto err_out;
for(i=0;i<n;i++){
codes[i]=bitreverse(codes[i]);
codep[i]=codes+i;
}
qsort(codep,n,sizeof(*codep),sort32a);
sortindex=alloca(n*sizeof(*sortindex));
c->codelist=_ogg_malloc(n*sizeof(*c->codelist));
/* the index is a reverse index */
@ -365,63 +360,63 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(i=0;i<n;i++)
c->codelist[sortindex[i]]=codes[i];
_ogg_free(codes);
c->valuelist=_book_unquantize(s,n,sortindex);
c->dec_index=_ogg_malloc(n*sizeof(*c->dec_index));
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_index[sortindex[n++]]=i;
c->dec_index[sortindex[n++]]=i;
c->dec_codelengths=_ogg_malloc(n*sizeof(*c->dec_codelengths));
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
if(c->dec_firsttablen<5)c->dec_firsttablen=5;
if(c->dec_firsttablen>8)c->dec_firsttablen=8;
tabn=1<<c->dec_firsttablen;
c->dec_firsttable=_ogg_calloc(tabn,sizeof(*c->dec_firsttable));
c->dec_maxlength=0;
for(i=0;i<n;i++){
if(c->dec_maxlength<c->dec_codelengths[i])
c->dec_maxlength=c->dec_codelengths[i];
c->dec_maxlength=c->dec_codelengths[i];
if(c->dec_codelengths[i]<=c->dec_firsttablen){
ogg_uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
ogg_uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
}
}
/* now fill in 'unused' entries in the firsttable with hi/lo search
hints for the non-direct-hits */
{
ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
long lo=0,hi=0;
for(i=0;i<tabn;i++){
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
/* we only actually have 15 bits per hint to play with here.
In order to overflow gracefully (nothing breaks, efficiency
just drops), encode as the difference from the extremes. */
{
unsigned long loval=lo;
unsigned long hival=n-hi;
if(loval>0x7fff)loval=0x7fff;
if(hival>0x7fff)hival=0x7fff;
c->dec_firsttable[bitreverse(word)]=
0x80000000UL | (loval<<15) | hival;
}
}
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
/* we only actually have 15 bits per hint to play with here.
In order to overflow gracefully (nothing breaks, efficiency
just drops), encode as the difference from the extremes. */
{
unsigned long loval=lo;
unsigned long hival=n-hi;
if(loval>0x7fff)loval=0x7fff;
if(hival>0x7fff)hival=0x7fff;
c->dec_firsttable[bitreverse(word)]=
0x80000000UL | (loval<<15) | hival;
}
}
}
}
}
@ -432,157 +427,6 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
return(-1);
}
static float _dist(int el,float *ref, float *b,int step){
int i;
float acc=0.f;
for(i=0;i<el;i++){
float val=(ref[i]-b[i*step]);
acc+=val*val;
}
return(acc);
}
int _best(codebook *book, float *a, int step){
encode_aux_threshmatch *tt=book->c->thresh_tree;
#if 0
encode_aux_nearestmatch *nt=book->c->nearest_tree;
encode_aux_pigeonhole *pt=book->c->pigeon_tree;
#endif
int dim=book->dim;
int k,o;
/*int savebest=-1;
float saverr;*/
/* do we have a threshhold encode hint? */
if(tt){
int index=0,i;
/* find the quant val of each scalar */
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
i=tt->threshvals>>1;
if(a[o]<tt->quantthresh[i]){
for(;i>0;i--)
if(a[o]>=tt->quantthresh[i-1])
break;
}else{
for(i++;i<tt->threshvals-1;i++)
if(a[o]<tt->quantthresh[i])break;
}
index=(index*tt->quantvals)+tt->quantmap[i];
}
/* regular lattices are easy :-) */
if(book->c->lengthlist[index]>0) /* is this unused? If so, we'll
use a decision tree after all
and fall through*/
return(index);
}
#if 0
/* do we have a pigeonhole encode hint? */
if(pt){
const static_codebook *c=book->c;
int i,besti=-1;
float best=0.f;
int entry=0;
/* dealing with sequentialness is a pain in the ass */
if(c->q_sequencep){
int pv;
long mul=1;
float qlast=0;
for(k=0,o=0;k<dim;k++,o+=step){
pv=(int)((a[o]-qlast-pt->min)/pt->del);
if(pv<0 || pv>=pt->mapentries)break;
entry+=pt->pigeonmap[pv]*mul;
mul*=pt->quantvals;
qlast+=pv*pt->del+pt->min;
}
}else{
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
int pv=(int)((a[o]-pt->min)/pt->del);
if(pv<0 || pv>=pt->mapentries)break;
entry=entry*pt->quantvals+pt->pigeonmap[pv];
}
}
/* must be within the pigeonholable range; if we quant outside (or
in an entry that we define no list for), brute force it */
if(k==dim && pt->fitlength[entry]){
/* search the abbreviated list */
long *list=pt->fitlist+pt->fitmap[entry];
for(i=0;i<pt->fitlength[entry];i++){
float this=_dist(dim,book->valuelist+list[i]*dim,a,step);
if(besti==-1 || this<best){
best=this;
besti=list[i];
}
}
return(besti);
}
}
if(nt){
/* optimized using the decision tree */
while(1){
float c=0.f;
float *p=book->valuelist+nt->p[ptr];
float *q=book->valuelist+nt->q[ptr];
for(k=0,o=0;k<dim;k++,o+=step)
c+=(p[k]-q[k])*(a[o]-(p[k]+q[k])*.5);
if(c>0.f) /* in A */
ptr= -nt->ptr0[ptr];
else /* in B */
ptr= -nt->ptr1[ptr];
if(ptr<=0)break;
}
return(-ptr);
}
#endif
/* brute force it! */
{
const static_codebook *c=book->c;
int i,besti=-1;
float best=0.f;
float *e=book->valuelist;
for(i=0;i<book->entries;i++){
if(c->lengthlist[i]>0){
float this=_dist(dim,e,a,step);
if(besti==-1 || this<best){
best=this;
besti=i;
}
}
e+=dim;
}
/*if(savebest!=-1 && savebest!=besti){
fprintf(stderr,"brute force/pigeonhole disagreement:\n"
"original:");
for(i=0;i<dim*step;i+=step)fprintf(stderr,"%g,",a[i]);
fprintf(stderr,"\n"
"pigeonhole (entry %d, err %g):",savebest,saverr);
for(i=0;i<dim;i++)fprintf(stderr,"%g,",
(book->valuelist+savebest*dim)[i]);
fprintf(stderr,"\n"
"bruteforce (entry %d, err %g):",besti,best);
for(i=0;i<dim;i++)fprintf(stderr,"%g,",
(book->valuelist+besti*dim)[i]);
fprintf(stderr,"\n");
}*/
return(besti);
}
}
long vorbis_book_codeword(codebook *book,int entry){
if(book->c) /* only use with encode; decode optimizations are
allowed to break this */
@ -625,10 +469,10 @@ static_codebook test1={
0,
0,0,0,0,
NULL,
NULL,NULL
0
};
static float *test1_result=NULL;
/* linear, full mapping, nonsequential */
static_codebook test2={
4,3,
@ -636,7 +480,7 @@ static_codebook test2={
2,
-533200896,1611661312,4,0,
full_quantlist1,
NULL,NULL
0
};
static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
@ -647,7 +491,7 @@ static_codebook test3={
2,
-533200896,1611661312,4,1,
full_quantlist1,
NULL,NULL
0
};
static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
@ -658,17 +502,17 @@ static_codebook test4={
1,
-533200896,1611661312,4,0,
partial_quantlist1,
NULL,NULL
0
};
static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3,
-3, 4,-3, 4, 4,-3, -1, 4,-3,
-3,-1,-3, 4,-1,-3, -1,-1,-3,
-3,-3, 4, 4,-3, 4, -1,-3, 4,
-3, 4, 4, 4, 4, 4, -1, 4, 4,
-3,-1, 4, 4,-1, 4, -1,-1, 4,
-3,-3,-1, 4,-3,-1, -1,-3,-1,
-3, 4,-1, 4, 4,-1, -1, 4,-1,
-3,-1,-1, 4,-1,-1, -1,-1,-1};
-3, 4,-3, 4, 4,-3, -1, 4,-3,
-3,-1,-3, 4,-1,-3, -1,-1,-3,
-3,-3, 4, 4,-3, 4, -1,-3, 4,
-3, 4, 4, 4, 4, 4, -1, 4, 4,
-3,-1, 4, 4,-1, 4, -1,-1, 4,
-3,-3,-1, 4,-3,-1, -1,-3,-1,
-3, 4,-1, 4, 4,-1, -1, 4,-1,
-3,-1,-1, 4,-1,-1, -1,-1,-1};
/* linear, algorithmic mapping, sequential */
static_codebook test5={
@ -677,17 +521,17 @@ static_codebook test5={
1,
-533200896,1611661312,4,1,
partial_quantlist1,
NULL,NULL
0
};
static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7,
-3, 1,-2, 4, 8, 5, -1, 3, 0,
-3,-4,-7, 4, 3, 0, -1,-2,-5,
-3,-6,-2, 4, 1, 5, -1,-4, 0,
-3, 1, 5, 4, 8,12, -1, 3, 7,
-3,-4, 0, 4, 3, 7, -1,-2, 2,
-3,-6,-7, 4, 1, 0, -1,-4,-5,
-3, 1, 0, 4, 8, 7, -1, 3, 2,
-3,-4,-5, 4, 3, 2, -1,-2,-3};
-3, 1,-2, 4, 8, 5, -1, 3, 0,
-3,-4,-7, 4, 3, 0, -1,-2,-5,
-3,-6,-2, 4, 1, 5, -1,-4, 0,
-3, 1, 5, 4, 8,12, -1, 3, 7,
-3,-4, 0, 4, 3, 7, -1,-2, 2,
-3,-6,-7, 4, 1, 0, -1,-4,-5,
-3, 1, 0, 4, 8, 7, -1, 3, 2,
-3,-4,-5, 4, 3, 2, -1,-2,-3};
void run_test(static_codebook *b,float *comp){
float *out=_book_unquantize(b,b->entries,NULL);
@ -701,15 +545,15 @@ void run_test(static_codebook *b,float *comp){
for(i=0;i<b->entries*b->dim;i++)
if(fabs(out[i]-comp[i])>.0001){
fprintf(stderr,"disagreement in unquantized and reference data:\n"
"position %d, %g != %g\n",i,out[i],comp[i]);
exit(1);
fprintf(stderr,"disagreement in unquantized and reference data:\n"
"position %d, %g != %g\n",i,out[i],comp[i]);
exit(1);
}
}else{
if(out){
fprintf(stderr,"_book_unquantize returned a value array: \n"
" correct result should have been NULL\n");
" correct result should have been NULL\n");
exit(1);
}
}
@ -728,7 +572,7 @@ int main(){
fprintf(stderr,"OK\nDequant test 5... ");
run_test(&test5,test5_result);
fprintf(stderr,"OK\n\n");
return(0);
}

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: *unnormalized* fft transform
last mod: $Id: smallft.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: smallft.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/
@ -94,10 +94,10 @@ static void drfti1(int n, float *wa, int *ifac){
argld=(float)ld*argh;
fi=0.f;
for (ii=2;ii<ido;ii+=2){
fi+=1.f;
arg=fi*argld;
wa[i++]=cos(arg);
wa[i++]=sin(arg);
fi+=1.f;
arg=fi*argld;
wa[i++]=cos(arg);
wa[i++]=sin(arg);
}
is+=ido;
}
@ -125,7 +125,7 @@ static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
t1+=ido;
t2+=ido;
}
if(ido<2)return;
if(ido==2)goto L105;
@ -167,12 +167,12 @@ static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
}
static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
float *wa2,float *wa3){
float *wa2,float *wa3){
static float hsqt2 = .70710678118654752f;
int i,k,t0,t1,t2,t3,t4,t5,t6;
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
t0=l1*ido;
t1=t0;
t4=t1<<1;
t2=t1+(t1<<1);
@ -244,7 +244,7 @@ static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
if(ido&1)return;
L105:
t2=(t1=t0+ido-1)+(t0<<1);
t3=ido<<2;
t4=ido;
@ -278,7 +278,7 @@ static void dradfg(int ido,int ip,int l1,int idl1,float *cc,float *c1,
int nbd;
float dcp,arg,dsp,ar1h,ar2h;
int idp2,ipp2;
arg=tpi/(float)ip;
dcp=cos(arg);
dsp=sin(arg);
@ -636,7 +636,7 @@ static void dradb2(int ido,int l1,float *cc,float *ch,float *wa1){
float ti2,tr2;
t0=l1*ido;
t1=0;
t2=0;
t3=(ido<<1)-1;
@ -747,12 +747,12 @@ static void dradb3(int ido,int l1,float *cc,float *ch,float *wa1,
}
static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
float *wa2,float *wa3){
float *wa2,float *wa3){
static float sqrt2=1.414213562373095f;
int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
t0=l1*ido;
t1=0;
t2=ido<<2;
t3=0;
@ -761,7 +761,7 @@ static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
t4=t3+t6;
t5=t1;
tr3=cc[t4-1]+cc[t4-1];
tr4=cc[t4]+cc[t4];
tr4=cc[t4]+cc[t4];
tr1=cc[t3]-cc[(t4+=t6)-1];
tr2=cc[t3]+cc[t4-1];
ch[t5]=tr2+tr3;
@ -856,7 +856,7 @@ static void dradbg(int ido,int ip,int l1,int idl1,float *cc,float *c1,
ipp2=ip;
ipph=(ip+1)>>1;
if(ido<l1)goto L103;
t1=0;
t2=0;
for(k=0;k<l1;k++){

View file

@ -5,13 +5,13 @@
* 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-2007 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: single-block PCM synthesis
last mod: $Id: synthesis.c 13293 2007-07-24 00:09:47Z xiphmont $
last mod: $Id: synthesis.c 17474 2010-09-30 03:41:41Z gmaxwell $
********************************************************************/
@ -24,13 +24,17 @@
#include "os.h"
int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
vorbis_dsp_state *vd=vb->vd;
private_state *b=vd->backend_state;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=vi->codec_setup;
oggpack_buffer *opb=&vb->opb;
vorbis_dsp_state *vd= vb ? vb->vd : 0;
private_state *b= vd ? vd->backend_state : 0;
vorbis_info *vi= vd ? vd->vi : 0;
codec_setup_info *ci= vi ? vi->codec_setup : 0;
oggpack_buffer *opb=vb ? &vb->opb : 0;
int type,mode,i;
if (!vd || !b || !vi || !ci || !opb) {
return OV_EBADPACKET;
}
/* first things first. Make sure decode is ready */
_vorbis_block_ripcord(vb);
oggpack_readinit(opb,op->packet,op->bytes);
@ -43,9 +47,15 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
/* read our mode and pre/post windowsize */
mode=oggpack_read(opb,b->modebits);
if(mode==-1)return(OV_EBADPACKET);
if(mode==-1){
return(OV_EBADPACKET);
}
vb->mode=mode;
if(!ci->mode_param[mode]){
return(OV_EBADPACKET);
}
vb->W=ci->mode_param[mode]->blockflag;
if(vb->W){
@ -53,12 +63,14 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
only for window selection */
vb->lW=oggpack_read(opb,1);
vb->nW=oggpack_read(opb,1);
if(vb->nW==-1) return(OV_EBADPACKET);
if(vb->nW==-1){
return(OV_EBADPACKET);
}
}else{
vb->lW=0;
vb->nW=0;
}
/* more setup */
vb->granulepos=op->granulepos;
vb->sequence=op->packetno;
@ -74,7 +86,7 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
type=ci->map_type[ci->mode_param[mode]->mapping];
return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]->
mapping]));
mapping]));
}
/* used to track pcm position without actually performing decode.
@ -86,7 +98,7 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
codec_setup_info *ci=vi->codec_setup;
oggpack_buffer *opb=&vb->opb;
int mode;
/* first things first. Make sure decode is ready */
_vorbis_block_ripcord(vb);
oggpack_readinit(opb,op->packet,op->bytes);
@ -100,8 +112,12 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
/* read our mode and pre/post windowsize */
mode=oggpack_read(opb,b->modebits);
if(mode==-1)return(OV_EBADPACKET);
vb->mode=mode;
if(!ci->mode_param[mode]){
return(OV_EBADPACKET);
}
vb->W=ci->mode_param[mode]->blockflag;
if(vb->W){
vb->lW=oggpack_read(opb,1);
@ -111,7 +127,7 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
vb->lW=0;
vb->nW=0;
}
/* more setup */
vb->granulepos=op->granulepos;
vb->sequence=op->packetno;
@ -128,7 +144,7 @@ long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
codec_setup_info *ci=vi->codec_setup;
oggpack_buffer opb;
int mode;
oggpack_readinit(&opb,op->packet,op->bytes);
/* Check the packet type */
@ -155,7 +171,7 @@ long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){
/* set / clear half-sample-rate mode */
codec_setup_info *ci=vi->codec_setup;
/* right now, our MDCT can't handle < 64 sample windows. */
if(ci->blocksizes[0]<=64 && flag)return -1;
ci->halfrate_flag=(flag?1:0);
@ -166,5 +182,3 @@ int vorbis_synthesis_halfrate_p(vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup;
return ci->halfrate_flag;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff