[xiph-cvs] cvs commit: vorbis/lib/modes psych_44.h

Monty xiphmont at xiph.org
Fri Mar 22 19:17:36 PST 2002



xiphmont    02/03/22 19:17:35

  Modified:    examples encoder_example.c
               lib      analysis.c block.c envelope.c envelope.h mapping0.c
                        window.c
               lib/modes psych_44.h
  Log:
  new preecho was switching back to long blocks too soon

Revision  Changes    Path
1.38      +2 -2      vorbis/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/encoder_example.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- encoder_example.c	2002/02/28 04:12:47	1.37
+++ encoder_example.c	2002/03/23 03:17:33	1.38
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.37 2002/02/28 04:12:47 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.38 2002/03/23 03:17:33 xiphmont Exp $
 
  ********************************************************************/
 
@@ -97,7 +97,7 @@
   /* (quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR) */
   vorbis_info_init(&vi);
 
-  vorbis_encode_init_vbr(&vi,2,44100,.4); /* max compression */
+  vorbis_encode_init_vbr(&vi,2,44100,.3); /* max compression */
 
   /* add a comment */
   vorbis_comment_init(&vc);

<p><p>1.49      +7 -3      vorbis/lib/analysis.c

Index: analysis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/analysis.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- analysis.c	2002/01/22 08:06:06	1.48
+++ analysis.c	2002/03/23 03:17:33	1.49
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.48 2002/01/22 08:06:06 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.49 2002/03/23 03:17:33 xiphmont Exp $
 
  ********************************************************************/
 
@@ -78,7 +78,7 @@
 }
 
 /* there was no great place to put this.... */
-void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB){
+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];
@@ -96,7 +96,7 @@
         if(bark)
           fprintf(of,"%g ",toBARK(22050.f*j/n));
         else
-	  fprintf(of,"%g ",(double)j);
+	  fprintf(of,"%g ",(double)(j+off)/44100.);
         
         if(dB){
           fprintf(of,"%g\n",todB(v+j));
@@ -114,4 +114,8 @@
   if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB);
 #endif
 }
+
+
+
+
 

<p><p>1.61      +4 -10     vorbis/lib/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- block.c	2002/03/17 19:50:47	1.60
+++ block.c	2002/03/23 03:17:33	1.61
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.60 2002/03/17 19:50:47 xiphmont Exp $
+ last mod: $Id: block.c,v 1.61 2002/03/23 03:17:33 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -502,15 +502,9 @@
      regardless of actual settings in the stream */
 
   _vorbis_block_ripcord(vb);
-  if(v->W){
-    vb->lW=v->lW;
-    vb->W=v->W;
-    vb->nW=v->nW;
-  }else{
-    vb->lW=0;
-    vb->W=v->W;
-    vb->nW=0;
-  }
+  vb->lW=v->lW;
+  vb->W=v->W;
+  vb->nW=v->nW;
 
   if(v->W){
     if(!v->lW || !v->nW){

<p><p>1.43      +67 -7     vorbis/lib/envelope.c

Index: envelope.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- envelope.c	2002/03/17 19:50:47	1.42
+++ envelope.c	2002/03/23 03:17:33	1.43
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data envelope analysis 
- last mod: $Id: envelope.c,v 1.42 2002/03/17 19:50:47 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.43 2002/03/23 03:17:33 xiphmont Exp $
 
  ********************************************************************/
 
@@ -149,6 +149,7 @@
     float val=.14*buf[0]+.14*buf[1]+.72*acc[j];
     buf[0]=buf[1];buf[1]=acc[j];
     acc[j]=val;
+    filters[j].markers[pos+1]=val;
   }
 
   /* look at local min/max */
@@ -162,6 +163,8 @@
 }
 
 static int seq=0;
+static ogg_int64_t totalshift=-1024;
+
 long _ve_envelope_search(vorbis_dsp_state *v){
   vorbis_info *vi=v->vi;
   codec_setup_info *ci=vi->codec_setup;
@@ -175,18 +178,25 @@
 
   /* make sure we have enough storage to match the PCM */
   if(last>ve->storage){
-    ve->storage=last;
+    ve->storage=last+VE_DIV;
     ve->mark=_ogg_realloc(ve->mark,ve->storage*sizeof(*ve->mark));
   }
 
   for(j=first;j<last;j++){
     int ret=0;
     for(i=0;i<ve->ch;i++){
+      /* the mark delay is one searchstep because of min/max finder */
       float *pcm=v->pcm[i]+ve->searchstep*(j+1);
       ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS,j);
     }
-    /* the mark delay is one searchstep because of min/max finder */
-    ve->mark[j]=ret;
+
+    /* we assume a 'transient' occupies half a short block; this way,
+       it's contained in two short blocks, else the first block is
+       short and the second long, causing smearing */
+    ve->mark[j+VE_DIV/2]=0;
+    if(ret)
+      for(i=0;i<=VE_DIV/2;i++)
+	ve->mark[j+i]=ret;
   }
 
   ve->current=last*ve->searchstep;
