summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2000-03-29 20:08:49 +0000
committerMonty <xiphmont@xiph.org>2000-03-29 20:08:49 +0000
commit03f1ea17e5834567832d7b6530072a7b89748a6f (patch)
tree34f23213595528899377e58be0a5f2bd6c41e91a
parent9bb072dc5a541ffb4f724b9d215ba67fef01af0d (diff)
downloadlibvorbis-git-03f1ea17e5834567832d7b6530072a7b89748a6f.tar.gz
Incremental update
svn path=/branches/unlabeled-1.1.2/vorbis/; revision=287
-rw-r--r--lib/masking.h52
-rw-r--r--lib/psytune.c158
2 files changed, 94 insertions, 116 deletions
diff --git a/lib/masking.h b/lib/masking.h
index 18aeac47..7b67eb4f 100644
--- a/lib/masking.h
+++ b/lib/masking.h
@@ -12,7 +12,7 @@
********************************************************************
function: masking curve data for psychoacoustics
- last mod: $Id: masking.h,v 1.1.2.1 2000/03/29 03:49:28 xiphmont Exp $
+ last mod: $Id: masking.h,v 1.1.2.2 2000/03/29 20:08:49 xiphmont Exp $
********************************************************************/
@@ -48,7 +48,7 @@ double tone_250_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_250_80dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, 10, 17, 24, 30, 37, 41, 48, 49,
- 60, 58, 54, 53, 53, 54, 55, 57, 57, 57, 58, 59, 60, 58, 57, 58,
+ 50, 53, 54, 53, 53, 54, 55, 57, 57, 57, 58, 59, 60, 58, 57, 58,
59, 58, 57, 54, 52, 50, 49, 47, 46, 47, 46, 44, 43, 42, 41, 40,
38, 32, 27, 22, 17, 11, 6, 0};
@@ -64,75 +64,75 @@ double tone_500_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_500_80dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -22,-16,-10, 0, 10, 20, 32, 43,
- 60, 55, 52, 50, 49, 50, 52, 55, 55, 54, 51, 49, 46, 44, 44, 42,
+ 53, 52, 52, 50, 49, 50, 52, 55, 55, 54, 51, 49, 46, 44, 44, 42,
38, 34, 32, 29, 29, 28, 25, 23, 20, 16, 10, 7, 4, 2, -1, -4,
-7, -10, -15, -20, -25, -30, -35, -40};
double tone_500_100dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -7, 2, 10, 19, 27, 35, 55, 56,
- 80, 70, 60, 58, 57, 57, 59, 63, 65, 66, 62, 60, 57, 57, 58, 58,
+ 62, 61, 60, 58, 57, 57, 59, 63, 65, 66, 62, 60, 57, 57, 58, 58,
57, 56, 56, 56, 57, 57, 56, 57, 57, 54, 47, 41, 37, 28, 21, 16,
10, 3, -3, -8, -13, -18, -23, -28};
double tone_1000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -55, -45, -35, -25, -15, -5, 5, 15,
- 25, 20, 13, 8, 3, -3, -9, -15, -900,-900,-900,-900,-900,-900,-900,-900,
+-900,-900,-900,-900,-900,-900,-900,-900, -55, -40, -30, -20, -10, 0, 9, 20,
+ 27, 20, 13, 14, 13, 5, -1, -6, -11, -20, -30,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_1000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40,-30,-20,-10, 0, 10, 20, 30,
- 40, 33, 24, 23, 21, 17, 13, 8, 3, -2, -8,-13,-18, -23, -28, -33,
+-900,-900,-900,-900,-900,-900,-900, -43, -33,-23,-13, -3, 7, 17, 25, 37,
+ 42, 33, 25, 25, 23, 18, 13, 9, 4, -1, -7,-13,-18, -23, -28, -33,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_1000_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40,-30,-20,-10, 0, 10, 24, 42,
- 60, 57, 46, 41, 39, 37, 41, 46, 45, 41, 39, 35, 35, 34, 33, 31,
- 28, 22, 15, 10, 5, -2, -10, -18, -900,-900,-900,-900,-900,-900,-900,-900,
+-900,-900,-900,-900,-900,-900,-900, -35, -25,-14, -4, 6, 16, 27, 33, 50,
+ 59, 57, 47, 41, 40, 43, 47, 48, 47, 42, 39, 37, 37, 36, 35, 32,
+ 30, 27, 21, 15, 5, -2, -10, -18, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_1000_100dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -34,-24,-14, -4, 6, 16, 33, 53,
- 80, 72, 55, 49, 43, 40, 44, 54, 59, 58, 49, 43, 52, 57, 57, 58,
+-900,-900,-900,-900,-900,-900, -40, -30, -20,-10, 0, 10, 23, 33, 45, 60,
+ 70, 72, 55, 49, 43, 40, 44, 54, 59, 58, 49, 43, 52, 57, 57, 58,
58, 54, 49, 47, 42, 39, 33, 28, 20, 15, 5, 0, -5,-15,-20,-25,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_2000_40dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -3, 5, 12, 20,
- 25, 21, 15, 5, -5, -15, -25, -35, -900,-900,-900,-900,-900,-900,-900,-900,
+ 24, 21, 14, 5, -5, -15, -25, -35, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_2000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 8, 19, 32,
- 40, 35, 25, 17, 14, 13, 11, 7, 3, -2, -6, -10, -14, -20, -26, -32,
+-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 8, 19, 31,
+ 38, 34, 24, 17, 14, 13, 11, 7, 3, -2, -6, -10, -14, -20, -26, -32,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_2000_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 13, 28, 41,
- 60, 55, 43, 35, 28, 29, 35, 37, 37, 35, 31, 28, 25, 22, 19, 15,
+-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 13, 28, 40,
+ 51, 51, 43, 35, 28, 29, 35, 37, 37, 35, 31, 28, 25, 22, 19, 15,
11, 8, 6, 2, -6, -14, -22, -30, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_2000_100dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -10, 6, 25, 42, 60,
- 80, 68, 53, 43, 35, 31, 34, 47, 58, 51, 43, 45, 54, 59, 59, 56,
+ 66, 60, 53, 43, 35, 31, 34, 47, 58, 51, 43, 45, 54, 59, 59, 56,
54, 51, 40, 29, 20, 11, 2, -8, -17, -26, -35,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_4000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -70, -56, -43, -30, -17, -5, 7, 15,
- 21, 13, 5, -2, -10, -17, -24, -31, -900,-900,-900,-900,-900,-900,-900,-900,
+-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, 0, 3, 10, 18,
+ 24, 21, 14, 5, -5, -15, -25, -35, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_4000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -70, -56, -43, -30, -17, -5, 10, 27,
- 40, 33, 20, 16, 10, 5, -5, -15, -20, -25, -30, -35, -40,-900,-900,-900,
+-900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 8, 19, 31,
+ 38, 34, 24, 17, 14, 13, 11, 7, 3, -2, -6, -10, -14, -20, -26, -32,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_4000_80dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -60, -50, -40, -29, -12, 5, 19, 37,
- 60, 53, 35, 33, 36, 36, 36, 31, 27, 17, 8, 0, -8, -16, -24, -32,
+ 51, 49, 38, 32, 36, 36, 36, 31, 27, 17, 8, 0, -8, -16, -24, -32,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
double tone_4000_100dB_SL[EHMER_MAX]={
- -20, -12, -8, -4, 0, 4, 8, 11, 15, 22, 26, 28, 32, 36, 43, 54,
- 80, 70, 45, 41, 48, 49, 40, 26, 40, 40, 33, 29, 24, 19, 14, 9,
+ -20, -12, -8, -4, 0, 4, 8, 11, 15, 22, 26, 28, 32, 36, 43, 52,
+ 65, 61, 45, 41, 48, 49, 40, 26, 40, 40, 33, 29, 24, 19, 14, 9,
4, -1, -6, -11, -16, -21, -26, -31, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
diff --git a/lib/psytune.c b/lib/psytune.c
index 95b8815e..eaa60cd3 100644
--- a/lib/psytune.c
+++ b/lib/psytune.c
@@ -13,7 +13,7 @@
function: simple utility that runs audio through the psychoacoustics
without encoding
- last mod: $Id: psytune.c,v 1.1.2.1 2000/03/29 03:49:28 xiphmont Exp $
+ last mod: $Id: psytune.c,v 1.1.2.2 2000/03/29 20:08:49 xiphmont Exp $
********************************************************************/
@@ -29,44 +29,31 @@
#include "scales.h"
#include "lpc.h"
-/*
- 0 1 2 3 4 5 6 7 8 9
- 0, 100, 200, 300, 400, 510, 630, 770, 920, 1080,
-
- 10 11 12 13 14 15 16 17 18 19
- 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300,
-
- 20 21 22 23 24 25 26 Bark
- 6400, 7700, 9500, 12000, 15500, 20500, 27000 Hz */
-
static vorbis_info_psy _psy_set0={
- /* ATH */
- { 70, 25, 15, 11, 9, 8, 7.5, 7, 7, 7,
- 6, 4, 2, 0, -3, -5, -6, -6,-4.5, 2.5,
- 11, 18, 21, 17, 25, 80,120},
- /* master attenuation */
- 120.,
-
- /* mask1 attenuation proportion */
- { .7, .75, .80, .83, .84, .85, .85, .85, .85, .85,
- .00, .00, .00, .00, .00, .00, .00, .00, .00, .00,
- /* .85, .85, .85, .85, .00, .00, .00, .00, .00, .00,*/
- .00, .00, .00, .00, .00, .00, .00},
- /* mask1 slope */
- {-40, -24, -12, -8., -4., -4, -4, -4, -4, -4,
- -99, -99, -99, -99, -99,-99,-99,-99,-99,-99,
- -99,-99,-99,-99,-99,-99,-99},
-
- /* mask2 attenuation proportion */
- { .60, .60, .60, .60, .55, .55, .50, .50, .50, .50,
- .50, .50, .50, .50, .50, .50, .50, .50, .50, .55,
- .60, .65, .66, .67, .68, .7, .7},
- /* mask2 slope */
- {-40.,-24.,-11., -8., -6., -5.,-3.,-1.8, -1.8,-1.8,
- -1.8,-1.8,-1.9,-1.9,-2, -2, -2, -2,-2,-1.8,
- -1.7,-1.7,-1.6,-1.6,-1.6,-1.6,-1.6},
-
- -33., /* backward masking rolloff */
+ -130.,
+
+ {-35.,-40.,-60.,-80.,-85.},
+ {-35.,-40.,-60.,-80.,-100.},
+ {-35.,-40.,-60.,-80.,-100.},
+ {-35.,-40.,-60.,-80.,-100.},
+ {-35.,-40.,-60.,-80.,-100.},
+ {-35.,-40.,-60.,-80.,-100.},
+
+ /*{-99,-99,-99,-99,-99},
+ {-99,-99,-99,-99,-99},
+ {-99,-99,-99,-99,-99},
+ {-99,-99,-99,-99,-99},
+ {-99,-99,-99,-99,-99},
+ {-99,-99,-99,-99,-99},*/
+ {-8.,-12.,-18.,-20.,-24.},
+ {-8.,-12.,-18.,-20.,-24.},
+ {-8.,-12.,-18.,-20.,-24.},
+ {-8.,-12.,-18.,-20.,-24.},
+ {-8.,-12.,-18.,-20.,-24.},
+ {-8.,-12.,-18.,-20.,-24.},
+ -25.,-12.,
+
+ 110.,
.9998, .9997 /* attack/decay control */
};
@@ -117,14 +104,9 @@ int main(int argc,char *argv[]){
vorbis_look_psy p_look;
long i,j,k;
- drft_lookup fft_look;
lpc_lookup lpc_look;
int ath=0;
- int mask1p=0;
- int mask2p=0;
- int mask3p=0;
- int backp=0;
int decayp=0;
argv++;
@@ -137,28 +119,12 @@ int main(int argc,char *argv[]){
if(argv[0][1]=='A'){
ath=0;
}
- if(argv[0][1]=='1'){
- mask1p=0;
- }
- if(argv[0][1]=='2'){
- mask2p=0;
- }
- if(argv[0][1]=='3'){
- mask3p=0;
- }
- if(argv[0][1]=='B'){
- backp=0;
- }
if(argv[0][1]=='D'){
decayp=0;
}
if(argv[0][1]=='X'){
ath=0;
- mask1p=0;
- mask2p=0;
- mask3p=0;
decayp=0;
- backp=0;
}
}else
if(*argv[0]=='+'){
@@ -169,28 +135,12 @@ int main(int argc,char *argv[]){
if(argv[0][1]=='A'){
ath=1;
}
- if(argv[0][1]=='1'){
- mask1p=1;
- }
- if(argv[0][1]=='2'){
- mask2p=1;
- }
- if(argv[0][1]=='3'){
- mask3p=1;
- }
- if(argv[0][1]=='B'){
- backp=1;
- }
if(argv[0][1]=='D'){
decayp=1;
}
if(argv[0][1]=='X'){
ath=1;
- mask1p=1;
- mask2p=1;
- mask3p=1;
decayp=1;
- backp=1;
}
}else
framesize=atoi(argv[0]);
@@ -214,6 +164,10 @@ int main(int argc,char *argv[]){
_vp_psy_init(&p_look,&_psy_set0,framesize/2,44100);
lpc_init(&lpc_look,framesize/2,256,44100,order);
+ for(i=0;i<11;i++)
+ for(j=0;j<9;j++)
+ analysis("Pcurve",i*10+j,p_look.curves[i][j],EHMER_MAX,0,1);
+
for(j=0;j<framesize;j++)
maskwindow[j]*=maskwindow[j];
@@ -229,7 +183,6 @@ int main(int argc,char *argv[]){
fprintf(stderr,"Processing for frame size %d...\n",framesize);
while(!eos){
- long s;
long bytes=fread(buffer2,1,framesize*2,stdin);
if(bytes<framesize*2)
memset(buffer2+bytes,0,framesize*2-bytes);
@@ -256,8 +209,37 @@ int main(int argc,char *argv[]){
mdct_forward(&m_look,mask,mask);
analysis("maskmdct",frameno,mask,framesize/2,1,1);
- _vp_tone_tone_mask(&p_look,mask,mask,
- 1,1,decayp,decay[i]);
+
+ {
+ double *iter=malloc(sizeof(double)*framesize/2);
+
+ _vp_tone_tone_mask(&p_look,mask,floor,
+ ath,0,decay[i]);
+
+ memcpy(iter,mask,sizeof(double)*framesize/2);
+ for(j=0;j<framesize/2;j++)
+ if(fabs(iter[j])<fromdB(floor[j]))iter[j]=0.;
+ _vp_tone_tone_mask(&p_look,iter,iter,
+ ath,0,decay[i]);
+ for(j=0;j<framesize/2;j++)
+ floor[j]=(floor[j]+iter[j])/2.;
+
+ memcpy(iter,mask,sizeof(double)*framesize/2);
+ for(j=0;j<framesize/2;j++)
+ if(fabs(iter[j])<fromdB(floor[j]))iter[j]=0.;
+ _vp_tone_tone_mask(&p_look,iter,iter,
+ ath,0,decay[i]);
+ for(j=0;j<framesize/2;j++)
+ floor[j]=(floor[j]+iter[j])/2.;
+
+ memcpy(iter,mask,sizeof(double)*framesize/2);
+ for(j=0;j<framesize/2;j++)
+ if(fabs(iter[j])<fromdB(floor[j]))iter[j]=0.;
+ _vp_tone_tone_mask(&p_look,iter,mask,
+ ath,0,decay[i]);
+ }
+
+
analysis("mask",frameno,mask,framesize/2,1,0);
analysis("lmask",frameno,mask,framesize/2,0,0);
analysis("decay",frameno,decay[i],framesize/2,1,1);
@@ -291,29 +273,25 @@ int main(int argc,char *argv[]){
if(mask[j]==0)
val=0;
else{
- val=todB(pcm[i][j])-floor[j]-3.;
- if(val<-6.){
- val=0;
+ val=rint((todB(pcm[i][j])-floor[j]));
+ if(val<0.){
+ val=0.;
}else{
nonz+=1;
- if(val<1.5){
- val=1;
- }else{
- val=rint(val/3.)+1;
- }
+ val+=1;
+ if(pcm[i][j]<0)val= -val;
}
- if(pcm[i][j]<0)val= -val;
}
-
+
acc+=log(fabs(val)*2.+1.)/log(2);
tot++;
if(val==0)
pcm[i][j]=0.;
else{
if(val>0)
- pcm[i][j]=fromdB(val*3.+floor[j]-3.);
+ pcm[i][j]=fromdB((val-1.)+floor[j]);
else
- pcm[i][j]=-fromdB(floor[j]-val*3.-3.);
+ pcm[i][j]=-fromdB(floor[j]-(val+1.));
}
}