psy.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: random psychoacoustics (not including preecho)
  13. ********************************************************************/
  14. #ifndef _V_PSY_H_
  15. #define _V_PSY_H_
  16. #include "smallft.h"
  17. #include "backends.h"
  18. #include "envelope.h"
  19. #ifndef EHMER_MAX
  20. #define EHMER_MAX 56
  21. #endif
  22. /* psychoacoustic setup ********************************************/
  23. #define P_BANDS 17 /* 62Hz to 16kHz */
  24. #define P_LEVELS 8 /* 30dB to 100dB */
  25. #define P_LEVEL_0 30. /* 30 dB */
  26. #define P_NOISECURVES 3
  27. #define NOISE_COMPAND_LEVELS 40
  28. typedef struct vorbis_info_psy{
  29. int blockflag;
  30. float ath_adjatt;
  31. float ath_maxatt;
  32. float tone_masteratt[P_NOISECURVES];
  33. float tone_centerboost;
  34. float tone_decay;
  35. float tone_abs_limit;
  36. float toneatt[P_BANDS];
  37. int noisemaskp;
  38. float noisemaxsupp;
  39. float noisewindowlo;
  40. float noisewindowhi;
  41. int noisewindowlomin;
  42. int noisewindowhimin;
  43. int noisewindowfixed;
  44. float noiseoff[P_NOISECURVES][P_BANDS];
  45. float noisecompand[NOISE_COMPAND_LEVELS];
  46. float max_curve_dB;
  47. int normal_p;
  48. int normal_start;
  49. int normal_partition;
  50. double normal_thresh;
  51. } vorbis_info_psy;
  52. typedef struct{
  53. int eighth_octave_lines;
  54. /* for block long/short tuning; encode only */
  55. float preecho_thresh[VE_BANDS];
  56. float postecho_thresh[VE_BANDS];
  57. float stretch_penalty;
  58. float preecho_minenergy;
  59. float ampmax_att_per_sec;
  60. /* channel coupling config */
  61. int coupling_pkHz[PACKETBLOBS];
  62. int coupling_pointlimit[2][PACKETBLOBS];
  63. int coupling_prepointamp[PACKETBLOBS];
  64. int coupling_postpointamp[PACKETBLOBS];
  65. int sliding_lowpass[2][PACKETBLOBS];
  66. } vorbis_info_psy_global;
  67. typedef struct {
  68. float ampmax;
  69. int channels;
  70. vorbis_info_psy_global *gi;
  71. int coupling_pointlimit[2][P_NOISECURVES];
  72. } vorbis_look_psy_global;
  73. typedef struct {
  74. int n;
  75. struct vorbis_info_psy *vi;
  76. float ***tonecurves;
  77. float **noiseoffset;
  78. float *ath;
  79. long *octave; /* in n.ocshift format */
  80. long *bark;
  81. long firstoc;
  82. long shiftoc;
  83. int eighth_octave_lines; /* power of two, please */
  84. int total_octave_lines;
  85. long rate; /* cache it */
  86. float m_val; /* Masking compensation value */
  87. } vorbis_look_psy;
  88. extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
  89. vorbis_info_psy_global *gi,int n,long rate);
  90. extern void _vp_psy_clear(vorbis_look_psy *p);
  91. extern void *_vi_psy_dup(void *source);
  92. extern void _vi_psy_free(vorbis_info_psy *i);
  93. extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
  94. extern void _vp_noisemask(vorbis_look_psy *p,
  95. float *logmdct,
  96. float *logmask);
  97. extern void _vp_tonemask(vorbis_look_psy *p,
  98. float *logfft,
  99. float *logmask,
  100. float global_specmax,
  101. float local_specmax);
  102. extern void _vp_offset_and_mix(vorbis_look_psy *p,
  103. float *noise,
  104. float *tone,
  105. int offset_select,
  106. float *logmask,
  107. float *mdct,
  108. float *logmdct);
  109. extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
  110. extern void _vp_couple_quantize_normalize(int blobno,
  111. vorbis_info_psy_global *g,
  112. vorbis_look_psy *p,
  113. vorbis_info_mapping0 *vi,
  114. float **mdct,
  115. int **iwork,
  116. int *nonzero,
  117. int sliding_lowpass,
  118. int ch);
  119. #endif