e5ce99df1427deeec5a82cc45dba9d20fcf654c3
[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.14 2000/06/14 01:38:32 xiphmont Exp $
16
17  ********************************************************************/
18
19 #ifndef _VQGEN_H_
20 #define _VQGEN_H_
21
22 typedef struct vqgen{
23   int seeded;
24   int sorted;
25
26   int it;
27   int elements;
28
29   int aux;
30   double mindist;
31   int centroid;
32
33   /* point cache */
34   double *pointlist; 
35   long   points;
36   long   allocated;
37
38   /* entries */
39   double *entrylist;
40   long   *assigned;
41   double *bias;
42   long   entries;
43   double *max;
44   
45   double  (*metric_func) (struct vqgen *v,double *entry,double *point);
46   double *(*weight_func) (struct vqgen *v,double *point);
47
48   FILE *asciipoints;
49 } vqgen;
50
51 typedef struct {
52   long   min;       /* packed 24 bit float */       
53   long   delta;     /* packed 24 bit float */       
54   int    quant;     /* 0 < quant <= 16 */
55   int    sequencep; /* bitflag */
56 } quant_meta;
57
58 static inline double *_point(vqgen *v,long ptr){
59   return v->pointlist+((v->elements+v->aux)*ptr);
60 }
61
62 static inline double *_aux(vqgen *v,long ptr){
63   return _point(v,ptr)+v->aux;
64 }
65
66 static inline double *_now(vqgen *v,long ptr){
67   return v->entrylist+(v->elements*ptr);
68 }
69
70 extern void vqgen_init(vqgen *v,
71                        int elements,int aux,int entries,double mindist,
72                        double  (*metric)(vqgen *,double *, double *),
73                        double *(*weight)(vqgen *,double *),int centroid);
74 extern void vqgen_addpoint(vqgen *v, double *p,double *aux);
75
76 extern double vqgen_iterate(vqgen *v,int biasp);
77 extern void vqgen_unquantize(vqgen *v,quant_meta *q);
78 extern void vqgen_quantize(vqgen *v,quant_meta *q);
79 extern void vqgen_cellmetric(vqgen *v);
80
81 #endif
82
83
84
85
86