Update website link in copyright headers.
[platform/upstream/libvorbis.git] / vq / vqgen.h
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7  *                                                                  *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
9  * by the Xiph.Org Foundation https://xiph.org/                     *
10  *                                                                  *
11  ********************************************************************
12
13  function: build a VQ codebook 
14
15  ********************************************************************/
16
17 #ifndef _VQGEN_H_
18 #define _VQGEN_H_
19
20 typedef struct vqgen{
21   int seeded;
22   int sorted;
23
24   int it;
25   int elements;
26
27   int aux;
28   float mindist;
29   int centroid;
30
31   /* point cache */
32   float *pointlist; 
33   long   points;
34   long   allocated;
35
36   /* entries */
37   float *entrylist;
38   long   *assigned;
39   float *bias;
40   long   entries;
41   float *max;
42   
43   float  (*metric_func) (struct vqgen *v,float *entry,float *point);
44   float *(*weight_func) (struct vqgen *v,float *point);
45
46   FILE *asciipoints;
47 } vqgen;
48
49 typedef struct {
50   long   min;       /* packed 24 bit float */       
51   long   delta;     /* packed 24 bit float */       
52   int    quant;     /* 0 < quant <= 16 */
53   int    sequencep; /* bitflag */
54 } quant_meta;
55
56 static inline float *_point(vqgen *v,long ptr){
57   return v->pointlist+((v->elements+v->aux)*ptr);
58 }
59
60 static inline float *_aux(vqgen *v,long ptr){
61   return _point(v,ptr)+v->aux;
62 }
63
64 static inline float *_now(vqgen *v,long ptr){
65   return v->entrylist+(v->elements*ptr);
66 }
67
68 extern void vqgen_init(vqgen *v,
69                        int elements,int aux,int entries,float mindist,
70                        float  (*metric)(vqgen *,float *, float *),
71                        float *(*weight)(vqgen *,float *),int centroid);
72 extern void vqgen_addpoint(vqgen *v, float *p,float *aux);
73
74 extern float vqgen_iterate(vqgen *v,int biasp);
75 extern void vqgen_unquantize(vqgen *v,quant_meta *q);
76 extern void vqgen_quantize(vqgen *v,quant_meta *q);
77 extern void vqgen_cellmetric(vqgen *v);
78
79 #endif
80
81
82
83
84