psy.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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-2002 *
  9. * by the XIPHOPHORUS Company http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: random psychoacoustics (not including preecho)
  13. last mod: $Id: psy.h,v 1.32 2002/07/13 06:12:47 xiphmont Exp $
  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. } 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_remove_floor(vorbis_look_psy *p,
  96. float *mdct,
  97. int *icodedflr,
  98. float *residue,
  99. int sliding_lowpass);
  100. extern void _vp_noisemask(vorbis_look_psy *p,
  101. float *logmdct,
  102. float *logmask);
  103. extern void _vp_tonemask(vorbis_look_psy *p,
  104. float *logfft,
  105. float *logmask,
  106. float global_specmax,
  107. float local_specmax);
  108. extern void _vp_offset_and_mix(vorbis_look_psy *p,
  109. float *noise,
  110. float *tone,
  111. int offset_select,
  112. float *logmask);
  113. extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
  114. extern float **_vp_quantize_couple_memo(vorbis_block *vb,
  115. vorbis_info_psy_global *g,
  116. vorbis_look_psy *p,
  117. vorbis_info_mapping0 *vi,
  118. float **mdct);
  119. extern void _vp_couple(int blobno,
  120. vorbis_info_psy_global *g,
  121. vorbis_look_psy *p,
  122. vorbis_info_mapping0 *vi,
  123. float **res,
  124. float **mag_memo,
  125. int **mag_sort,
  126. int **ifloor,
  127. int *nonzero,
  128. int sliding_lowpass);
  129. extern void _vp_noise_normalize(vorbis_look_psy *p,
  130. float *in,float *out,int *sortedindex);
  131. extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
  132. float *magnitudes,int *sortedindex);
  133. extern int **_vp_quantize_couple_sort(vorbis_block *vb,
  134. vorbis_look_psy *p,
  135. vorbis_info_mapping0 *vi,
  136. float **mags);
  137. #endif