[xiph-cvs] cvs commit: vorbis/lib analysis.c bitrate.c block.c codec_internal.h floor0.c floor1.c iir.c info.c lookup.c mdct.c misc.c misc.h psytune.c res0.c sharedbook.c vorbisenc.c vorbisfile.c
Monty
xiphmont at xiph.org
Tue Jan 22 00:06:11 PST 2002
xiphmont 02/01/22 00:06:11
Modified: examples decoder_example.c
lib analysis.c bitrate.c block.c codec_internal.h
floor0.c floor1.c iir.c info.c lookup.c mdct.c
misc.c misc.h psytune.c res0.c sharedbook.c
vorbisenc.c vorbisfile.c
Log:
Fixed a memory management error in the new codebook code
Removed final-stage infinite shift buffer; now a no-copy
double buffer; removes another 70kB nominal from decode
with slight speed improvement (~2%)
there's still an exact-position seek bug found by seeking_example to
track down. The seek succeeds, but the position is off.
Monty
Revision Changes Path
1.25 +3 -1 vorbis/examples/decoder_example.c
Index: decoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/decoder_example.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- decoder_example.c 2001/12/19 23:13:32 1.24
+++ decoder_example.c 2002/01/22 08:06:05 1.25
@@ -11,7 +11,7 @@
********************************************************************
function: simple example decoder
- last mod: $Id: decoder_example.c,v 1.24 2001/12/19 23:13:32 segher Exp $
+ last mod: $Id: decoder_example.c,v 1.25 2002/01/22 08:06:05 xiphmont Exp $
********************************************************************/
@@ -37,6 +37,8 @@
ogg_int16_t convbuffer[4096]; /* take 8k out of the data segment, not the stack */
int convsize=4096;
+
+extern void _VDBG_dump(void);
int main(){
ogg_sync_state oy; /* sync and verify incoming physical bitstream */
<p><p>1.48 +3 -2 vorbis/lib/analysis.c
Index: analysis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/analysis.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- analysis.c 2001/12/12 09:45:24 1.47
+++ analysis.c 2002/01/22 08:06:06 1.48
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.47 2001/12/12 09:45:24 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.48 2002/01/22 08:06:06 xiphmont Exp $
********************************************************************/
@@ -24,6 +24,7 @@
#include "registry.h"
#include "scales.h"
#include "os.h"
+#include "misc.h"
int analysis_noisy=1;
<p><p>1.11 +3 -2 vorbis/lib/bitrate.c
Index: bitrate.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/bitrate.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- bitrate.c 2002/01/22 02:19:09 1.10
+++ bitrate.c 2002/01/22 08:06:06 1.11
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: bitrate tracking and management
- last mod: $Id: bitrate.c,v 1.10 2002/01/22 02:19:09 xiphmont Exp $
+ last mod: $Id: bitrate.c,v 1.11 2002/01/22 08:06:06 xiphmont Exp $
********************************************************************/
@@ -23,6 +23,7 @@
#include "vorbis/codec.h"
#include "codec_internal.h"
#include "os.h"
+#include "misc.h"
#include "bitrate.h"
<p><p>1.57 +103 -101 vorbis/lib/block.c
Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- block.c 2002/01/19 04:52:39 1.56
+++ block.c 2002/01/22 08:06:06 1.57
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.56 2002/01/19 04:52:39 xiphmont Exp $
+ last mod: $Id: block.c,v 1.57 2002/01/22 08:06:06 xiphmont Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
@@ -214,27 +214,28 @@
if(encp){ /* encode/decode differ here */
/* finish the codebooks */
- b->fullbooks=_ogg_calloc(ci->books,sizeof(*b->fullbooks));
- for(i=0;i<ci->books;i++)
- vorbis_book_init_encode(b->fullbooks+i,ci->book_param[i]);
+ 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]);
+ }
v->analysisp=1;
}else{
/* finish the codebooks */
- b->fullbooks=_ogg_calloc(ci->books,sizeof(*b->fullbooks));
- for(i=0;i<ci->books;i++){
- vorbis_book_init_decode(b->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->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;
+ }
}
}
- /* initialize the storage vectors to a decent size greater than the
- minimum */
-
- v->pcm_storage=8192; /* we'll assume later that we have
- a minimum of twice the blocksize of
- accumulated samples in analysis */
+ /* initialize the storage vectors. blocksize[1] is small for encode,
+ but the correct size for decode */
+ v->pcm_storage=ci->blocksizes[1];
v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm));
v->pcmret=_ogg_malloc(vi->channels*sizeof(*v->pcmret));
{
@@ -336,14 +337,10 @@
int maptype=ci->map_type[mapnum];
if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]);
}
- /* free codebooks */
- for(i=0;i<ci->books;i++)
- if(b && b->fullbooks)vorbis_book_clear(b->fullbooks+i);
}
if(b){
if(b->mode)_ogg_free(b->mode);
- if(b->fullbooks)_ogg_free(b->fullbooks);
/* free header, header1, header2 */
if(b->header)_ogg_free(b->header);
@@ -647,33 +644,9 @@
int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
vorbis_info *vi=v->vi;
codec_setup_info *ci=vi->codec_setup;
-
- /* Shift out any PCM that we returned previously */
- /* centerW is currently the center of the last block added */
+ int i,j;
- if(v->centerW>ci->blocksizes[1]/2 &&
- /* Quick additional hack; to avoid *alot* of shifts, use an
- oversized buffer. This increases memory usage, but doesn't make
- much difference wrt L1/L2 cache pressure. */
- v->pcm_returned>8192){
-
- /* don't shift too much; we need to have a minimum PCM buffer of
- 1/2 long block */
-
- int shiftPCM=v->centerW-ci->blocksizes[1]/2;
- shiftPCM=(v->pcm_returned<shiftPCM?v->pcm_returned:shiftPCM);
-
- v->pcm_current-=shiftPCM;
- v->centerW-=shiftPCM;
- v->pcm_returned-=shiftPCM;
-
- if(shiftPCM){
- int i;
- for(i=0;i<vi->channels;i++)
- memmove(v->pcm[i],v->pcm[i]+shiftPCM,
- v->pcm_current*sizeof(*v->pcm[i]));
- }
- }
+ if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL);
v->lW=v->W;
v->W=vb->W;
@@ -688,59 +661,90 @@
lose count */
v->sequence=vb->sequence;
-
+
{
- int sizeW=ci->blocksizes[v->W];
- int centerW=v->centerW+ci->blocksizes[v->lW]/4+sizeW/4;
- int beginW=centerW-sizeW/2;
- int endW=beginW+sizeW;
- int beginSl;
- int endSl;
- int i,j;
-
- /* Do we have enough PCM/mult storage for the block? */
- if(endW>v->pcm_storage){
- /* expand the storage */
- v->pcm_storage=endW+ci->blocksizes[1];
-
- for(i=0;i<vi->channels;i++)
- v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i]));
+ int n=ci->blocksizes[v->W]/2;
+ int n0=ci->blocksizes[0]/2;
+ int n1=ci->blocksizes[1]/2;
+
+ int thisCenter;
+ int prevCenter;
+
+ if(v->centerW){
+ thisCenter=n1;
+ prevCenter=0;
+ }else{
+ 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 */
+
/* overlap/add PCM */
-
- switch((int)v->W){
- case 0:
- beginSl=0;
- endSl=ci->blocksizes[0]/2;
- break;
- case 1:
- beginSl=ci->blocksizes[1]/4-ci->blocksizes[v->lW]/4;
- endSl=beginSl+ci->blocksizes[v->lW]/2;
- break;
- default:
- return(-1);
- }
-
+
for(j=0;j<vi->channels;j++){
- float *pcm=v->pcm[j]+beginW;
- float *p=vb->pcm[j];
-
/* the overlap/add section */
- for(i=beginSl;i<endSl;i++)
- pcm[i]+=p[i];
- /* the remaining section */
- for(;i<sizeW;i++)
- pcm[i]=p[i];
-
+ if(v->lW){
+ if(v->W){
+ /* large/large */
+ float *pcm=v->pcm[j]+prevCenter;
+ float *p=vb->pcm[j];
+ for(i=0;i<n1;i++)
+ pcm[i]+=p[i];
+ }else{
+ /* large/small */
+ float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
+ float *p=vb->pcm[j];
+ for(i=0;i<n0;i++)
+ pcm[i]+=p[i];
+ }
+ }else{
+ if(v->W){
+ /* small/large */
+ float *pcm=v->pcm[j]+prevCenter;
+ float *p=vb->pcm[j]+n1/2-n0/2;
+ for(i=0;i<n0;i++)
+ pcm[i]+=p[i];
+ for(;i<n1/2+n0/2;i++)
+ pcm[i]=p[i];
+ }else{
+ /* small/small */
+ float *pcm=v->pcm[j]+prevCenter;
+ float *p=vb->pcm[j];
+ for(i=0;i<n0;i++)
+ pcm[i]+=p[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];
+ }
}
-
+
+ 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=centerW;
+ 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;
+ }
/* track the frame number... This is for convenience, but also
making sure our last packet doesn't end with added padding. If
@@ -760,7 +764,7 @@
v->granulepos=vb->granulepos;
}
else{
- v->granulepos+=(centerW-v->centerW);
+ 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){
@@ -768,14 +772,15 @@
if(vb->eofflag){
/* partial last frame. Strip the extra samples off */
- centerW-=extra;
+ v->pcm_current-=extra;
}else if(vb->sequence == 1){
/* ^^^ argh, this can be 1 from seeking! */
/* partial first frame. Discard extra leading samples */
v->pcm_returned+=extra;
- if(v->pcm_returned>centerW)v->pcm_returned=centerW;
+ if(v->pcm_returned>v->pcm_current)
+ v->pcm_returned=v->pcm_current;
}
@@ -784,35 +789,32 @@
v->granulepos=vb->granulepos;
}
}
-
+
/* Update, cleanup */
-
- v->centerW=centerW;
- v->pcm_current=endW;
-
+
if(vb->eofflag)v->eofflag=1;
}
-
+
return(0);
}
/* pcm==NULL indicates we just want the pending samples, no more */
int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){
vorbis_info *vi=v->vi;
- if(v->pcm_returned>-1 && v->pcm_returned<v->centerW){
+ if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){
if(pcm){
int i;
for(i=0;i<vi->channels;i++)
v->pcmret[i]=v->pcm[i]+v->pcm_returned;
*pcm=v->pcmret;
}
- return(v->centerW-v->pcm_returned);
+ return(v->pcm_current-v->pcm_returned);
}
return(0);
}
int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){
- if(bytes && v->pcm_returned+bytes>v->centerW)return(OV_EINVAL);
+ if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL);
v->pcm_returned+=bytes;
return(0);
}
<p><p>1.13 +3 -3 vorbis/lib/codec_internal.h
Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codec_internal.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- codec_internal.h 2001/12/20 01:00:26 1.12
+++ codec_internal.h 2002/01/22 08:06:06 1.13
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.12 2001/12/20 01:00:26 segher Exp $
+ last mod: $Id: codec_internal.h,v 1.13 2002/01/22 08:06:06 xiphmont Exp $
********************************************************************/
@@ -61,7 +61,6 @@
envelope_lookup *ve; /* envelope lookup */
float **window[2][2][2]; /* block, leadin, leadout, type */
vorbis_look_transform **transform[2]; /* block, type */
- codebook *fullbooks;
vorbis_look_psy_global *psy_g_look;
/* backend lookups are tied to the mode, not the backend or naked mapping */
@@ -157,6 +156,7 @@
int residue_type[64];
vorbis_info_residue *residue_param[64];
static_codebook *book_param[256];
+ codebook *fullbooks;
vorbis_info_psy *psy_param[64]; /* encode only */
vorbis_info_psy_global psy_g_param;
<p><p>1.50 +6 -6 vorbis/lib/floor0.c
Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor0.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- floor0.c 2001/12/21 14:52:35 1.49
+++ floor0.c 2002/01/22 08:06:06 1.50
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.49 2001/12/21 14:52:35 segher Exp $
+ last mod: $Id: floor0.c,v 1.50 2002/01/22 08:06:06 xiphmont Exp $
********************************************************************/
@@ -327,7 +327,7 @@
/* the spec supports using one of a number of codebooks. Right
now, encode using this lib supports only one */
- backend_lookup_state *be=vb->vd->backend_state;
+ codec_setup_info *ci=vb->vd->vi->codec_setup;
codebook *b;
int booknum;
@@ -348,7 +348,7 @@
}else
booknum=0;
- b=be->fullbooks+info->books[booknum];
+ b=ci->fullbooks+info->books[booknum];
oggpack_write(&vb->opb,booknum,_ilog(info->numbooks));
look->bits+=_ilog(info->numbooks);
@@ -421,8 +421,8 @@
int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
- backend_lookup_state *be=vb->vd->backend_state;
- codebook *b=be->fullbooks+info->books[booknum];
+ codec_setup_info *ci=vb->vd->vi->codec_setup;
+ codebook *b=ci->fullbooks+info->books[booknum];
float last=0.f;
float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
<p><p>1.20 +5 -6 vorbis/lib/floor1.c
Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- floor1.c 2001/12/19 23:13:33 1.19
+++ floor1.c 2002/01/22 08:06:06 1.20
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.19 2001/12/19 23:13:33 segher Exp $
+ last mod: $Id: floor1.c,v 1.20 2002/01/22 08:06:06 xiphmont Exp $
********************************************************************/
@@ -647,8 +647,7 @@
int writeflag=0;
if(vb->vd->backend_state){
- books=((backend_lookup_state *)(vb->vd->backend_state))->
- fullbooks;
+ books=ci->fullbooks;
writeflag=1;
}
@@ -1025,10 +1024,10 @@
static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
vorbis_info_floor1 *info=look->vi;
+ codec_setup_info *ci=vb->vd->vi->codec_setup;
int i,j,k;
- codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
- fullbooks;
+ codebook *books=ci->fullbooks;
/* unpack wrapped/predicted values from stream */
if(oggpack_read(&vb->opb,1)==1){
<p><p>1.13 +3 -2 vorbis/lib/iir.c
Index: iir.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/iir.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- iir.c 2001/12/20 01:00:26 1.12
+++ iir.c 2002/01/22 08:06:07 1.13
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: Direct Form II IIR filters, plus some specializations
- last mod: $Id: iir.c,v 1.12 2001/12/20 01:00:26 segher Exp $
+ last mod: $Id: iir.c,v 1.13 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -23,6 +23,7 @@
#include <string.h>
#include <math.h>
#include "iir.h"
+#include "misc.h"
void IIR_init(IIR_state *s,int stages,float gain, float *A, float *B){
memset(s,0,sizeof(*s));
<p><p>1.53 +6 -2 vorbis/lib/info.c
Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/info.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- info.c 2002/01/01 00:00:32 1.52
+++ info.c 2002/01/22 08:06:07 1.53
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.52 2002/01/01 00:00:32 xiphmont Exp $
+ last mod: $Id: info.c,v 1.53 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -177,7 +177,11 @@
/* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
}
+ if(ci->fullbooks)
+ vorbis_book_clear(ci->fullbooks+i);
}
+ if(ci->fullbooks)
+ _ogg_free(ci->fullbooks);
for(i=0;i<ci->psys;i++)
_vi_psy_free(ci->psy_param[i]);
<p><p>1.9 +3 -2 vorbis/lib/lookup.c
Index: lookup.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/lookup.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- lookup.c 2001/12/20 01:00:27 1.8
+++ lookup.c 2002/01/22 08:06:07 1.9
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: lookup based functions
- last mod: $Id: lookup.c,v 1.8 2001/12/20 01:00:27 segher Exp $
+ last mod: $Id: lookup.c,v 1.9 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -19,6 +19,7 @@
#include "lookup.h"
#include "lookup_data.h"
#include "os.h"
+#include "misc.h"
#ifdef FLOAT_LOOKUP
<p><p>1.29 +3 -2 vorbis/lib/mdct.c
Index: mdct.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mdct.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- mdct.c 2001/12/21 14:52:35 1.28
+++ mdct.c 2002/01/22 08:06:07 1.29
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
- last mod: $Id: mdct.c,v 1.28 2001/12/21 14:52:35 segher Exp $
+ last mod: $Id: mdct.c,v 1.29 2002/01/22 08:06:07 xiphmont Exp $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
@@ -44,6 +44,7 @@
#include "vorbis/codec.h"
#include "mdct.h"
#include "os.h"
+#include "misc.h"
/* build lookups for trig functions; also pre-figure scaling and
some window function algebra. */
<p><p>1.7 +116 -9 vorbis/lib/misc.c
Index: misc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/misc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- misc.c 2001/12/20 01:00:29 1.6
+++ misc.c 2002/01/22 08:06:07 1.7
@@ -5,7 +5,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************/
@@ -13,29 +13,41 @@
#define HEAD_ALIGN 32
#include <pthread.h>
#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
#include "vorbis/codec.h"
#define MISC_C
#include "misc.h"
+#include <sys/time.h>
static pthread_mutex_t memlock=PTHREAD_MUTEX_INITIALIZER;
-void **pointers=NULL;
-long *insertlist=NULL; /* We can't embed this in the pointer list;
+static void **pointers=NULL;
+static long *insertlist=NULL; /* We can't embed this in the pointer list;
a pointer can have any value... */
-int ptop=0;
-int palloced=0;
-int pinsert=0;
+static char **files=NULL;
+static long *file_bytes=NULL;
+static int filecount=0;
+
+static int ptop=0;
+static int palloced=0;
+static int pinsert=0;
+
typedef struct {
char *file;
long line;
long ptr;
+ long bytes;
} head;
+
+long global_bytes=0;
+long start_time=-1;
-static void *_insert(void *ptr,char *file,long line){
+static void *_insert(void *ptr,long bytes,char *file,long line){
((head *)ptr)->file=file;
((head *)ptr)->line=line;
((head *)ptr)->ptr=pinsert;
+ ((head *)ptr)->bytes=bytes-HEAD_ALIGN;
pthread_mutex_lock(&memlock);
if(pinsert>=palloced){
@@ -55,7 +67,56 @@
pinsert=++ptop;
else
pinsert=insertlist[pinsert];
-
+
+#ifdef _VDBG_GRAPHFILE
+ {
+ FILE *out;
+ struct timeval tv;
+ static struct timezone tz;
+ int i;
+ char buffer[80];
+ gettimeofday(&tv,&tz);
+
+ for(i=0;i<filecount;i++)
+ if(!strcmp(file,files[i]))break;
+
+ if(i==filecount){
+ filecount++;
+ if(!files){
+ files=malloc(filecount*sizeof(*files));
+ file_bytes=malloc(filecount*sizeof(*file_bytes));
+ }else{
+ files=realloc(files,filecount*sizeof(*files));
+ file_bytes=realloc(file_bytes,filecount*sizeof(*file_bytes));
+ }
+ files[i]=strdup(file);
+ file_bytes[i]=0;
+ }
+
+ file_bytes[i]+=bytes-HEAD_ALIGN;
+
+ if(start_time==-1)start_time=(tv.tv_sec*1000)+(tv.tv_usec/1000);
+
+ snprintf(buffer,80,"%s%s",file,_VDBG_GRAPHFILE);
+ out=fopen(buffer,"a");
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ file_bytes[i]-(bytes-HEAD_ALIGN));
+ fprintf(out,"%ld, %ld # FILE %s LINE %ld\n",
+ -start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ file_bytes[i],file,line);
+ fclose(out);
+
+ out=fopen(_VDBG_GRAPHFILE,"a");
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ global_bytes);
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ global_bytes+(bytes-HEAD_ALIGN));
+ fclose(out);
+ }
+#endif
+
+ global_bytes+=(bytes-HEAD_ALIGN);
+
pthread_mutex_unlock(&memlock);
return(ptr+HEAD_ALIGN);
}
@@ -63,9 +124,55 @@
static void _ripremove(void *ptr){
int insert;
pthread_mutex_lock(&memlock);
+
+#ifdef _VDBG_GRAPHFILE
+ {
+ FILE *out=fopen(_VDBG_GRAPHFILE,"a");
+ struct timeval tv;
+ static struct timezone tz;
+ char buffer[80];
+ char *file =((head *)ptr)->file;
+ long bytes =((head *)ptr)->bytes;
+ int i;
+
+ gettimeofday(&tv,&tz);
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ global_bytes);
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ global_bytes-((head *)ptr)->bytes);
+ fclose(out);
+
+ for(i=0;i<filecount;i++)
+ if(!strcmp(file,files[i]))break;
+
+ snprintf(buffer,80,"%s%s",file,_VDBG_GRAPHFILE);
+ out=fopen(buffer,"a");
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ file_bytes[i]);
+ fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
+ file_bytes[i]-bytes);
+ fclose(out);
+
+ file_bytes[i]-=bytes;
+
+ }
+#endif
+
+ global_bytes-=((head *)ptr)->bytes;
+
insert=((head *)ptr)->ptr;
insertlist[insert]=pinsert;
pinsert=insert;
+
+ if(pointers[insert]==NULL){
+ fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n");
+ fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line);
+ }
+
+ if(global_bytes<0){
+ fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n");
+ }
+
pointers[insert]=NULL;
pthread_mutex_unlock(&memlock);
}
@@ -93,7 +200,7 @@
ptr=malloc(bytes);
memset(ptr,0,bytes);
}
- return _insert(ptr,file,line);
+ return _insert(ptr,bytes,file,line);
}
extern void _VDBG_free(void *ptr,char *file,long line){
<p><p>1.11 +13 -7 vorbis/lib/misc.h
Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/misc.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- misc.h 2001/12/20 01:00:29 1.10
+++ misc.h 2002/01/22 08:06:07 1.11
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: miscellaneous prototypes
- last mod: $Id: misc.h,v 1.10 2001/12/20 01:00:29 segher Exp $
+ last mod: $Id: misc.h,v 1.11 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -23,7 +23,9 @@
extern void _vorbis_block_ripcord(vorbis_block *vb);
extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB);
-#ifdef DEBUG_LEAKS
+#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);
@@ -33,11 +35,15 @@
#undef _ogg_realloc
#undef _ogg_free
-#define _ogg_malloc(x) _VDBG__ogg_malloc(NULL,(x),__FILE__,__LINE__)
-#define _ogg_calloc(x,y) _VDBG__ogg_malloc(NULL,(x)*(y),__FILE__,__LINE__)
-#define _ogg_realloc(x,y) _VDBG__ogg_malloc((x),(y),__FILE__,__LINE__)
-#define _ogg_free(x) _VDBG__ogg_free((x),__FILE__,__LINE__)
+#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__)
+#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__)
+#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__)
+#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__)
#endif
#endif
#endif
+
+
+
+
<p><p>1.19 +3 -2 vorbis/lib/psytune.c
Index: psytune.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psytune.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- psytune.c 2001/12/20 01:00:29 1.18
+++ psytune.c 2002/01/22 08:06:07 1.19
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: simple utility that runs audio through the psychoacoustics
without encoding
- last mod: $Id: psytune.c,v 1.18 2001/12/20 01:00:29 segher Exp $
+ last mod: $Id: psytune.c,v 1.19 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -24,6 +24,7 @@
#include "vorbis/codec.h"
#include "codec_internal.h"
#include "os.h"
+#include "misc.h"
#include "psy.h"
#include "mdct.h"
#include "smallft.h"
<p><p>1.45 +6 -6 vorbis/lib/res0.c
Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- res0.c 2001/12/21 15:05:30 1.44
+++ res0.c 2002/01/22 08:06:07 1.45
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.44 2001/12/21 15:05:30 segher Exp $
+ last mod: $Id: res0.c,v 1.45 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -241,7 +241,7 @@
vorbis_info_residue *vr){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look));
- backend_lookup_state *be=vd->backend_state;
+ codec_setup_info *ci=vd->vi->codec_setup;
int j,k,acc=0;
int dim;
@@ -250,8 +250,8 @@
look->map=vm->mapping;
look->parts=info->partitions;
- look->fullbooks=be->fullbooks;
- look->phrasebook=be->fullbooks+info->groupbook;
+ look->fullbooks=ci->fullbooks;
+ look->phrasebook=ci->fullbooks+info->groupbook;
dim=look->phrasebook->dim;
look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks));
@@ -263,7 +263,7 @@
look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j]));
for(k=0;k<stages;k++)
if(info->secondstages[j]&(1<<k)){
- look->partbooks[j][k]=be->fullbooks+info->booklist[acc++];
+ look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
#ifdef TRAIN_RES
look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
sizeof(***look->training_data));
<p><p>1.27 +2 -1 vorbis/lib/sharedbook.c
Index: sharedbook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/sharedbook.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- sharedbook.c 2002/01/22 02:16:40 1.26
+++ sharedbook.c 2002/01/22 08:06:07 1.27
@@ -11,7 +11,7 @@
********************************************************************
function: basic shared codebook operations
- last mod: $Id: sharedbook.c,v 1.26 2002/01/22 02:16:40 xiphmont Exp $
+ last mod: $Id: sharedbook.c,v 1.27 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
@@ -20,6 +20,7 @@
#include <string.h>
#include <ogg/ogg.h>
#include "os.h"
+#include "misc.h"
#include "vorbis/codec.h"
#include "codebook.h"
#include "scales.h"
<p><p>1.36 +2 -2 vorbis/lib/vorbisenc.c
Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- vorbisenc.c 2002/01/22 02:19:09 1.35
+++ vorbisenc.c 2002/01/22 08:06:07 1.36
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.35 2002/01/22 02:19:09 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.36 2002/01/22 08:06:07 xiphmont Exp $
********************************************************************/
<p><p>1.55 +2 -2 vorbis/lib/vorbisfile.c
Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisfile.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- vorbisfile.c 2001/12/18 22:02:25 1.54
+++ vorbisfile.c 2002/01/22 08:06:08 1.55
@@ -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-2001 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************
function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.54 2001/12/18 22:02:25 jack Exp $
+ last mod: $Id: vorbisfile.c,v 1.55 2002/01/22 08:06:08 xiphmont Exp $
********************************************************************/
<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