examples/SFExamples/oggvorbiscodec/src/tremor/codebook.h

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
00004  *                                                                  *
00005  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00006  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00007  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00008  *                                                                  *
00009  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
00010  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
00011  *                                                                  *
00012  ********************************************************************
00013 
00014  function: basic shared codebook operations
00015 
00016  ********************************************************************/
00017 
00018 #ifndef _V_CODEBOOK_H_
00019 #define _V_CODEBOOK_H_
00020 
00021 #include "ogg.h"
00022 
00023 /* This structure encapsulates huffman and VQ style encoding books; it
00024    doesn't do anything specific to either.
00025 
00026    valuelist/quantlist are nonNULL (and q_* significant) only if
00027    there's entry->value mapping to be done.
00028 
00029    If encode-side mapping must be done (and thus the entry needs to be
00030    hunted), the auxiliary encode pointer will point to a decision
00031    tree.  This is true of both VQ and huffman, but is mostly useful
00032    with VQ.
00033 
00034 */
00035 
00036 typedef struct static_codebook{
00037   long   dim;            /* codebook dimensions (elements per vector) */
00038   long   entries;        /* codebook entries */
00039   long  *lengthlist;     /* codeword lengths in bits */
00040 
00041   /* mapping ***************************************************************/
00042   int    maptype;        /* 0=none
00043                             1=implicitly populated values from map column
00044                             2=listed arbitrary values */
00045 
00046   /* The below does a linear, single monotonic sequence mapping. */
00047   long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
00048   long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
00049   int      q_quant;     /* bits: 0 < quant <= 16 */
00050   int      q_sequencep; /* bitflag */
00051 
00052   long     *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map
00053                            map == 2: list of dim*entries quantized entry vals
00054                         */
00055 } static_codebook;
00056 
00057 typedef struct codebook{
00058   long dim;           /* codebook dimensions (elements per vector) */
00059   long entries;       /* codebook entries */
00060   long used_entries;  /* populated codebook entries */
00061 
00062   /* the below are ordered by bitreversed codeword and only used
00063      entries are populated */
00064   int           binarypoint;
00065   ogg_int32_t  *valuelist;  /* list of dim*entries actual entry values */
00066   ogg_uint32_t *codelist;   /* list of bitstream codewords for each entry */
00067 
00068   int          *dec_index;
00069   char         *dec_codelengths;
00070   ogg_uint32_t *dec_firsttable;
00071   int           dec_firsttablen;
00072   int           dec_maxlength;
00073 
00074   long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
00075   long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
00076 
00077 } codebook;
00078 
00079 extern void vorbis_staticbook_clear(static_codebook *b);
00080 extern void vorbis_staticbook_destroy(static_codebook *b);
00081 extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
00082 
00083 extern void vorbis_book_clear(codebook *b);
00084 extern long _book_maptype1_quantvals(const static_codebook *b);
00085 
00086 extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
00087 
00088 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
00089 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
00090                                      oggpack_buffer *b,int n,int point);
00091 extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
00092                                     oggpack_buffer *b,int n,int point);
00093 extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
00094                                     oggpack_buffer *b,int n,int point);
00095 extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
00096                                      long off,int ch,
00097                                     oggpack_buffer *b,int n,int point);
00098 
00099 extern int _ilog(unsigned int v);
00100 
00101 
00102 #endif

Generated by  doxygen 1.6.2