Incremental updates
[platform/upstream/libvorbis.git] / include / vorbis / codebook.h
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: codebook types
15  last mod: $Id: codebook.h,v 1.3 2000/01/22 10:40:36 xiphmont Exp $
16
17  ********************************************************************/
18
19 #ifndef _V_CODEBOOK_H_
20 #define _V_CODEBOOK_H_
21
22 /* This structure encapsulates huffman and VQ style encoding books; it
23    doesn't do anything specific to either.
24
25    valuelist/quantlist are nonNULL (and q_* significant) only if
26    there's entry->value mapping to be done.
27
28    If encode-side mapping must be done (and thus the entry needs to be
29    hunted), the auxiliary encode pointer will point to a decision
30    tree.  This is true of both VQ and huffman, but is mostly useful
31    with VQ.
32
33 */
34
35 typedef struct static_codebook{
36   long dim;           /* codebook dimensions (elements per vector) */
37   long entries;       /* codebook entries */
38
39   /* mapping */
40   long   q_min;       /* packed 24 bit float; quant value 0 maps to minval */
41   long   q_delta;     /* packed 24 bit float; val 1 - val 0 == delta */
42   int    q_quant;     /* 0 < quant <= 16 */
43   int    q_sequencep; /* bitflag */
44
45   long   *quantlist;  /* list of dim*entries quantized entry values */
46
47   long   *lengthlist; /* codeword lengths in bits */
48
49   struct encode_aux *encode_tree;
50 } static_codebook;
51
52 typedef struct encode_aux{
53   /* pre-calculated partitioning tree */
54   long   *ptr0;
55   long   *ptr1;
56
57   long   *p;         /* decision points (each is an entry) */
58   long   *q;         /* decision points (each is an entry) */
59   long   aux;        /* number of tree entries */
60   long   alloc;       
61 } encode_aux;
62
63 typedef struct decode_aux{
64   long   *ptr0;
65   long   *ptr1;
66   long   aux;        /* number of tree entries */
67 } decode_aux;
68
69 typedef struct codebook{
70   long dim;           /* codebook dimensions (elements per vector) */
71   long entries;       /* codebook entries */
72   static_codebook *c;
73
74   double *valuelist;  /* list of dim*entries actual entry values */
75   long   *codelist;   /* list of bitstream codewords for each entry */
76   struct decode_aux *decode_tree;
77
78 } codebook;
79
80 #define VQ_FEXP_BIAS 20 /* bias toward values smaller than 1. */
81
82 #endif
83
84
85
86
87