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.6 2000/07/17 12:55:35 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 */
38 long *lengthlist; /* codeword lengths in bits */
40 /* mapping ***************************************************************/
41 int maptype; /* 0=none
42 1=implicitly populated values from map column
43 2=listed arbitrary values */
45 /* The below does a linear, single monotonic sequence mapping. */
46 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
47 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
48 int q_quant; /* bits: 0 < quant <= 16 */
49 int q_sequencep; /* bitflag */
51 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
52 map == 2: list of dim*entries quantized entry vals
55 /* encode helpers ********************************************************/
56 struct encode_aux_nearestmatch *nearest_tree;
57 struct encode_aux_threshmatch *thresh_tree;
58 struct encode_aux_pigeonhole *pigeon_tree;
61 /* this structures an arbitrary trained book to quickly find the
63 typedef struct encode_aux_nearestmatch{
64 /* pre-calculated partitioning tree */
68 long *p; /* decision points (each is an entry) */
69 long *q; /* decision points (each is an entry) */
70 long aux; /* number of tree entries */
72 } encode_aux_nearestmatch;
74 /* assumes a maptype of 1; encode side only, so that's OK */
75 typedef struct encode_aux_threshmatch{
80 } encode_aux_threshmatch;
82 typedef struct encode_aux_pigeonhole{
94 } encode_aux_pigeonhole;
96 typedef struct decode_aux{
99 long aux; /* number of tree entries */
102 typedef struct codebook{
103 long dim; /* codebook dimensions (elements per vector) */
104 long entries; /* codebook entries */
105 const static_codebook *c;
107 double *valuelist; /* list of dim*entries actual entry values */
108 long *codelist; /* list of bitstream codewords for each entry */
109 struct decode_aux *decode_tree;