several extremely minor fixes
[platform/upstream/libvorbis.git] / lib / psy.h
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  ********************************************************************
12
13  function: random psychoacoustics (not including preecho)
14  last mod: $Id: psy.h,v 1.27 2001/12/20 01:00:29 segher Exp $
15
16  ********************************************************************/
17
18 #ifndef _V_PSY_H_
19 #define _V_PSY_H_
20 #include "smallft.h"
21
22 #include "backends.h"
23
24 #ifndef EHMER_MAX
25 #define EHMER_MAX 56
26 #endif
27
28 /* psychoacoustic setup ********************************************/
29 #define MAX_BARK 27
30 #define P_BANDS 17
31 #define P_LEVELS 11
32
33 typedef struct vp_couple{
34   int limit;        /* sample post */
35
36   int outofphase_redundant_flip_p;
37   float outofphase_requant_limit;
38
39   float amppost_point;
40   
41 } vp_couple;
42
43 typedef struct vp_couple_pass{  
44   float granulem;
45   float igranulem;
46
47   vp_couple couple_pass[8];
48 } vp_couple_pass;
49
50 typedef struct vp_attenblock{
51   float block[P_BANDS][P_LEVELS];
52 } vp_attenblock;
53
54 #define NOISE_COMPAND_LEVELS 40
55 typedef struct vorbis_info_psy{
56   float  ath[27];
57
58   float  ath_adjatt;
59   float  ath_maxatt;
60
61   float tone_masteratt;
62   float tone_guard;
63   float tone_abs_limit;
64   vp_attenblock toneatt;
65
66   int peakattp;
67   int curvelimitp;
68   vp_attenblock peakatt;
69
70   int noisemaskp;
71   float noisemaxsupp;
72   float noisewindowlo;
73   float noisewindowhi;
74   int   noisewindowlomin;
75   int   noisewindowhimin;
76   int   noisewindowfixed;
77   float noiseoff[P_BANDS];
78   float noisecompand[NOISE_COMPAND_LEVELS];
79
80   float max_curve_dB;
81
82   vp_couple_pass couple_pass[8];
83
84 } vorbis_info_psy;
85
86 typedef struct{
87   int       eighth_octave_lines;
88
89   /* for block long/short tuning; encode only */
90   float     preecho_thresh[4];
91   float     postecho_thresh[4];
92   float     preecho_minenergy;
93
94   float     ampmax_att_per_sec;
95
96   /* delay caching... how many samples to keep around prior to our
97      current block to aid in analysis? */
98   int       delaycache;
99 } vorbis_info_psy_global;
100
101 typedef struct {
102   float   ampmax;
103   int     channels;
104
105   vorbis_info_psy_global *gi;
106 } vorbis_look_psy_global;
107
108
109 typedef struct {
110   int n;
111   struct vorbis_info_psy *vi;
112
113   float ***tonecurves;
114   float *noisethresh;
115   float *noiseoffset;
116
117   float *ath;
118   long  *octave;             /* in n.ocshift format */
119   long  *bark;
120
121   long  firstoc;
122   long  shiftoc;
123   int   eighth_octave_lines; /* power of two, please */
124   int   total_octave_lines;  
125   long  rate; /* cache it */
126 } vorbis_look_psy;
127
128 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
129                            vorbis_info_psy_global *gi,int n,long rate);
130 extern void   _vp_psy_clear(vorbis_look_psy *p);
131 extern void  *_vi_psy_dup(void *source);
132
133 extern void   _vi_psy_free(vorbis_info_psy *i);
134 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
135
136 extern void _vp_remove_floor(vorbis_look_psy *p,
137                              float *mdct,
138                              float *codedflr,
139                              float *residue);
140
141 extern void   _vp_compute_mask(vorbis_look_psy *p,
142                                float *fft, 
143                                float *mdct, 
144                                float *mask, 
145                                float global_specmax,
146                                float local_specmax,
147                                float bitrate_noise_offset);
148
149 extern void _vp_quantize_couple(vorbis_look_psy *p,
150                          vorbis_info_mapping0 *vi,
151                          float **pcm,
152                          float **sofar,
153                          float **quantized,
154                          int   *nonzero,
155                          int   passno);
156
157 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
158
159 #endif
160
161