psy.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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-2007 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: random psychoacoustics (not including preecho)
  13. last mod: $Id$
  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_channel_p;
  49. int normal_point_p;
  50. int normal_start;
  51. int normal_partition;
  52. double normal_thresh;
  53. } vorbis_info_psy;
  54. typedef struct{
  55. int eighth_octave_lines;
  56. /* for block long/short tuning; encode only */
  57. float preecho_thresh[VE_BANDS];
  58. float postecho_thresh[VE_BANDS];
  59. float stretch_penalty;
  60. float preecho_minenergy;
  61. float ampmax_att_per_sec;
  62. /* channel coupling config */
  63. int coupling_pkHz[PACKETBLOBS];
  64. int coupling_pointlimit[2][PACKETBLOBS];
  65. int coupling_prepointamp[PACKETBLOBS];
  66. int coupling_postpointamp[PACKETBLOBS];
  67. int sliding_lowpass[2][PACKETBLOBS];
  68. } vorbis_info_psy_global;
  69. typedef struct {
  70. float ampmax;
  71. int channels;
  72. vorbis_info_psy_global *gi;
  73. int coupling_pointlimit[2][P_NOISECURVES];
  74. } vorbis_look_psy_global;
  75. typedef struct {
  76. int n;
  77. struct vorbis_info_psy *vi;
  78. float ***tonecurves;
  79. float **noiseoffset;
  80. float *ath;
  81. long *octave; /* in n.ocshift format */
  82. long *bark;
  83. long firstoc;
  84. long shiftoc;
  85. int eighth_octave_lines; /* power of two, please */
  86. int total_octave_lines;
  87. long rate; /* cache it */
  88. float m_val; /* Masking compensation value */
  89. } vorbis_look_psy;
  90. extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
  91. vorbis_info_psy_global *gi,int n,long rate);
  92. extern void _vp_psy_clear(vorbis_look_psy *p);
  93. extern void *_vi_psy_dup(void *source);
  94. extern void _vi_psy_free(vorbis_info_psy *i);
  95. extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
  96. extern void _vp_remove_floor(vorbis_look_psy *p,
  97. float *mdct,
  98. int *icodedflr,
  99. float *residue,
  100. int sliding_lowpass);
  101. extern void _vp_noisemask(vorbis_look_psy *p,
  102. float *logmdct,
  103. float *logmask);
  104. extern void _vp_tonemask(vorbis_look_psy *p,
  105. float *logfft,
  106. float *logmask,
  107. float global_specmax,
  108. float local_specmax);
  109. extern void _vp_offset_and_mix(vorbis_look_psy *p,
  110. float *noise,
  111. float *tone,
  112. int offset_select,
  113. float *logmask,
  114. float *mdct,
  115. float *logmdct);
  116. extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
  117. extern float **_vp_quantize_couple_memo(vorbis_block *vb,
  118. vorbis_info_psy_global *g,
  119. vorbis_look_psy *p,
  120. vorbis_info_mapping0 *vi,
  121. float **mdct);
  122. extern void _vp_couple(int blobno,
  123. vorbis_info_psy_global *g,
  124. vorbis_look_psy *p,
  125. vorbis_info_mapping0 *vi,
  126. float **res,
  127. float **mag_memo,
  128. int **mag_sort,
  129. int **ifloor,
  130. int *nonzero,
  131. int sliding_lowpass);
  132. extern void _vp_noise_normalize(vorbis_look_psy *p,
  133. float *in,float *out,int *sortedindex);
  134. extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
  135. float *magnitudes,int *sortedindex);
  136. extern int **_vp_quantize_couple_sort(vorbis_block *vb,
  137. vorbis_look_psy *p,
  138. vorbis_info_mapping0 *vi,
  139. float **mags);
  140. extern void hf_reduction(vorbis_info_psy_global *g,
  141. vorbis_look_psy *p,
  142. vorbis_info_mapping0 *vi,
  143. float **mdct);
  144. #endif