d16fd31abaa902034181b166ef7f5f57afed1504
[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-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.18 2001/02/02 03:51:57 xiphmont Exp $
15
16  ********************************************************************/
17
18 #ifndef _V_PSY_H_
19 #define _V_PSY_H_
20 #include "smallft.h"
21
22 #ifndef EHMER_MAX
23 #define EHMER_MAX 56
24 #endif
25
26 /* psychoacoustic setup ********************************************/
27 #define MAX_BARK 27
28 #define P_BANDS 17
29 #define P_LEVELS 11
30 typedef struct vorbis_info_psy{
31   int    athp;
32   int    decayp;
33
34   float  ath_adjatt;
35   float  ath_maxatt;
36
37   int   eighth_octave_lines;
38
39   /*     0  1  2   3   4   5   6   7   8   9  10  11  12  13  14  15   16   */
40   /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */
41   /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */
42
43   int tonemaskp;
44   float toneatt[P_BANDS][P_LEVELS];
45
46   int peakattp;
47   float peakatt[P_BANDS][P_LEVELS];
48
49   int noisemaskp;
50   float noisemaxsupp;
51   float noisewindowlo;
52   float noisewindowhi;
53   int   noisewindowlomin;
54   int   noisewindowhimin;
55   float noisemedian[P_BANDS*2];
56
57   float max_curve_dB;
58   float bound_att_dB;
59
60   /* decay setup */
61   float attack_coeff;
62   float decay_coeff;
63 } vorbis_info_psy;
64
65 typedef struct {
66   int n;
67   struct vorbis_info_psy *vi;
68
69   float ***tonecurves;
70   float **peakatt;
71   float *noisemedian;
72   float *noiseoffset;
73
74   float *ath;
75   long  *octave;             /* in n.ocshift format */
76   float *bark;
77
78   long  firstoc;
79   long  shiftoc;
80   int   eighth_octave_lines; /* power of two, please */
81   int   total_octave_lines;  
82
83 } vorbis_look_psy;
84
85 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate);
86 extern void   _vp_psy_clear(vorbis_look_psy *p);
87 extern void  *_vi_psy_dup(void *source);
88
89 extern void   _vi_psy_free(vorbis_info_psy *i);
90 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
91
92 extern float  _vp_compute_mask(vorbis_look_psy *p,
93                                float *fft, 
94                                float *mdct, 
95                                float *floor,
96                                float *decay,
97                                float prev_maxamp);
98 extern void _vp_apply_floor(vorbis_look_psy *p,float *f,float *flr);
99 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
100
101 #endif
102
103