Incremental updates
authorMonty <xiphmont@xiph.org>
Sat, 22 Jan 2000 10:40:41 +0000 (10:40 +0000)
committerMonty <xiphmont@xiph.org>
Sat, 22 Jan 2000 10:40:41 +0000 (10:40 +0000)
Backends has to be here to have static mode initializers

Monty

svn path=/trunk/vorbis/; revision=239

include/vorbis/backends.h [new file with mode: 0644]
include/vorbis/book/lsp20_0.vqh
include/vorbis/book/lsp32_0.vqh
include/vorbis/codebook.h
include/vorbis/codec.h
include/vorbis/internal.h

diff --git a/include/vorbis/backends.h b/include/vorbis/backends.h
new file mode 100644 (file)
index 0000000..7147f0a
--- /dev/null
@@ -0,0 +1,150 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
+ * PLEASE READ THESE TERMS DISTRIBUTING.                            *
+ *                                                                  *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
+ * http://www.xiph.org/                                             *
+ *                                                                  *
+ ********************************************************************
+
+ function: libvorbis backend and mapping structures; needed for 
+           static mode headers
+ last mod: $Id: backends.h,v 1.1 2000/01/22 10:40:36 xiphmont Exp $
+
+ ********************************************************************/
+
+/* this is exposed up here because we need it for static modes.
+   Lookups for each backend aren't exposed because there's no reason
+   to do so */
+
+#ifndef _vorbis_time_backend_h_
+#define _vorbis_time_backend_h_
+
+/* this would all be simpler/shorter with templates, but.... */
+/* mode setup ******************************************************/
+typedef struct {
+  int blockflag;
+  int windowtype;
+  int transformtype;
+  int mapping;
+} vorbis_info_mode;
+
+/* Transform backend generic *************************************/
+typedef void vorbis_look_transform;
+
+typedef struct{
+  void (*forward)(vorbis_look_transform *,double *in,double *out);
+  void (*inverse)(vorbis_look_transform *,double *in,double *out);
+} vorbis_func_transform;
+
+/* Time backend generic ******************************************/
+
+typedef void vorbis_info_time;
+typedef void vorbis_look_time;
+
+typedef struct{
+  void              (*pack)  (vorbis_info_time *,oggpack_buffer *);
+  vorbis_info_time *(*unpack)(oggpack_buffer *);
+  vorbis_look_time *(*look)  (vorbis_info *,vorbis_info_mode *,
+                             vorbis_info_time *);
+  void (*free_info) (vorbis_info_time *);
+  void (*free_look) (vorbis_look_time *);
+  void (*forward)   (vorbis_info *,vorbis_look_time *,double *,double *);
+  void (*inverse)   (vorbis_info *,vorbis_look_time *,double *,double *);
+} vorbis_func_time;
+
+typedef struct{
+  int dummy;
+} vorbis_info_time0;
+
+/* Floor backend generic *****************************************/
+
+typedef void vorbis_info_floor;
+typedef void vorbis_look_floor;
+
+typedef struct{
+  void               (*pack)  (vorbis_info_floor *,oggpack_buffer *);
+  vorbis_info_floor *(*unpack)(oggpack_buffer *);
+  vorbis_look_floor *(*look)  (vorbis_info *,vorbis_info_mode *,
+                              vorbis_info_floor *);
+  void (*free_info) (vorbis_info_floor *);
+  void (*free_look) (vorbis_look_floor *);
+  void (*forward)   (vorbis_info *,vorbis_look_floor *,double *,double *);
+  void (*inverse)   (vorbis_info *,vorbis_look_floor *,double *,double *);
+} vorbis_func_floor;
+
+typedef struct{
+  int   order;
+  long  rate;
+  long  barkmap;
+  int   stages;
+  int  *books;
+} vorbis_info_floor0;
+
+/* Residue backend generic *****************************************/
+typedef void vorbis_info_residue;
+typedef void vorbis_look_residue;
+
+typedef struct{
+  void                 (*pack)  (vorbis_info_residue *,oggpack_buffer *);
+  vorbis_info_residue *(*unpack)(oggpack_buffer *);
+  vorbis_look_residue *(*look)  (vorbis_info *,vorbis_info_mode *,
+                                vorbis_info_residue *);
+  void (*free_info)    (vorbis_info_residue *);
+  void (*free_look)    (vorbis_look_residue *);
+  void (*forward)      (vorbis_info *,vorbis_look_residue *,double *,double *);
+  void (*inverse)      (vorbis_info *,vorbis_look_residue *,double *,double *);
+} vorbis_func_residue;
+
+typedef struct vorbis_info_res0{
+/* block-partitioned VQ coded straight residue */
+  long  begin;
+  long  end;
+
+  /* way unfinished, just so you know while poking around CVS ;-) */
+  int   stages;
+  int  *books;
+} vorbis_info_res0;
+
+/* psychoacoustic setup ********************************************/
+typedef struct vorbis_info_psy{
+  double maskthresh[MAX_BARK];
+  double lrolldB;
+  double hrolldB;
+} vorbis_info_psy;
+
+/* Mapping backend generic *****************************************/
+typedef void vorbis_info_mapping;
+typedef void vorbis_look_mapping;
+
+typedef struct{
+  void                 (*pack)  (vorbis_info_mapping *,oggpack_buffer *);
+  vorbis_info_mapping *(*unpack)(oggpack_buffer *);
+  vorbis_look_mapping *(*look)  (vorbis_info *,vorbis_info_mode *,
+                                vorbis_info_mapping *);
+  void (*free_info)    (vorbis_info_mapping *);
+  void (*free_look)    (vorbis_look_mapping *);
+  void (*forward)      (int mode,struct vorbis_block *vb);
+  void (*inverse)      (int mode,struct vorbis_block *vb);
+} vorbis_func_residue;
+
+typedef struct vorbis_info_mapping0{
+  int    submaps;
+  int   *chmuxlist;
+  
+  int   *timesubmap;    /* [mux] */
+  int   *floorsubmap;   /* [mux] submap to floors */
+  int   *residuesubmap; /* [mux] submap to residue */
+  int   *psysubmap;     /* [mux]; encode only */
+} vorbis_info_mapping0;
+
+#endif
+
+
+
+
+
index d0df326..383719b 100644 (file)
@@ -1167,12 +1167,9 @@ static encode_aux _vq_aux_lsp20_0 = {
 
 static codebook _vq_book_lsp20_0 = {
        4, 256, 4152003, 2812515, 8, 1,
-       0,
        _vq_quantlist_lsp20_0,
-       0,
        _vq_lengthlist_lsp20_0,
-       &_vq_aux_lsp20_0,
-       0
+       &_vq_aux_lsp20_0
 };
 
 
index 3498d69..3bf6dd3 100644 (file)
@@ -1691,12 +1691,9 @@ static encode_aux _vq_aux_lsp32_0 = {
 
 static codebook _vq_book_lsp32_0 = {
        4, 256, 4089638, 2558033, 8, 1,
-       0,
        _vq_quantlist_lsp32_0,
-       0,
        _vq_lengthlist_lsp32_0,
-       &_vq_aux_lsp32_0,
-       0
+       &_vq_aux_lsp32_0
 };
 
 
index 59d3bed..e4bbfed 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: codebook types
- last mod: $Id: codebook.h,v 1.2 2000/01/12 11:34:35 xiphmont Exp $
+ last mod: $Id: codebook.h,v 1.3 2000/01/22 10:40:36 xiphmont Exp $
 
  ********************************************************************/
 
@@ -32,7 +32,7 @@
 
 */
 
-typedef struct codebook{
+typedef struct static_codebook{
   long dim;           /* codebook dimensions (elements per vector) */
   long entries;       /* codebook entries */
 
@@ -42,17 +42,12 @@ typedef struct codebook{
   int    q_quant;     /* 0 < quant <= 16 */
   int    q_sequencep; /* bitflag */
 
-  double *valuelist;  /* list of dim*entries actual entry values */
   long   *quantlist;  /* list of dim*entries quantized entry values */
 
-  /* actual codewords/lengths */
-  long   *codelist;   /* list of bitstream codewords for each entry */
   long   *lengthlist; /* codeword lengths in bits */
 
   struct encode_aux *encode_tree;
-  struct decode_aux *decode_tree;
-
-} codebook;
+} static_codebook;
 
 typedef struct encode_aux{
   /* pre-calculated partitioning tree */
@@ -71,6 +66,17 @@ typedef struct decode_aux{
   long   aux;        /* number of tree entries */
 } decode_aux;
 
+typedef struct codebook{
+  long dim;           /* codebook dimensions (elements per vector) */
+  long entries;       /* codebook entries */
+  static_codebook *c;
+
+  double *valuelist;  /* list of dim*entries actual entry values */
+  long   *codelist;   /* list of bitstream codewords for each entry */
+  struct decode_aux *decode_tree;
+
+} codebook;
+
 #define VQ_FEXP_BIAS 20 /* bias toward values smaller than 1. */
 
 #endif
index 12b7c01..0ce37f5 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.3 2000/01/20 04:43:50 xiphmont Exp $
+ last mod: $Id: codec.h,v 1.4 2000/01/22 10:40:37 xiphmont Exp $
 
  ********************************************************************/
 
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 #include "vorbis/codebook.h"
 #include "vorbis/internal.h"
+#include "vorbis/backends.h"
 
 /* vobis_info contains all the setup information specific to the
    specific compression/decompression mode in progress (eg,
@@ -60,59 +61,48 @@ typedef struct vorbis_info{
 
   long blocksizes[2];
 
-  /* unlimited user comment fields.  libvorbis writes 'libvorbis'
-     whatever vedor is set to in encode */
-  char **user_comments;
-  int    comments;
-  char  *vendor;
-
   /* modes are the primary means of supporting on-the-fly different
      blocksizes, different channel mappings (LR or mid-side),
      different residue backends, etc.  Each mode consists of a
      blocksize flag and a mapping (along with the mapping setup */
+
   int        modes;
-  int       *blockflags;
-  int       *windowtypes;
-  int       *transformtypes;
-  int       *mappingtypes;
-  void     **modelist;
-  
-  /* Codebook storage for encode and decode.  Encode side is submitted
-     by the client (and memory must be managed by the client), decode
-     side is allocated by header_in */
+  int        maps;
   int        times;
-  int       *timetypes;
-  void     **timelist;
-
   int        floors;
-  int       *floortypes;
-  void     **floorlist;
-
   int        residues;
-  int       *residuetypes;
-  void     **residuelist;
-
-  /* all books are the same generic type */
   int        books;
-  codebook **booklist;
-
-  /* here on out is encode only, not added to the header */
-  int        psys;
-  void     **psylist;
+  int        psys;     /* encode only */
+
+  vorbis_info_mode    **mode_param;
+  int                  *map_type;
+  vorbis_info_mapping **map_param;
+  int                  *time_type;
+  vorbis_info_time    **time_param;
+  int                  *floor_type;
+  vorbis_info_floor   **floor_param;
+  int                  *residue_type;
+  vorbis_info_res     **residue_param;
+  static_codebook     **book_param;
+  vorbis_info_psy     **psy_param; /* encode only */
   
-  /* for block long/sort tuning */
-  int    envelopesa;
-  double preecho_thresh;
-  double preecho_clamp;
-
-  /* local storage, only used on the encoding size.  This way the
-     application does not need to worry about freeing some packets'
-     memory and not others'.  Packet storage is always tracked */
-  char *header;
-  char *header1;
-  char *header2;
+  /* for block long/sort tuning; encode only */
+  int        envelopesa;
+  double     preecho_thresh;
+  double     preecho_clamp;
 
 } vorbis_info;
+
+/* the comments are not part of vorbis_info so that vorbis_info can be
+   static storage */
+typedef struct vorbis_comments{
+  /* unlimited user comment fields.  libvorbis writes 'libvorbis'
+     whatever vendor is set to in encode */
+  char **user_comments;
+  int    comments;
+  char  *vendor;
+
+} vorbis_comments;
  
 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
 
@@ -192,16 +182,11 @@ typedef struct {
 /* vorbis_dsp_state buffers the current vorbis audio
    analysis/synthesis state.  The DSP state belongs to a specific
    logical bitstream ****************************************************/
-
 typedef struct vorbis_dsp_state{
   int analysisp;
   vorbis_info *vi;
   int    modebits;
 
-  double *window[2][2][2]; /* windowsize, leadin, leadout */
-  envelope_lookup ve;    
-  mdct_lookup vm[2];
-
   double **pcm;
   double **pcmret;
   int      pcm_storage;
@@ -227,6 +212,22 @@ typedef struct vorbis_dsp_state{
   int64_t floor_bits;
   int64_t res_bits;
 
+  /* local lookup storage */
+  envelope_lookup         ve;    
+  double                **window[2][2][2]; /* block, leadin, leadout, type */
+  vorbis_look_transform **transform[2];    /* block, type */
+  codebook               *fullbooks;
+  /* backend lookups are tied to the mode, not the backend or naked mapping */
+  vorbis_look_mapping   **mode;
+
+  /* local storage, only used on the encoding side.  This way the
+     application does not need to worry about freeing some packets'
+     memory and not others'; packet storage is always tracked.
+     Cleared next call to a _dsp_ function */
+  char *header;
+  char *header1;
+  char *header2;
+
 } vorbis_dsp_state;
 
 /* vorbis_block is a single block of data to be processed as part of
@@ -234,6 +235,11 @@ the analysis/synthesis stream; it belongs to a specific logical
 bitstream, but is independant from other vorbis_blocks belonging to
 that logical bitstream. *************************************************/
 
+struct alloc_chain{
+  void *ptr;
+  struct alloc_chain *next;
+};
+
 typedef struct vorbis_block{
   /* necessary stream state for linking to the framing abstraction */
   double  **pcm;       /* this is a pointer into local storage */ 
@@ -251,9 +257,11 @@ typedef struct vorbis_block{
 
   /* local storage to avoid remallocing; it's up to the mapping to
      structure it */
-  double *localstore;
-  long   localtop;
-  long   localalloc;
+  double             *localstore;
+  long                localtop;
+  long                localalloc;
+  long                totaluse;
+  struct alloc_chain *reap;
 
   /* bitmetrics for the frame */
   long glue_bits;
@@ -263,10 +271,6 @@ typedef struct vorbis_block{
 
 } vorbis_block;
 
-/* internal use */
-extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
-extern void _vorbis_block_ripcord(vorbis_block *vb);
-
 /* libvorbis encodes in two abstraction layers; first we perform DSP
    and produce a packet (see docs/analysis.txt).  The packet is then
    coded into a framed OggSquish bitstream by the second layer (see
@@ -281,71 +285,70 @@ extern void _vorbis_block_ripcord(vorbis_block *vb);
 
 /* OggSquish BITSREAM PRIMITIVES: encoding **************************/
 
-extern int     ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
-extern int     ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
+extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
 
 /* OggSquish BITSREAM PRIMITIVES: decoding **************************/
 
-extern int     ogg_sync_init(ogg_sync_state *oy);
-extern int     ogg_sync_clear(ogg_sync_state *oy);
-extern int     ogg_sync_destroy(ogg_sync_state *oy);
-extern int     ogg_sync_reset(ogg_sync_state *oy);
+extern int      ogg_sync_init(ogg_sync_state *oy);
+extern int      ogg_sync_clear(ogg_sync_state *oy);
+extern int      ogg_sync_destroy(ogg_sync_state *oy);
+extern int      ogg_sync_reset(ogg_sync_state *oy);
 
-extern char   *ogg_sync_buffer(ogg_sync_state *oy, long size);
-extern int     ogg_sync_wrote(ogg_sync_state *oy, long bytes);
-extern long    ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
-extern int     ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
-extern int     ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
-extern int     ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
+extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
+extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
+extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
+extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
+extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
 
 /* OggSquish BITSREAM PRIMITIVES: general ***************************/
 
-extern int     ogg_stream_init(ogg_stream_state *os,int serialno);
-extern int     ogg_stream_clear(ogg_stream_state *os);
-extern int     ogg_stream_reset(ogg_stream_state *os,long expected_pageno);
-extern int     ogg_stream_destroy(ogg_stream_state *os);
-extern int     ogg_stream_eof(ogg_stream_state *os);
+extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
+extern int      ogg_stream_clear(ogg_stream_state *os);
+extern int      ogg_stream_reset(ogg_stream_state *os,long expected_pageno);
+extern int      ogg_stream_destroy(ogg_stream_state *os);
+extern int      ogg_stream_eof(ogg_stream_state *os);
 
-extern int     ogg_page_version(ogg_page *og);
-extern int     ogg_page_continued(ogg_page *og);
-extern int     ogg_page_bos(ogg_page *og);
-extern int     ogg_page_eos(ogg_page *og);
-extern int64_t ogg_page_frameno(ogg_page *og);
-extern int     ogg_page_serialno(ogg_page *og);
-extern int     ogg_page_pageno(ogg_page *og);
+extern int      ogg_page_version(ogg_page *og);
+extern int      ogg_page_continued(ogg_page *og);
+extern int      ogg_page_bos(ogg_page *og);
+extern int      ogg_page_eos(ogg_page *og);
+extern int64_t  ogg_page_frameno(ogg_page *og);
+extern int      ogg_page_serialno(ogg_page *og);
+extern int      ogg_page_pageno(ogg_page *og);
 
 /* Vorbis PRIMITIVES: general ***************************************/
 
-extern void vorbis_dsp_clear(vorbis_dsp_state *v);
-
-extern void vorbis_info_init(vorbis_info *vi); 
-extern void vorbis_info_clear(vorbis_info *vi); 
-extern int  vorbis_info_modeset(vorbis_info *vi, int mode); 
-extern int  vorbis_info_addcomment(vorbis_info *vi, char *comment); 
-extern int  vorbis_info_headerin(vorbis_info *vi,ogg_packet *op);
-extern int  vorbis_info_headerout(vorbis_info *vi,
-                                 ogg_packet *op,
-                                 ogg_packet *op_comm,
-                                 ogg_packet *op_code);
+extern int      vorbis_info_init(vorbis_info *vi,vorbis_comments *vc);
+extern int      vorbis_comment_init(vorbis_comments *vc);
+extern int      vorbis_comment_add(vorbis_comments *vc, char *comment); 
+extern int      vorbis_comment_clear(vorbis_comments *vc);
 
-extern int  vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
-extern int  vorbis_block_clear(vorbis_block *vb);
+extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
+extern int      vorbis_block_clear(vorbis_block *vb);
+extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
 
 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
 extern int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
-
+extern int      vorbis_analysis_headerout(vorbis_dsp_state *v,
+                                         ogg_packet *op,
+                                         ogg_packet *op_comm,
+                                         ogg_packet *op_code);
 extern double **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
 extern int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
 extern int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
 extern int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
 
 /* Vorbis PRIMITIVES: synthesis layer *******************************/
-extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
-
-extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
-extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
-extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,double ***pcm);
-extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
+extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comments *vc,
+                                         ogg_packet *op);
+
+extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
+extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
+extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,double ***pcm);
+extern int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
 
 #endif
 
index 020509f..9a7ed7c 100644 (file)
@@ -13,7 +13,7 @@
 
  function: libvorbis codec internal types.  These structures are 
            'visible', but generally uninteresting to the developer
- last mod: $Id: internal.h,v 1.2 2000/01/20 04:43:51 xiphmont Exp $
+ last mod: $Id: internal.h,v 1.3 2000/01/22 10:40:38 xiphmont Exp $
 
  ********************************************************************/
 
@@ -32,29 +32,11 @@ typedef struct {
 } mdct_lookup;
 
 typedef struct {
-  int n;
-  double *trigcache;
-  int *splitcache;
-} drft_lookup;
-
-typedef struct {
   int winlen;
   double *window;
   mdct_lookup mdct;
 } envelope_lookup;
 
-typedef struct lpclook{
-  /* en/decode lookups */
-  int *linearmap;
-  double *barknorm;
-  drft_lookup fft;
-
-  int n;
-  int ln;
-  int m;
-
-} lpc_lookup;
-
 /* structures for various internal data abstractions ********************/
 
 typedef struct {
@@ -67,6 +49,10 @@ typedef struct {
   
 } oggpack_buffer;
 
+/* internal use */
+extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
+extern void _vorbis_block_ripcord(vorbis_block *vb);
+
 #endif