Because residue codebooks use very coarse quantization, I needed to
[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.12 2000/02/21 01:13:01 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
26   int aux;
27   double mindist;
28
29   /* point cache */
30   double *pointlist; 
31   long   points;
32   long   allocated;
33
34   /* entries */
35   double *entrylist;
36   long   *assigned;
37   double *bias;
38   long   entries;
39   double *max;
40   
41
42   double  (*metric_func) (struct vqgen *v,double *entry,double *point);
43   double *(*weight_func) (struct vqgen *v,double *point);
44 } vqgen;
45
46 typedef struct {
47   long   min;       /* packed 24 bit float */       
48   long   delta;     /* packed 24 bit float */       
49   int    quant;     /* 0 < quant <= 16 */
50   int    sequencep; /* bitflag */
51 } quant_meta;
52
53 static inline double *_point(vqgen *v,long ptr){
54   return v->pointlist+((v->elements+v->aux)*ptr);
55 }
56
57 static inline double *_aux(vqgen *v,long ptr){
58   return _point(v,ptr)+v->aux;
59 }
60
61 static inline double *_now(vqgen *v,long ptr){
62   return v->entrylist+(v->elements*ptr);
63 }
64
65 extern void vqgen_init(vqgen *v,
66                        int elements,int aux,int entries,double mindist,
67                        double  (*metric)(vqgen *,double *, double *),
68                        double *(*weight)(vqgen *,double *));
69 extern void vqgen_addpoint(vqgen *v, double *p,double *aux);
70
71 extern double vqgen_iterate(vqgen *v);
72 extern void vqgen_unquantize(vqgen *v,quant_meta *q);
73 extern void vqgen_quantize(vqgen *v,quant_meta *q);
74 extern void vqgen_cellmetric(vqgen *v);
75
76 #endif
77
78
79
80
81