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.13.2.2 2000/06/12 00:31:16 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. double mindist;
  25. int centroid;
  26. /* point cache */
  27. double *pointlist;
  28. long points;
  29. long allocated;
  30. /* entries */
  31. double *entrylist;
  32. long *assigned;
  33. double *bias;
  34. long entries;
  35. double *max;
  36. double (*metric_func) (struct vqgen *v,double *entry,double *point);
  37. double *(*weight_func) (struct vqgen *v,double *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 double *_point(vqgen *v,long ptr){
  47. return v->pointlist+((v->elements+v->aux)*ptr);
  48. }
  49. static inline double *_aux(vqgen *v,long ptr){
  50. return _point(v,ptr)+v->aux;
  51. }
  52. static inline double *_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,double mindist,
  57. double (*metric)(vqgen *,double *, double *),
  58. double *(*weight)(vqgen *,double *),int centroid);
  59. extern void vqgen_addpoint(vqgen *v, double *p,double *aux);
  60. extern double 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