Minor build fixes, integrate XMMS into the autoconfed stuff
[platform/upstream/libvorbis.git] / vq / vqgen.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: build a VQ codebook 
15  last mod: $Id: vqgen.h,v 1.8 1999/12/30 07:27:05 xiphmont Exp $
16
17  ********************************************************************/
18
19 #ifndef _VQGEN_H_
20 #define _VQGEN_H_
21
22 typedef struct vqgen{
23   int it;
24   int elements;
25   int aux;
26
27   /* point cache */
28   double *pointlist; 
29   long   points;
30   long   allocated;
31
32   /* entries */
33   double *entrylist;
34   long   *assigned;
35   double *bias;
36   long   entries;
37
38   double  (*metric_func) (struct vqgen *v,double *entry,double *point);
39   double *(*weight_func) (struct vqgen *v,double *point);
40 } vqgen;
41
42 typedef struct vqbook{
43   long dim;           /* codebook dimensions (elements per vector) */
44   long entries;       /* codebook entries */
45
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 */
50
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 */
55
56   /* auxiliary encoding/decoding information */
57   /* encode: provided pre-calculated partitioning tree */
58   /* decode: hufftree */
59   long   *ptr0;
60   long   *ptr1;
61
62   /* auxiliary encoding information. Not used in decode */
63   double *n;         /* decision hyperplanes: sum(x_i*n_i)[0<=i<dim]=c */ 
64   double *c;
65   long   *p;
66   long   *q;
67   long   aux;
68   long   alloc;
69
70 } vqbook;
71
72 typedef struct {
73   long   min;       /* packed 24 bit float */       
74   long   delta;     /* packed 24 bit float */       
75   int    quant;     /* 0 < quant <= 16 */
76   int    sequencep; /* bitflag */
77 } quant_meta;
78
79 static inline double *_point(vqgen *v,long ptr){
80   return v->pointlist+((v->elements+v->aux)*ptr);
81 }
82
83 static inline double *_aux(vqgen *v,long ptr){
84   return _point(v,ptr)+v->aux;
85 }
86
87 static inline double *_now(vqgen *v,long ptr){
88   return v->entrylist+(v->elements*ptr);
89 }
90
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);
95
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);
101
102 extern void vqsp_book(vqgen *v,vqbook *b,long *quantlist);
103 extern int vqenc_entry(vqbook *b,double *val);
104
105 #endif
106
107
108
109
110