psy.h 4.6 KB

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