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-2009 * |
9 | * by the Xiph.Org Foundation https://xiph.org/ * |
10 | * * |
11 | ******************************************************************** |
12 | |
13 | function: random psychoacoustics (not including preecho) |
14 | |
15 | ********************************************************************/ |
16 | |
17 | #ifndef _V_PSY_H_ |
18 | #define _V_PSY_H_ |
19 | #include "smallft.h" |
20 | |
21 | #include "backends.h" |
22 | #include "envelope.h" |
23 | |
24 | #ifndef EHMER_MAX |
25 | #define EHMER_MAX 56 |
26 | #endif |
27 | |
28 | /* psychoacoustic setup ********************************************/ |
29 | #define P_BANDS 17 /* 62Hz to 16kHz */ |
30 | #define P_LEVELS 8 /* 30dB to 100dB */ |
31 | #define P_LEVEL_0 30. /* 30 dB */ |
32 | #define P_NOISECURVES 3 |
33 | |
34 | #define NOISE_COMPAND_LEVELS 40 |
35 | typedef struct vorbis_info_psy{ |
36 | int blockflag; |
37 | |
38 | float ath_adjatt; |
39 | float ath_maxatt; |
40 | |
41 | float tone_masteratt[P_NOISECURVES]; |
42 | float tone_centerboost; |
43 | float tone_decay; |
44 | float tone_abs_limit; |
45 | float toneatt[P_BANDS]; |
46 | |
47 | int noisemaskp; |
48 | float noisemaxsupp; |
49 | float noisewindowlo; |
50 | float noisewindowhi; |
51 | int noisewindowlomin; |
52 | int noisewindowhimin; |
53 | int noisewindowfixed; |
54 | float noiseoff[P_NOISECURVES][P_BANDS]; |
55 | float noisecompand[NOISE_COMPAND_LEVELS]; |
56 | |
57 | float max_curve_dB; |
58 | |
59 | int normal_p; |
60 | int normal_start; |
61 | int normal_partition; |
62 | double normal_thresh; |
63 | } vorbis_info_psy; |
64 | |
65 | typedef struct{ |
66 | int eighth_octave_lines; |
67 | |
68 | /* for block long/short tuning; encode only */ |
69 | float preecho_thresh[VE_BANDS]; |
70 | float postecho_thresh[VE_BANDS]; |
71 | float stretch_penalty; |
72 | float preecho_minenergy; |
73 | |
74 | float ampmax_att_per_sec; |
75 | |
76 | /* channel coupling config */ |
77 | int coupling_pkHz[PACKETBLOBS]; |
78 | int coupling_pointlimit[2][PACKETBLOBS]; |
79 | int coupling_prepointamp[PACKETBLOBS]; |
80 | int coupling_postpointamp[PACKETBLOBS]; |
81 | int sliding_lowpass[2][PACKETBLOBS]; |
82 | |
83 | } vorbis_info_psy_global; |
84 | |
85 | typedef struct { |
86 | float ampmax; |
87 | int channels; |
88 | |
89 | vorbis_info_psy_global *gi; |
90 | int coupling_pointlimit[2][P_NOISECURVES]; |
91 | } vorbis_look_psy_global; |
92 | |
93 | |
94 | typedef struct { |
95 | int n; |
96 | struct vorbis_info_psy *vi; |
97 | |
98 | float ***tonecurves; |
99 | float **noiseoffset; |
100 | |
101 | float *ath; |
102 | long *octave; /* in n.ocshift format */ |
103 | long *bark; |
104 | |
105 | long firstoc; |
106 | long shiftoc; |
107 | int eighth_octave_lines; /* power of two, please */ |
108 | int total_octave_lines; |
109 | long rate; /* cache it */ |
110 | |
111 | float m_val; /* Masking compensation value */ |
112 | |
113 | } vorbis_look_psy; |
114 | |
115 | extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, |
116 | vorbis_info_psy_global *gi,int n,long rate); |
117 | extern void _vp_psy_clear(vorbis_look_psy *p); |
118 | extern void *_vi_psy_dup(void *source); |
119 | |
120 | extern void _vi_psy_free(vorbis_info_psy *i); |
121 | extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); |
122 | |
123 | extern void _vp_noisemask(vorbis_look_psy *p, |
124 | float *logmdct, |
125 | float *logmask); |
126 | |
127 | extern void _vp_tonemask(vorbis_look_psy *p, |
128 | float *logfft, |
129 | float *logmask, |
130 | float global_specmax, |
131 | float local_specmax); |
132 | |
133 | extern void _vp_offset_and_mix(vorbis_look_psy *p, |
134 | float *noise, |
135 | float *tone, |
136 | int offset_select, |
137 | float *logmask, |
138 | float *mdct, |
139 | float *logmdct); |
140 | |
141 | extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); |
142 | |
143 | extern void _vp_couple_quantize_normalize(int blobno, |
144 | vorbis_info_psy_global *g, |
145 | vorbis_look_psy *p, |
146 | vorbis_info_mapping0 *vi, |
147 | float **mdct, |
148 | int **iwork, |
149 | int *nonzero, |
150 | int sliding_lowpass, |
151 | int ch); |
152 | |
153 | #endif |
154 | |