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-1999 *
9 * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
10 * http://www.xiph.org/ *
12 ********************************************************************/
33 double (*metric_func) (struct vqgen *v,double *entry,double *point);
34 double *(*weight_func) (struct vqgen *v,double *point);
37 typedef struct vqbook{
38 long dim; /* codebook dimensions (elements per vector) */
39 long entries; /* codebook entries */
41 long min; /* packed 24 bit float; quant value 0 maps to minval */
42 long delta; /* packed 24 bit float; val 1 - val 0 == delta */
43 int quant; /* 0 < quant <= 16 */
44 int sequencep; /* bitflag */
46 double *valuelist; /* list of dim*entries actual entry values */
47 long *quantlist; /* list of dim*entries quantized entry values */
48 long *codelist; /* list of bitstream codewords for each entry */
49 long *lengthlist; /* codeword lengths in bits */
51 /* auxiliary encoding/decoding information */
52 /* encode: provided pre-calculated partitioning tree */
53 /* decode: hufftree */
57 /* auxiliary encoding information. Not used in decode */
58 double *n; /* decision hyperplanes: sum(x_i*n_i)[0<=i<dim]=c */
66 long min; /* packed 24 bit float */
67 long delta; /* packed 24 bit float */
68 int quant; /* 0 < quant <= 16 */
69 int sequencep; /* bitflag */
72 static inline double *_point(vqgen *v,long ptr){
73 return v->pointlist+((v->elements+v->aux)*ptr);
76 static inline double *_aux(vqgen *v,long ptr){
77 return _point(v,ptr)+v->aux;
80 static inline double *_now(vqgen *v,long ptr){
81 return v->entrylist+(v->elements*ptr);
84 extern void vqgen_init(vqgen *v,int elements,int aux,int entries,
85 double (*metric)(vqgen *,double *, double *),
86 double *(*weight)(vqgen *,double *));
87 extern void vqgen_addpoint(vqgen *v, double *p,double *aux);
89 extern double vqgen_iterate(vqgen *v);
90 extern void vqgen_unquantize(vqgen *v,quant_meta *q);
91 extern void vqgen_quantize(vqgen *v,quant_meta *q);
92 extern long float24_pack(double val);
93 extern double float24_unpack(long val);
95 extern void vqsp_book(vqgen *v,vqbook *b,long *quantlist);
96 extern int vqenc_entry(vqbook *b,double *val);