@@ -206,16 +216,56 @@
       if(ve->mark[j/ve->searchstep]){
         if(j>centerW){
 
-	  ve->curmark=j;
+#if 0
+	  if(j>ve->curmark){
+	    float *marker=alloca(v->pcm_current*sizeof(*marker));
+	    int l;
+	    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(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[0].markers[l]*.01;
+	    _analysis_output_always("delL0",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[1].markers[l]*.01;
+	    _analysis_output_always("delL1",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[2].markers[l]*.01;
+	    _analysis_output_always("delL2",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[3].markers[l]*.01;
+	    _analysis_output_always("delL3",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[4].markers[l]*.01;
+	    _analysis_output_always("delR0",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[5].markers[l]*.01;
+	    _analysis_output_always("delR1",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[6].markers[l]*.01;
+	    _analysis_output_always("delR2",seq,marker,v->pcm_current,0,0,totalshift);
+	    for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[7].markers[l]*.01;
+	    _analysis_output_always("delR3",seq,marker,v->pcm_current,0,0,totalshift);
+	      
+	    seq++;
 
+	  }
+#endif
+
+	  ve->curmark=j;
+	  ve->cursor=j;
           if(j>=testW)return(1);
           return(0);
         }
       }
       j+=ve->searchstep;
-      ve->cursor=j;
     }
   }
+  ve->cursor=j;
  
   return(-1);
 }
@@ -247,16 +297,26 @@
 }
 
 void _ve_envelope_shift(envelope_lookup *e,long shift){
-  int smallsize=e->current/e->searchstep;
+  int smallsize=e->current/e->searchstep+VE_DIV/2; /* VE_DIV/2 is to
+                                                      match setting a
+                                                      mark on a region
+                                                      in
+                                                      envelope_search */
   int smallshift=shift/e->searchstep;
   int i;
 
   memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark));
+  
+  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->current-=shift;
   if(e->curmark>=0)
     e->curmark-=shift;
   e->cursor-=shift;
+  totalshift+=shift;
 }
 
 

<p><p>1.20      +3 -1      vorbis/lib/envelope.h

Index: envelope.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- envelope.h	2002/03/17 19:50:47	1.19
+++ envelope.h	2002/03/23 03:17:34	1.20
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.h,v 1.19 2002/03/17 19:50:47 xiphmont Exp $
+ last mod: $Id: envelope.h,v 1.20 2002/03/23 03:17:34 xiphmont Exp $
 
  ********************************************************************/
 
@@ -29,6 +29,8 @@
   int   ampptr;
   float delbuf[VE_CONV-1];
   float convbuf[2];
+  
+  float markers[1024];
 } envelope_filter_state;
 
 typedef struct {

<p><p>1.46      +10 -11    vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- mapping0.c	2002/02/28 04:12:48	1.45
+++ mapping0.c	2002/03/23 03:17:34	1.46
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.45 2002/02/28 04:12:48 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.46 2002/03/23 03:17:34 xiphmont Exp $
 
  ********************************************************************/
 
@@ -284,6 +284,8 @@
 
 /* no time mapping implementation for now */
 static long seq=0;
+ogg_int64_t total=0;
+
 static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
   vorbis_dsp_state      *vd=vb->vd;
   vorbis_info           *vi=vd->vi;
@@ -331,13 +333,13 @@
     float *logmask =work+n/2;*/
 
     scale_dB=todB(&scale);
-    _analysis_output("pcm",seq+i,pcm,n,0,0);
+    //_analysis_output_always("pcm",seq+i,pcm,n,0,0,total-n/2);
 
     /* window the PCM data */
     _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
     memcpy(fft,pcm,sizeof(*fft)*n);
     
-    /*_analysis_output("windowed",seq+i,pcm,n,0,0);*/
+    //_analysis_output_always("windowed",seq+i,pcm,n,0,0,total-n/2);
 
     /* transform the PCM data */
     /* only MDCT right now.... */
@@ -357,7 +359,7 @@
     if(local_ampmax[i]>0.f)local_ampmax[i]=0.f;
     if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];
 
-    _analysis_output("fft",seq+i,logfft,n/2,1,0);
+    //_analysis_output("fft",seq+i,logfft,n/2,1,0);
   }
 
   for(i=0;i<vi->channels;i++){
@@ -375,7 +377,7 @@
 
     for(j=0;j<n/2;j++)
       logmdct[j]=todB(mdct+j);
-    _analysis_output("mdct",seq+i,logmdct,n/2,1,0);
+    //_analysis_output("mdct",seq+i,logmdct,n/2,1,0);
 
 
     /* perform psychoacoustics; do masking */
@@ -387,7 +389,7 @@
                      local_ampmax[i],
                      bm->avgnoise);
 
-    _analysis_output("mask",seq+i,logmask,n/2,1,0);
+    //_analysis_output("mask",seq+i,logmask,n/2,1,0);
     /* perform floor encoding */
     nonzero[i]=look->floor_func[submap]->
       forward(vb,look->floor_look[submap],
@@ -410,7 +412,7 @@
         fprintf(stderr,"%ld ",seq+i);
         }*/
 
