envelope.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-2009 *
  9. * by the Xiph.Org Foundation https://xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: PCM data envelope analysis and manipulation
  13. ********************************************************************/
  14. #ifndef _V_ENVELOPE_
  15. #define _V_ENVELOPE_
  16. #include "mdct.h"
  17. #define VE_PRE 16
  18. #define VE_WIN 4
  19. #define VE_POST 2
  20. #define VE_AMP (VE_PRE+VE_POST-1)
  21. #define VE_BANDS 7
  22. #define VE_NEARDC 15
  23. #define VE_MINSTRETCH 2 /* a bit less than short block */
  24. #define VE_MAXSTRETCH 12 /* one-third full block */
  25. typedef struct {
  26. float ampbuf[VE_AMP];
  27. int ampptr;
  28. float nearDC[VE_NEARDC];
  29. float nearDC_acc;
  30. float nearDC_partialacc;
  31. int nearptr;
  32. } envelope_filter_state;
  33. typedef struct {
  34. int begin;
  35. int end;
  36. float *window;
  37. float total;
  38. } envelope_band;
  39. typedef struct {
  40. int ch;
  41. int winlength;
  42. int searchstep;
  43. float minenergy;
  44. mdct_lookup mdct;
  45. float *mdct_win;
  46. envelope_band band[VE_BANDS];
  47. envelope_filter_state *filter;
  48. int stretch;
  49. int *mark;
  50. long storage;
  51. long current;
  52. long curmark;
  53. long cursor;
  54. } envelope_lookup;
  55. extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi);
  56. extern void _ve_envelope_clear(envelope_lookup *e);
  57. extern long _ve_envelope_search(vorbis_dsp_state *v);
  58. extern void _ve_envelope_shift(envelope_lookup *e,long shift);
  59. extern int _ve_envelope_mark(vorbis_dsp_state *v);
  60. #endif