Additional optimizations, rearrangement.
[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.21 2001/06/15 21:15:40 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   float  *ath;
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   int   noisewindowfixed;
56   float noisemedian[P_BANDS*2];
57
58   float max_curve_dB;
59   float bound_att_dB;
60
61 } vorbis_info_psy;
62
63 typedef struct {
64   int n;
65   struct vorbis_info_psy *vi;
66
67   float ***tonecurves;
68   float **peakatt;
69   int   *noisemedian;
70   float *noiseoffset;
71
72   float *ath;
73   long  *octave;             /* in n.ocshift format */
74   unsigned long *bark;
75
76   long  firstoc;
77   long  shiftoc;
78   int   eighth_octave_lines; /* power of two, please */
79   int   total_octave_lines;  
80
81 } vorbis_look_psy;
82
83 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate);
84 extern void   _vp_psy_clear(vorbis_look_psy *p);
85 extern void  *_vi_psy_dup(void *source);
86
87 extern void   _vi_psy_free(vorbis_info_psy *i);
88 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
89
90 extern float  _vp_compute_mask(vorbis_look_psy *p,
91                                float *fft, 
92                                float *mdct, 
93                                float *mask,
94                                float prev_maxamp);
95 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
96
97 #endif
98
99