-    _analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
+    //_analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
       
   }
 
@@ -488,10 +490,6 @@
                           0);
     }
 
-    for(i=0;i<vi->channels;i++)
-      _analysis_output("quant",seq+i,quantized[i],n/2,1,0);
-
-  
     /* classify, by submap */
 
     for(i=0;i<info->submaps;i++){
@@ -564,6 +562,7 @@
     seq+=vi->channels;
   } 
 
+  total+=ci->blocksizes[vb->W]/4+ci->blocksizes[vb->nW]/4;
   look->lastframe=vb->sequence;
   return(0);
 }

<p><p>1.17      +28 -24    vorbis/lib/window.c

Index: window.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/window.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- window.c	2002/01/22 11:59:00	1.16
+++ window.c	2002/03/23 03:17:34	1.17
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: window functions
- last mod: $Id: window.c,v 1.16 2002/01/22 11:59:00 xiphmont Exp $
+ last mod: $Id: window.c,v 1.17 2002/03/23 03:17:34 xiphmont Exp $
 
  ********************************************************************/
 
@@ -48,28 +48,32 @@
 
 void _vorbis_apply_window(float *d,float *window[2],long *blocksizes,
                           int lW,int W,int nW){
+  lW=(W?lW:0);
+  nW=(W?nW:0);
 
-  long n=blocksizes[W];
-  long ln=blocksizes[lW];
-  long rn=blocksizes[nW];
-
-  long leftbegin=n/4-ln/4;
-  long leftend=leftbegin+ln/2;
-
-  long rightbegin=n/2+n/4-rn/4;
-  long rightend=rightbegin+rn/2;
-  
-  int i,p;
-
-  for(i=0;i<leftbegin;i++)
-    d[i]=0.f;
-
-  for(p=0;i<leftend;i++,p++)
-    d[i]*=window[lW][p];
-
-  for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
-    d[i]*=window[nW][p];
-
-  for(;i<n;i++)
-    d[i]=0.f;
+  {
+    long n=blocksizes[W];
+    long ln=blocksizes[lW];
+    long rn=blocksizes[nW];
+    
+    long leftbegin=n/4-ln/4;
+    long leftend=leftbegin+ln/2;
+    
+    long rightbegin=n/2+n/4-rn/4;
+    long rightend=rightbegin+rn/2;
+    
+    int i,p;
+    
+    for(i=0;i<leftbegin;i++)
+      d[i]=0.f;
+    
+    for(p=0;i<leftend;i++,p++)
+      d[i]*=window[lW][p];
+    
+    for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
+      d[i]*=window[nW][p];
+    
+    for(;i<n;i++)
+      d[i]=0.f;
+  }
 }

<p><p>1.9       +5 -5      vorbis/lib/modes/psych_44.h

Index: psych_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/psych_44.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- psych_44.h	2002/03/17 19:50:49	1.8
+++ psych_44.h	2002/03/23 03:17:35	1.9
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: key psychoacoustic settings for 44.1/48kHz
- last mod: $Id: psych_44.h,v 1.8 2002/03/17 19:50:49 xiphmont Exp $
+ last mod: $Id: psych_44.h,v 1.9 2002/03/23 03:17:35 xiphmont Exp $
 
  ********************************************************************/
 
@@ -23,20 +23,20 @@
   {8,   /* lines per eighth octave */
    /*{990.f,990.f,990.f,990.f}, {-990.f,-990.f,-990.f,-990.f}, -90.f,
    {0.f,0.f,0.f,0.f}, {-0.f,-0.f,-0.f,-0.f}, -90.f,*/
-   {46.f,40.f,40.f,36.f}, {-990.f,-990.f,-990.f,-990.f}, -100.f,
+   {46.f,40.f,36.f,36.f}, {-990.f,-990.f,-990.f,-990.f}, -100.f,
    -6.f, 0,
   },
   {8,   /* lines per eighth octave */
    /*{990.f,990.f,990.f,990.f}, {-990.f,-990.f,-990.f,-990.f}, -90.f,*/
-   {40.f,36.f,32.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -100.f,
+   {40.f,36.f,30.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -100.f,
    -6.f, 0,
   },
   {8,   /* lines per eighth octave */
-   {40.f,36.f,32.f,30.f}, {-60.f,-40.f,-40.f,-40.f}, -100.f,
+   {40.f,36.f,30.f,30.f}, {-60.f,-40.f,-40.f,-40.f}, -100.f,
    -6.f, 0,
   },
   {8,   /* lines per eighth octave */
-   {40.f,36.f,32.f,30.f}, {-40.f,-36.f,-32.f,-30.f}, -100.f,
+   {40.f,34.f,30.f,30.f}, {-40.f,-36.f,-32.f,-30.f}, -100.f,
    -6.f, 0,
   },
 };

<p><p><p>--- >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