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 | |
---|
13 | function: random psychoacoustics (not including preecho) |
---|
14 | last mod: $Id: psy.h 13293 2007-07-24 00:09:47Z xiphmont $ |
---|
15 | |
---|
16 | ********************************************************************/ |
---|
17 | |
---|
18 | #ifndef _V_PSY_H_ |
---|
19 | #define _V_PSY_H_ |
---|
20 | #include "smallft.h" |
---|
21 | |
---|
22 | #include "backends.h" |
---|
23 | #include "envelope.h" |
---|
24 | |
---|
25 | #ifndef EHMER_MAX |
---|
26 | #define EHMER_MAX 56 |
---|
27 | #endif |
---|
28 | |
---|
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 |
---|
34 | |
---|
35 | #define NOISE_COMPAND_LEVELS 40 |
---|
36 | typedef struct vorbis_info_psy{ |
---|
37 | int blockflag; |
---|
38 | |
---|
39 | float ath_adjatt; |
---|
40 | float ath_maxatt; |
---|
41 | |
---|
42 | float tone_masteratt[P_NOISECURVES]; |
---|
43 | float tone_centerboost; |
---|
44 | float tone_decay; |
---|
45 | float tone_abs_limit; |
---|
46 | float toneatt[P_BANDS]; |
---|
47 | |
---|
48 | int noisemaskp; |
---|
49 | float noisemaxsupp; |
---|
50 | float noisewindowlo; |
---|
51 | float noisewindowhi; |
---|
52 | int noisewindowlomin; |
---|
53 | int noisewindowhimin; |
---|
54 | int noisewindowfixed; |
---|
55 | float noiseoff[P_NOISECURVES][P_BANDS]; |
---|
56 | float noisecompand[NOISE_COMPAND_LEVELS]; |
---|
57 | |
---|
58 | float max_curve_dB; |
---|
59 | |
---|
60 | int normal_channel_p; |
---|
61 | int normal_point_p; |
---|
62 | int normal_start; |
---|
63 | int normal_partition; |
---|
64 | double normal_thresh; |
---|
65 | } vorbis_info_psy; |
---|
66 | |
---|
67 | typedef struct{ |
---|
68 | int eighth_octave_lines; |
---|
69 | |
---|
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; |
---|
75 | |
---|
76 | float ampmax_att_per_sec; |
---|
77 | |
---|
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]; |
---|
84 | |
---|
85 | } vorbis_info_psy_global; |
---|
86 | |
---|
87 | typedef struct { |
---|
88 | float ampmax; |
---|
89 | int channels; |
---|
90 | |
---|
91 | vorbis_info_psy_global *gi; |
---|
92 | int coupling_pointlimit[2][P_NOISECURVES]; |
---|
93 | } vorbis_look_psy_global; |
---|
94 | |
---|
95 | |
---|
96 | typedef struct { |
---|
97 | int n; |
---|
98 | struct vorbis_info_psy *vi; |
---|
99 | |
---|
100 | float ***tonecurves; |
---|
101 | float **noiseoffset; |
---|
102 | |
---|
103 | float *ath; |
---|
104 | long *octave; /* in n.ocshift format */ |
---|
105 | long *bark; |
---|
106 | |
---|
107 | long firstoc; |
---|
108 | long shiftoc; |
---|
109 | int eighth_octave_lines; /* power of two, please */ |
---|
110 | int total_octave_lines; |
---|
111 | long rate; /* cache it */ |
---|
112 | |
---|
113 | float m_val; /* Masking compensation value */ |
---|
114 | |
---|
115 | } vorbis_look_psy; |
---|
116 | |
---|
117 | extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, |
---|
118 | vorbis_info_psy_global *gi,int n,long rate); |
---|
119 | extern void _vp_psy_clear(vorbis_look_psy *p); |
---|
120 | extern void *_vi_psy_dup(void *source); |
---|
121 | |
---|
122 | extern void _vi_psy_free(vorbis_info_psy *i); |
---|
123 | extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); |
---|
124 | |
---|
125 | extern void _vp_remove_floor(vorbis_look_psy *p, |
---|
126 | float *mdct, |
---|
127 | int *icodedflr, |
---|
128 | float *residue, |
---|
129 | int sliding_lowpass); |
---|
130 | |
---|
131 | extern void _vp_noisemask(vorbis_look_psy *p, |
---|
132 | float *logmdct, |
---|
133 | float *logmask); |
---|
134 | |
---|
135 | extern void _vp_tonemask(vorbis_look_psy *p, |
---|
136 | float *logfft, |
---|
137 | float *logmask, |
---|
138 | float global_specmax, |
---|
139 | float local_specmax); |
---|
140 | |
---|
141 | extern void _vp_offset_and_mix(vorbis_look_psy *p, |
---|
142 | float *noise, |
---|
143 | float *tone, |
---|
144 | int offset_select, |
---|
145 | float *logmask, |
---|
146 | float *mdct, |
---|
147 | float *logmdct); |
---|
148 | |
---|
149 | extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); |
---|
150 | |
---|
151 | extern float **_vp_quantize_couple_memo(vorbis_block *vb, |
---|
152 | vorbis_info_psy_global *g, |
---|
153 | vorbis_look_psy *p, |
---|
154 | vorbis_info_mapping0 *vi, |
---|
155 | float **mdct); |
---|
156 | |
---|
157 | extern void _vp_couple(int blobno, |
---|
158 | vorbis_info_psy_global *g, |
---|
159 | vorbis_look_psy *p, |
---|
160 | vorbis_info_mapping0 *vi, |
---|
161 | float **res, |
---|
162 | float **mag_memo, |
---|
163 | int **mag_sort, |
---|
164 | int **ifloor, |
---|
165 | int *nonzero, |
---|
166 | int sliding_lowpass); |
---|
167 | |
---|
168 | extern void _vp_noise_normalize(vorbis_look_psy *p, |
---|
169 | float *in,float *out,int *sortedindex); |
---|
170 | |
---|
171 | extern void _vp_noise_normalize_sort(vorbis_look_psy *p, |
---|
172 | float *magnitudes,int *sortedindex); |
---|
173 | |
---|
174 | extern int **_vp_quantize_couple_sort(vorbis_block *vb, |
---|
175 | vorbis_look_psy *p, |
---|
176 | vorbis_info_mapping0 *vi, |
---|
177 | float **mags); |
---|
178 | |
---|
179 | extern void hf_reduction(vorbis_info_psy_global *g, |
---|
180 | vorbis_look_psy *p, |
---|
181 | vorbis_info_mapping0 *vi, |
---|
182 | float **mdct); |
---|
183 | |
---|
184 | |
---|
185 | #endif |
---|
186 | |
---|