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: build a VQ codebook
15 last mod: $Id: vqgen.h,v 1.8 1999/12/30 07:27:05 xiphmont Exp $
17 ********************************************************************/
38 double (*metric_func) (struct vqgen *v,double *entry,double *point);
39 double *(*weight_func) (struct vqgen *v,double *point);
42 typedef struct vqbook{
43 long dim; /* codebook dimensions (elements per vector) */
44 long entries; /* codebook entries */
46 long min; /* packed 24 bit float; quant value 0 maps to minval */
47 long delta; /* packed 24 bit float; val 1 - val 0 == delta */
48 int quant; /* 0 < quant <= 16 */
49 int sequencep; /* bitflag */
51 double *valuelist; /* list of dim*entries actual entry values */
52 long *quantlist; /* list of dim*entries quantized entry values */
53 long *codelist; /* list of bitstream codewords for each entry */
54 long *lengthlist; /* codeword lengths in bits */
56 /* auxiliary encoding/decoding information */
57 /* encode: provided pre-calculated partitioning tree */
58 /* decode: hufftree */
62 /* auxiliary encoding information. Not used in decode */
63 double *n; /* decision hyperplanes: sum(x_i*n_i)[0<=i<dim]=c */
73 long min; /* packed 24 bit float */
74 long delta; /* packed 24 bit float */
75 int quant; /* 0 < quant <= 16 */
76 int sequencep; /* bitflag */
79 static inline double *_point(vqgen *v,long ptr){
80 return v->pointlist+((v->elements+v->aux)*ptr);
83 static inline double *_aux(vqgen *v,long ptr){
84 return _point(v,ptr)+v->aux;
87 static inline double *_now(vqgen *v,long ptr){
88 return v->entrylist+(v->elements*ptr);
91 extern void vqgen_init(vqgen *v,int elements,int aux,int entries,
92 double (*metric)(vqgen *,double *, double *),
93 double *(*weight)(vqgen *,double *));
94 extern void vqgen_addpoint(vqgen *v, double *p,double *aux);
96 extern double vqgen_iterate(vqgen *v);
97 extern void vqgen_unquantize(vqgen *v,quant_meta *q);
98 extern void vqgen_quantize(vqgen *v,quant_meta *q);
99 extern long float24_pack(double val);
100 extern double float24_unpack(long val);
102 extern void vqsp_book(vqgen *v,vqbook *b,long *quantlist);
103 extern int vqenc_entry(vqbook *b,double *val);