vqgen.h 2.3 KB

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