psy.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.25.2.2 2001/12/18 23:49:17 xiphmont Exp $
  13. ********************************************************************/
  14. #ifndef _V_PSY_H_
  15. #define _V_PSY_H_
  16. #include "smallft.h"
  17. #include "backends.h"
  18. #ifndef EHMER_MAX
  19. #define EHMER_MAX 56
  20. #endif
  21. /* psychoacoustic setup ********************************************/
  22. #define MAX_BARK 27
  23. #define P_BANDS 17
  24. #define P_LEVELS 11
  25. typedef struct vp_couple{
  26. int limit; /* sample post */
  27. int outofphase_redundant_flip_p;
  28. float outofphase_requant_limit;
  29. float amppost_point;
  30. } vp_couple;
  31. typedef struct vp_couple_pass{
  32. float granulem;
  33. float igranulem;
  34. vp_couple couple_pass[8];
  35. } vp_couple_pass;
  36. typedef struct vp_attenblock{
  37. float block[P_BANDS][P_LEVELS];
  38. } vp_attenblock;
  39. #define NOISE_COMPAND_LEVELS 40
  40. typedef struct vorbis_info_psy{
  41. float ath[27];
  42. float ath_adjatt;
  43. float ath_maxatt;
  44. float tone_masteratt;
  45. float tone_guard;
  46. float tone_abs_limit;
  47. vp_attenblock toneatt;
  48. int peakattp;
  49. int curvelimitp;
  50. vp_attenblock peakatt;
  51. int noisemaskp;
  52. float noisemaxsupp;
  53. float noisewindowlo;
  54. float noisewindowhi;
  55. int noisewindowlomin;
  56. int noisewindowhimin;
  57. int noisewindowfixed;
  58. float noiseoff[P_BANDS];
  59. float noisecompand[NOISE_COMPAND_LEVELS];
  60. float max_curve_dB;
  61. vp_couple_pass couple_pass[8];
  62. } vorbis_info_psy;
  63. typedef struct{
  64. int eighth_octave_lines;
  65. /* for block long/short tuning; encode only */
  66. float preecho_thresh[4];
  67. float postecho_thresh[4];
  68. float preecho_minenergy;
  69. float ampmax_att_per_sec;
  70. /* delay caching... how many samples to keep around prior to our
  71. current block to aid in analysis? */
  72. int delaycache;
  73. } vorbis_info_psy_global;
  74. typedef struct {
  75. float ampmax;
  76. int channels;
  77. vorbis_info_psy_global *gi;
  78. } vorbis_look_psy_global;
  79. typedef struct {
  80. int n;
  81. struct vorbis_info_psy *vi;
  82. float ***tonecurves;
  83. float *noisethresh;
  84. float *noiseoffset;
  85. float *ath;
  86. long *octave; /* in n.ocshift format */
  87. long *bark;
  88. long firstoc;
  89. long shiftoc;
  90. int eighth_octave_lines; /* power of two, please */
  91. int total_octave_lines;
  92. long rate; /* cache it */
  93. } vorbis_look_psy;
  94. extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
  95. vorbis_info_psy_global *gi,int n,long rate);
  96. extern void _vp_psy_clear(vorbis_look_psy *p);
  97. extern void *_vi_psy_dup(void *source);
  98. extern void _vi_psy_free(vorbis_info_psy *i);
  99. extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
  100. extern void _vp_remove_floor(vorbis_look_psy *p,
  101. float *mdct,
  102. float *codedflr,
  103. float *residue);
  104. extern void _vp_compute_mask(vorbis_look_psy *p,
  105. float *fft,
  106. float *mdct,
  107. float *mask,
  108. float global_specmax,
  109. float local_specmax,
  110. float bitrate_noise_offset);
  111. extern void _vp_quantize_couple(vorbis_look_psy *p,
  112. vorbis_info_mapping0 *vi,
  113. float **pcm,
  114. float **sofar,
  115. float **quantized,
  116. int *nonzero,
  117. int passno);
  118. extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
  119. #endif