Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /******************************************************************** |
michael@0 | 2 | * * |
michael@0 | 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
michael@0 | 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
michael@0 | 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
michael@0 | 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
michael@0 | 7 | * * |
michael@0 | 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * |
michael@0 | 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * |
michael@0 | 10 | * * |
michael@0 | 11 | ******************************************************************** |
michael@0 | 12 | |
michael@0 | 13 | function: linear scale -> dB, Bark and Mel scales |
michael@0 | 14 | last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $ |
michael@0 | 15 | |
michael@0 | 16 | ********************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef _V_SCALES_H_ |
michael@0 | 19 | #define _V_SCALES_H_ |
michael@0 | 20 | |
michael@0 | 21 | #include <math.h> |
michael@0 | 22 | #include "os.h" |
michael@0 | 23 | |
michael@0 | 24 | #ifdef _MSC_VER |
michael@0 | 25 | /* MS Visual Studio doesn't have C99 inline keyword. */ |
michael@0 | 26 | #define inline __inline |
michael@0 | 27 | #endif |
michael@0 | 28 | |
michael@0 | 29 | /* 20log10(x) */ |
michael@0 | 30 | #define VORBIS_IEEE_FLOAT32 1 |
michael@0 | 31 | #ifdef VORBIS_IEEE_FLOAT32 |
michael@0 | 32 | |
michael@0 | 33 | static inline float unitnorm(float x){ |
michael@0 | 34 | union { |
michael@0 | 35 | ogg_uint32_t i; |
michael@0 | 36 | float f; |
michael@0 | 37 | } ix; |
michael@0 | 38 | ix.f = x; |
michael@0 | 39 | ix.i = (ix.i & 0x80000000U) | (0x3f800000U); |
michael@0 | 40 | return ix.f; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | /* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ |
michael@0 | 44 | static inline float todB(const float *x){ |
michael@0 | 45 | union { |
michael@0 | 46 | ogg_uint32_t i; |
michael@0 | 47 | float f; |
michael@0 | 48 | } ix; |
michael@0 | 49 | ix.f = *x; |
michael@0 | 50 | ix.i = ix.i&0x7fffffff; |
michael@0 | 51 | return (float)(ix.i * 7.17711438e-7f -764.6161886f); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | #define todB_nn(x) todB(x) |
michael@0 | 55 | |
michael@0 | 56 | #else |
michael@0 | 57 | |
michael@0 | 58 | static float unitnorm(float x){ |
michael@0 | 59 | if(x<0)return(-1.f); |
michael@0 | 60 | return(1.f); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | #define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f) |
michael@0 | 64 | #define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f) |
michael@0 | 65 | |
michael@0 | 66 | #endif |
michael@0 | 67 | |
michael@0 | 68 | #define fromdB(x) (exp((x)*.11512925f)) |
michael@0 | 69 | |
michael@0 | 70 | /* The bark scale equations are approximations, since the original |
michael@0 | 71 | table was somewhat hand rolled. The below are chosen to have the |
michael@0 | 72 | best possible fit to the rolled tables, thus their somewhat odd |
michael@0 | 73 | appearance (these are more accurate and over a longer range than |
michael@0 | 74 | the oft-quoted bark equations found in the texts I have). The |
michael@0 | 75 | approximations are valid from 0 - 30kHz (nyquist) or so. |
michael@0 | 76 | |
michael@0 | 77 | all f in Hz, z in Bark */ |
michael@0 | 78 | |
michael@0 | 79 | #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) |
michael@0 | 80 | #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) |
michael@0 | 81 | #define toMEL(n) (log(1.f+(n)*.001f)*1442.695f) |
michael@0 | 82 | #define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f) |
michael@0 | 83 | |
michael@0 | 84 | /* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave |
michael@0 | 85 | 0.0 */ |
michael@0 | 86 | |
michael@0 | 87 | #define toOC(n) (log(n)*1.442695f-5.965784f) |
michael@0 | 88 | #define fromOC(o) (exp(((o)+5.965784f)*.693147f)) |
michael@0 | 89 | |
michael@0 | 90 | #endif |