vqgen.h 2.4 KB

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