envelope.h 2.1 KB

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