vqgen.h 2.4 KB

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