Don't leave the silly debugging malloc enabled
[xiph/unicode.git] / Tremor / codebook.h
blob14f65382ddd2fc579bdd1a5b85ab0499683d163a
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
14 function: basic shared codebook operations
16 ********************************************************************/
18 #ifndef _V_CODEBOOK_H_
19 #define _V_CODEBOOK_H_
21 #include "ogg.h"
23 /* This structure encapsulates huffman and VQ style encoding books; it
24 doesn't do anything specific to either.
26 valuelist/quantlist are nonNULL (and q_* significant) only if
27 there's entry->value mapping to be done.
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.
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 */
41 /* mapping ***************************************************************/
42 int maptype; /* 0=none
43 1=implicitly populated values from map column
44 2=listed arbitrary values */
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 */
52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
53 map == 2: list of dim*entries quantized entry vals
55 } static_codebook;
57 typedef struct codebook{
58 long dim; /* codebook dimensions (elements per vector) */
59 long entries; /* codebook entries */
60 long used_entries; /* populated codebook entries */
62 /* the below are ordered by bitreversed codeword and only used
63 entries are populated */
64 int binarypoint;
65 ogg_int32_t *valuelist; /* list of dim*entries actual entry values */
66 ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
68 int *dec_index;
69 char *dec_codelengths;
70 ogg_uint32_t *dec_firsttable;
71 int dec_firsttablen;
72 int dec_maxlength;
74 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
75 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
77 } codebook;
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);
83 extern void vorbis_book_clear(codebook *b);
84 extern long _book_maptype1_quantvals(const static_codebook *b);
86 extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
88 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
89 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
90 oggpack_buffer *b,int n,int point);
91 extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
92 oggpack_buffer *b,int n,int point);
93 extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
94 oggpack_buffer *b,int n,int point);
95 extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
96 long off,int ch,
97 oggpack_buffer *b,int n,int point);
99 extern int _ilog(unsigned int v);
102 #endif