misc/libtremor/tremor/codebook.h
changeset 7849 a12155461b34
parent 7697 767d3c4153a1
equal deleted inserted replaced
7848:775a72905708 7849:a12155461b34
    18 #ifndef _V_CODEBOOK_H_
    18 #ifndef _V_CODEBOOK_H_
    19 #define _V_CODEBOOK_H_
    19 #define _V_CODEBOOK_H_
    20 
    20 
    21 #include "ogg.h"
    21 #include "ogg.h"
    22 
    22 
       
    23 /* This structure encapsulates huffman and VQ style encoding books; it
       
    24    doesn't do anything specific to either.
       
    25 
       
    26    valuelist/quantlist are nonNULL (and q_* significant) only if
       
    27    there's entry->value mapping to be done.
       
    28 
       
    29    If encode-side mapping must be done (and thus the entry needs to be
       
    30    hunted), the auxiliary encode pointer will point to a decision
       
    31    tree.  This is true of both VQ and huffman, but is mostly useful
       
    32    with VQ.
       
    33 
       
    34 */
       
    35 
       
    36 typedef struct static_codebook{
       
    37   long   dim;            /* codebook dimensions (elements per vector) */
       
    38   long   entries;        /* codebook entries */
       
    39   long  *lengthlist;     /* codeword lengths in bits */
       
    40 
       
    41   /* mapping ***************************************************************/
       
    42   int    maptype;        /* 0=none
       
    43 			    1=implicitly populated values from map column 
       
    44 			    2=listed arbitrary values */
       
    45 
       
    46   /* The below does a linear, single monotonic sequence mapping. */
       
    47   long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
       
    48   long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
       
    49   int      q_quant;     /* bits: 0 < quant <= 16 */
       
    50   int      q_sequencep; /* bitflag */
       
    51 
       
    52   long     *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map
       
    53 			   map == 2: list of dim*entries quantized entry vals
       
    54 			*/
       
    55 } static_codebook;
       
    56 
    23 typedef struct codebook{
    57 typedef struct codebook{
    24   long  dim;             /* codebook dimensions (elements per vector) */
    58   long dim;           /* codebook dimensions (elements per vector) */
    25   long  entries;         /* codebook entries */
    59   long entries;       /* codebook entries */
    26   long  used_entries;    /* populated codebook entries */
    60   long used_entries;  /* populated codebook entries */
    27 
    61 
    28   int   dec_maxlength;
    62   /* the below are ordered by bitreversed codeword and only used
    29   void *dec_table;
    63      entries are populated */
    30   int   dec_nodeb;      
    64   int           binarypoint;
    31   int   dec_leafw;      
    65   ogg_int32_t  *valuelist;  /* list of dim*entries actual entry values */  
    32   int   dec_type;        /* 0 = entry number
    66   ogg_uint32_t *codelist;   /* list of bitstream codewords for each entry */
    33 			    1 = packed vector of values
       
    34 			    2 = packed vector of column offsets, maptype 1 
       
    35 			    3 = scalar offset into value array,  maptype 2  */
       
    36 
    67 
    37   ogg_int32_t q_min;  
    68   int          *dec_index;  
    38   int         q_minp;  
    69   char         *dec_codelengths;
    39   ogg_int32_t q_del;
    70   ogg_uint32_t *dec_firsttable;
    40   int         q_delp;
    71   int           dec_firsttablen;
    41   int         q_seq;
    72   int           dec_maxlength;
    42   int         q_bits;
    73 
    43   int         q_pack;
    74   long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
    44   void       *q_val;   
    75   long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
    45 
    76 
    46 } codebook;
    77 } codebook;
    47 
    78 
       
    79 extern void vorbis_staticbook_clear(static_codebook *b);
       
    80 extern void vorbis_staticbook_destroy(static_codebook *b);
       
    81 extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
       
    82 
    48 extern void vorbis_book_clear(codebook *b);
    83 extern void vorbis_book_clear(codebook *b);
    49 extern int  vorbis_book_unpack(oggpack_buffer *b,codebook *c);
    84 extern long _book_maptype1_quantvals(const static_codebook *b);
       
    85 
       
    86 extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
    50 
    87 
    51 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
    88 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
    52 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 
    89 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 
    53 				     oggpack_buffer *b,int n,int point);
    90 				     oggpack_buffer *b,int n,int point);
    54 extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, 
    91 extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,