psy.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-2001 *
  9. * by the XIPHOPHORUS Company http://www.xiph.org/ *
  10. ********************************************************************
  11. function: random psychoacoustics (not including preecho)
  12. last mod: $Id: psy.h,v 1.19.2.1 2001/03/28 03:34:12 segher Exp $
  13. ********************************************************************/
  14. #ifndef _V_PSY_H_
  15. #define _V_PSY_H_
  16. #include "smallft.h"
  17. #ifndef EHMER_MAX
  18. #define EHMER_MAX 56
  19. #endif
  20. /* psychoacoustic setup ********************************************/
  21. #define MAX_BARK 27
  22. #define P_BANDS 17
  23. #define P_LEVELS 11
  24. typedef struct vorbis_info_psy{
  25. int athp;
  26. int decayp;
  27. float ath_adjatt;
  28. float ath_maxatt;
  29. int eighth_octave_lines;
  30. /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
  31. /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */
  32. /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */
  33. int tonemaskp;
  34. float toneatt[P_BANDS][P_LEVELS];
  35. int peakattp;
  36. float peakatt[P_BANDS][P_LEVELS];
  37. int noisemaskp;
  38. float noisemaxsupp;
  39. float noisewindowlo;
  40. float noisewindowhi;
  41. int noisewindowlomin;
  42. int noisewindowhimin;
  43. float noisemedian[P_BANDS*2];
  44. float max_curve_dB;
  45. float bound_att_dB;
  46. /* decay setup */
  47. float attack_coeff;
  48. float decay_coeff;
  49. } vorbis_info_psy;
  50. typedef struct {
  51. int n;
  52. struct vorbis_info_psy *vi;
  53. float ***tonecurves;
  54. float **peakatt;
  55. float *noisemedian;
  56. int *inoisemedian;
  57. int *barknoisewindowlo;
  58. int *barknoisewindowhi;
  59. float *noiseoffset;
  60. float *ath;
  61. long *octave; /* in n.ocshift format */
  62. float *bark;
  63. long firstoc;
  64. long shiftoc;
  65. int eighth_octave_lines; /* power of two, please */
  66. int total_octave_lines;
  67. } vorbis_look_psy;
  68. extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate);
  69. extern void _vp_psy_clear(vorbis_look_psy *p);
  70. extern void *_vi_psy_dup(void *source);
  71. extern void _vi_psy_free(vorbis_info_psy *i);
  72. extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
  73. extern float _vp_compute_mask(vorbis_look_psy *p,
  74. float *fft,
  75. float *mdct,
  76. float *floor,
  77. float *decay,
  78. float prev_maxamp);
  79. extern void _vp_apply_floor(vorbis_look_psy *p,float *f,float *flr);
  80. extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
  81. #endif