[xiph-cvs] cvs commit: vorbis/lib psy.c psy.h
Monty
xiphmont at xiph.org
Thu Dec 27 00:09:34 PST 2001
xiphmont 01/12/27 00:09:34
Modified: lib Tag: monty_branch_rc4 psy.c psy.h
Log:
psy_normalize_noise
Revision Changes Path
No revision
No revision
1.64.2.1 +52 -3 vorbis/lib/psy.c
Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.64
retrieving revision 1.64.2.1
diff -u -r1.64 -r1.64.2.1
--- psy.c 2001/12/22 09:40:39 1.64
+++ psy.c 2001/12/27 08:09:33 1.64.2.1
@@ -11,7 +11,7 @@
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.64 2001/12/22 09:40:39 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.64.2.1 2001/12/27 08:09:33 xiphmont Exp $
********************************************************************/
@@ -923,7 +923,7 @@
}
corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
- *mag=rint(*mag*corr*igranule)*granule;
+ *mag*=corr;
*ang=0.f;
}else{
@@ -970,7 +970,7 @@
vp_couple *part=info->couple_pass[passno].couple_pass+k;
float rqlimit=part->outofphase_requant_limit;
int flip_p=part->outofphase_redundant_flip_p;
-
+
for(;j<part->limit && j<p->n;j++){
/* partition by partition; k is our by-location partition
class counter */
@@ -1006,3 +1006,52 @@
}
}
}
+
+static int apsort(const void *a, const void *b){
+ if(fabs(**(float **)a)>fabs(**(float **)b))return -1;
+ return 1;
+}
+
+void psy_normalize_noise(vorbis_block *vb,float *pcm,int n){
+ /* sort in ascending order */
+ int i;
+ float **index=alloca(n*sizeof(*index));
+ float acc=0,qacc=0;
+
+ for(i=0;i<n;i++)index[i]=pcm+i;
+ qsort(index,n,sizeof(*index),apsort);
+
+ for(i=0;i<n;i++)acc+=fabs(pcm[i]);
+ for(i=0;i<n;i++){
+ float qval=rint(*index[i]);
+
+ if(qval!=0.f){
+ qacc+=fabs(qval);
+ }else{
+ if(fabs(*index[i])<.1f)break;
+ if(*index[i]<0){
+ qacc+=1.f;
+ *index[i]= -1.;
+ }else{
+ qacc+=1.f;
+ *index[i]=1.;
+ }
+ if(qacc>acc)break;
+ }
+
+ }
+ for(;i<n;i++){
+ *index[i]=0.;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
1.27.2.1 +4 -1 vorbis/lib/psy.h
Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.27
retrieving revision 1.27.2.1
diff -u -r1.27 -r1.27.2.1
--- psy.h 2001/12/20 01:00:29 1.27
+++ psy.h 2001/12/27 08:09:33 1.27.2.1
@@ -11,7 +11,7 @@
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.27 2001/12/20 01:00:29 segher Exp $
+ last mod: $Id: psy.h,v 1.27.2.1 2001/12/27 08:09:33 xiphmont Exp $
********************************************************************/
@@ -155,7 +155,10 @@
int passno);
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
+extern void psy_normalize_noise(vorbis_block *vb,float *pcm,int n);
#endif
+
+
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list