1 /********************************************************************
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. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: random psychoacoustics (not including preecho)
14 last mod: $Id: psy.h,v 1.32 2002/07/13 06:12:47 xiphmont Exp $
16 ********************************************************************/
29 /* psychoacoustic setup ********************************************/
30 #define P_BANDS 17 /* 62Hz to 16kHz */
31 #define P_LEVELS 8 /* 30dB to 100dB */
32 #define P_LEVEL_0 30. /* 30 dB */
33 #define P_NOISECURVES 3
35 #define NOISE_COMPAND_LEVELS 40
36 typedef struct vorbis_info_psy{
42 float tone_masteratt[P_NOISECURVES];
43 float tone_centerboost;
46 float toneatt[P_BANDS];
55 float noiseoff[P_NOISECURVES][P_BANDS];
56 float noisecompand[NOISE_COMPAND_LEVELS];
68 int eighth_octave_lines;
70 /* for block long/short tuning; encode only */
71 float preecho_thresh[VE_BANDS];
72 float postecho_thresh[VE_BANDS];
73 float stretch_penalty;
74 float preecho_minenergy;
76 float ampmax_att_per_sec;
78 /* channel coupling config */
79 int coupling_pkHz[PACKETBLOBS];
80 int coupling_pointlimit[2][PACKETBLOBS];
81 int coupling_prepointamp[PACKETBLOBS];
82 int coupling_postpointamp[PACKETBLOBS];
83 int sliding_lowpass[2][PACKETBLOBS];
85 } vorbis_info_psy_global;
91 vorbis_info_psy_global *gi;
92 int coupling_pointlimit[2][P_NOISECURVES];
93 } vorbis_look_psy_global;
98 struct vorbis_info_psy *vi;
104 long *octave; /* in n.ocshift format */
109 int eighth_octave_lines; /* power of two, please */
110 int total_octave_lines;
111 long rate; /* cache it */
114 extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
115 vorbis_info_psy_global *gi,int n,long rate);
116 extern void _vp_psy_clear(vorbis_look_psy *p);
117 extern void *_vi_psy_dup(void *source);
119 extern void _vi_psy_free(vorbis_info_psy *i);
120 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
122 extern void _vp_remove_floor(vorbis_look_psy *p,
126 int sliding_lowpass);
128 extern void _vp_noisemask(vorbis_look_psy *p,
132 extern void _vp_tonemask(vorbis_look_psy *p,
135 float global_specmax,
136 float local_specmax);
138 extern void _vp_offset_and_mix(vorbis_look_psy *p,
144 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
146 extern float **_vp_quantize_couple_memo(vorbis_block *vb,
147 vorbis_info_psy_global *g,
149 vorbis_info_mapping0 *vi,
152 extern void _vp_couple(int blobno,
153 vorbis_info_psy_global *g,
155 vorbis_info_mapping0 *vi,
161 int sliding_lowpass);
163 extern void _vp_noise_normalize(vorbis_look_psy *p,
164 float *in,float *out,int *sortedindex);
166 extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
167 float *magnitudes,int *sortedindex);
169 extern int **_vp_quantize_couple_sort(vorbis_block *vb,
171 vorbis_info_mapping0 *vi,