Ongoig psychoacoustic work:
[platform/upstream/libvorbis.git] / lib / xlogmap.h
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999             *
9  * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company       *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14   function: linear x scale -> log x scale mappings (with bias)
15   author: Monty <monty@xiph.org>
16   modifications by: Monty
17   last modification date: Aug 18 1999
18
19  ********************************************************************/
20
21 #ifndef _V_XLOGMAP_H_
22 #define _V_XLOGMAP_H_
23
24 #include <math.h>
25
26 /*
27 Bias     = log_2( n / ( (2^octaves) - 1))
28 log_x    = log_2( linear_x + 2^Bias ) - Bias 
29 linear_x = 2^(Bias+log_x)-2^Bias; 
30 */
31
32 #define LOG_BIAS(n,o)  (log((n)/(pow(2.,(o))-1))/log(2.))
33 #define LOG_X(x,b)     (log((x)+pow(2.,(b)))/log(2.)-(b))
34 #define LINEAR_X(x,b)  (pow(2.,((b)+(x)))-pow(2.,(b)))
35
36 #endif