Initial beta 4 merge
[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 SOURCE IS GOVERNED BY *
5  * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH    *
6  * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.        *
7  *                                                                  *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and the XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: random psychoacoustics (not including preecho)
15  last mod: $Id: psy.h,v 1.17 2001/01/22 01:38:25 xiphmont Exp $
16
17  ********************************************************************/
18
19 #ifndef _V_PSY_H_
20 #define _V_PSY_H_
21 #include "smallft.h"
22
23 #ifndef EHMER_MAX
24 #define EHMER_MAX 56
25 #endif
26
27 /* psychoacoustic setup ********************************************/
28 #define MAX_BARK 27
29 #define P_BANDS 17
30 #define P_LEVELS 11
31 typedef struct vorbis_info_psy{
32   int    athp;
33   int    decayp;
34
35   float  ath_adjatt;
36   float  ath_maxatt;
37
38   int   eighth_octave_lines;
39
40   /*     0  1  2   3   4   5   6   7   8   9  10  11  12  13  14  15   16   */
41   /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */
42   /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */
43
44   int tonemaskp;
45   float toneatt[P_BANDS][P_LEVELS];
46
47   int peakattp;
48   float peakatt[P_BANDS][P_LEVELS];
49
50   int noisemaskp;
51   float noisemaxsupp;
52   float noisewindowlo;
53   float noisewindowhi;
54   int   noisewindowlomin;
55   int   noisewindowhimin;
56   float noisemedian[P_BANDS*2];
57
58   float max_curve_dB;
59   float bound_att_dB;
60
61   /* decay setup */
62   float attack_coeff;
63   float decay_coeff;
64 } vorbis_info_psy;
65
66 typedef struct {
67   int n;
68   struct vorbis_info_psy *vi;
69
70   float ***tonecurves;
71   float **peakatt;
72   float *noisemedian;
73   float *noiseoffset;
74
75   float *ath;
76   long  *octave;             /* in n.ocshift format */
77   float *bark;
78
79   long  firstoc;
80   long  shiftoc;
81   int   eighth_octave_lines; /* power of two, please */
82   int   total_octave_lines;  
83
84 } vorbis_look_psy;
85
86 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate);
87 extern void   _vp_psy_clear(vorbis_look_psy *p);
88 extern void  *_vi_psy_dup(void *source);
89
90 extern void   _vi_psy_free(vorbis_info_psy *i);
91 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
92
93 extern float  _vp_compute_mask(vorbis_look_psy *p,
94                                float *fft, 
95                                float *mdct, 
96                                float *floor,
97                                float *decay,
98                                float prev_maxamp);
99 extern void _vp_apply_floor(vorbis_look_psy *p,float *f,float *flr);
100 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
101
102 #endif
103
104