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