1 /********************************************************************
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. *
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/ *
12 ********************************************************************
14 function: codebook types
15 last mod: $Id: codebook.h,v 1.3 2000/01/22 10:40:36 xiphmont Exp $
17 ********************************************************************/
19 #ifndef _V_CODEBOOK_H_
20 #define _V_CODEBOOK_H_
22 /* This structure encapsulates huffman and VQ style encoding books; it
23 doesn't do anything specific to either.
25 valuelist/quantlist are nonNULL (and q_* significant) only if
26 there's entry->value mapping to be done.
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
35 typedef struct static_codebook{
36 long dim; /* codebook dimensions (elements per vector) */
37 long entries; /* codebook entries */
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 */
45 long *quantlist; /* list of dim*entries quantized entry values */
47 long *lengthlist; /* codeword lengths in bits */
49 struct encode_aux *encode_tree;
52 typedef struct encode_aux{
53 /* pre-calculated partitioning tree */
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 */
63 typedef struct decode_aux{
66 long aux; /* number of tree entries */
69 typedef struct codebook{
70 long dim; /* codebook dimensions (elements per vector) */
71 long entries; /* codebook entries */
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;
80 #define VQ_FEXP_BIAS 20 /* bias toward values smaller than 1. */