media/libtremor/lib/codebook.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libtremor/lib/codebook.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +/********************************************************************
     1.5 + *                                                                  *
     1.6 + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
     1.7 + *                                                                  *
     1.8 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     1.9 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
    1.10 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
    1.11 + *                                                                  *
    1.12 + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
    1.13 + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    1.14 + *                                                                  *
    1.15 + ********************************************************************
    1.16 +
    1.17 + function: basic shared codebook operations
    1.18 +
    1.19 + ********************************************************************/
    1.20 +
    1.21 +#ifndef _V_CODEBOOK_H_
    1.22 +#define _V_CODEBOOK_H_
    1.23 +
    1.24 +#include <ogg/ogg.h>
    1.25 +
    1.26 +/* This structure encapsulates huffman and VQ style encoding books; it
    1.27 +   doesn't do anything specific to either.
    1.28 +
    1.29 +   valuelist/quantlist are nonNULL (and q_* significant) only if
    1.30 +   there's entry->value mapping to be done.
    1.31 +
    1.32 +   If encode-side mapping must be done (and thus the entry needs to be
    1.33 +   hunted), the auxiliary encode pointer will point to a decision
    1.34 +   tree.  This is true of both VQ and huffman, but is mostly useful
    1.35 +   with VQ.
    1.36 +
    1.37 +*/
    1.38 +
    1.39 +typedef struct static_codebook{
    1.40 +  long   dim;            /* codebook dimensions (elements per vector) */
    1.41 +  long   entries;        /* codebook entries */
    1.42 +  long  *lengthlist;     /* codeword lengths in bits */
    1.43 +
    1.44 +  /* mapping ***************************************************************/
    1.45 +  int    maptype;        /* 0=none
    1.46 +			    1=implicitly populated values from map column 
    1.47 +			    2=listed arbitrary values */
    1.48 +
    1.49 +  /* The below does a linear, single monotonic sequence mapping. */
    1.50 +  long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
    1.51 +  long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
    1.52 +  int      q_quant;     /* bits: 0 < quant <= 16 */
    1.53 +  int      q_sequencep; /* bitflag */
    1.54 +
    1.55 +  long     *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map
    1.56 +			   map == 2: list of dim*entries quantized entry vals
    1.57 +			*/
    1.58 +} static_codebook;
    1.59 +
    1.60 +typedef struct codebook{
    1.61 +  long dim;           /* codebook dimensions (elements per vector) */
    1.62 +  long entries;       /* codebook entries */
    1.63 +  long used_entries;  /* populated codebook entries */
    1.64 +
    1.65 +  /* the below are ordered by bitreversed codeword and only used
    1.66 +     entries are populated */
    1.67 +  int           binarypoint;
    1.68 +  ogg_int32_t  *valuelist;  /* list of dim*entries actual entry values */  
    1.69 +  ogg_uint32_t *codelist;   /* list of bitstream codewords for each entry */
    1.70 +
    1.71 +  int          *dec_index;  
    1.72 +  char         *dec_codelengths;
    1.73 +  ogg_uint32_t *dec_firsttable;
    1.74 +  int           dec_firsttablen;
    1.75 +  int           dec_maxlength;
    1.76 +
    1.77 +  long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
    1.78 +  long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
    1.79 +
    1.80 +} codebook;
    1.81 +
    1.82 +extern void vorbis_staticbook_destroy(static_codebook *b);
    1.83 +extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
    1.84 +
    1.85 +extern void vorbis_book_clear(codebook *b);
    1.86 +extern long _book_maptype1_quantvals(const static_codebook *b);
    1.87 +
    1.88 +extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
    1.89 +
    1.90 +extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
    1.91 +extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 
    1.92 +				     oggpack_buffer *b,int n,int point);
    1.93 +extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, 
    1.94 +				    oggpack_buffer *b,int n,int point);
    1.95 +extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, 
    1.96 +				    oggpack_buffer *b,int n,int point);
    1.97 +extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
    1.98 +				     long off,int ch, 
    1.99 +				    oggpack_buffer *b,int n,int point);
   1.100 +
   1.101 +extern int _ilog(unsigned int v);
   1.102 +
   1.103 +
   1.104 +#endif

mercurial