vqgen.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. function: build a VQ codebook
  13. last mod: $Id$
  14. ********************************************************************/
  15. #ifndef _VQGEN_H_
  16. #define _VQGEN_H_
  17. typedef struct vqgen{
  18. int seeded;
  19. int sorted;
  20. int it;
  21. int elements;
  22. int aux;
  23. float mindist;
  24. int centroid;
  25. /* point cache */
  26. float *pointlist;
  27. long points;
  28. long allocated;
  29. /* entries */
  30. float *entrylist;
  31. long *assigned;
  32. float *bias;
  33. long entries;
  34. float *max;
  35. float (*metric_func) (struct vqgen *v,float *entry,float *point);
  36. float *(*weight_func) (struct vqgen *v,float *point);
  37. FILE *asciipoints;
  38. } vqgen;
  39. typedef struct {
  40. long min; /* packed 24 bit float */
  41. long delta; /* packed 24 bit float */
  42. int quant; /* 0 < quant <= 16 */
  43. int sequencep; /* bitflag */
  44. } quant_meta;
  45. static inline float *_point(vqgen *v,long ptr){
  46. return v->pointlist+((v->elements+v->aux)*ptr);
  47. }
  48. static inline float *_aux(vqgen *v,long ptr){
  49. return _point(v,ptr)+v->aux;
  50. }
  51. static inline float *_now(vqgen *v,long ptr){
  52. return v->entrylist+(v->elements*ptr);
  53. }
  54. extern void vqgen_init(vqgen *v,
  55. int elements,int aux,int entries,float mindist,
  56. float (*metric)(vqgen *,float *, float *),
  57. float *(*weight)(vqgen *,float *),int centroid);
  58. extern void vqgen_addpoint(vqgen *v, float *p,float *aux);
  59. extern float vqgen_iterate(vqgen *v,int biasp);
  60. extern void vqgen_unquantize(vqgen *v,quant_meta *q);
  61. extern void vqgen_quantize(vqgen *v,quant_meta *q);
  62. extern void vqgen_cellmetric(vqgen *v);
  63. #endif