projects
/
platform
/
upstream
/
libvorbis.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
CVE-2017-14160: fix bounds check on very low sample rates.
[platform/upstream/libvorbis.git]
/
lib
/
scales.h
diff --git
a/lib/scales.h
b/lib/scales.h
index
fdc8c95
..
18bc4e7
100644
(file)
--- a/
lib/scales.h
+++ b/
lib/scales.h
@@
-5,13
+5,12
@@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-200
2
*
- * by the X
IPHOPHORUS Company
http://www.xiph.org/ *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-200
9
*
+ * by the X
iph.Org Foundation
http://www.xiph.org/ *
* *
********************************************************************
function: linear scale -> dB, Bark and Mel scales
* *
********************************************************************
function: linear scale -> dB, Bark and Mel scales
- last mod: $Id: scales.h,v 1.26 2002/07/11 06:40:50 xiphmont Exp $
********************************************************************/
********************************************************************/
@@
-21,29
+20,34
@@
#include <math.h>
#include "os.h"
#include <math.h>
#include "os.h"
+#ifdef _MSC_VER
+/* MS Visual Studio doesn't have C99 inline keyword. */
+#define inline __inline
+#endif
+
/* 20log10(x) */
#define VORBIS_IEEE_FLOAT32 1
#ifdef VORBIS_IEEE_FLOAT32
/* 20log10(x) */
#define VORBIS_IEEE_FLOAT32 1
#ifdef VORBIS_IEEE_FLOAT32
-static float unitnorm(float x){
- ogg_uint32_t *ix=(ogg_uint32_t *)&x;
- *ix=(*ix&0x80000000UL)|(0x3f800000UL);
- return(x);
-}
-
-static float FABS(float *x){
- ogg_uint32_t *ix=(ogg_uint32_t *)x;
- *ix&=0x7fffffffUL;
- return(*x);
+static inline float unitnorm(float x){
+ union {
+ ogg_uint32_t i;
+ float f;
+ } ix;
+ ix.f = x;
+ ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
+ return ix.f;
}
}
-static float todB(const float *x){
- float calc;
- ogg_int32_t *i=(ogg_int32_t *)x;
- calc = ((*i) & 0x7fffffff);
- calc *= 7.1771144e-7f;
- calc += -764.27118f;
- return calc;
+/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */
+static inline float todB(const float *x){
+ union {
+ ogg_uint32_t i;
+ float f;
+ } ix;
+ ix.f = *x;
+ ix.i = ix.i&0x7fffffff;
+ return (float)(ix.i * 7.17711438e-7f -764.6161886f);
}
#define todB_nn(x) todB(x)
}
#define todB_nn(x) todB(x)
@@
-55,14
+59,12
@@
static float unitnorm(float x){
return(1.f);
}
return(1.f);
}
-#define FABS(x) fabs(*(x))
-
#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
-#endif
+#endif
-#define fromdB(x) (exp((x)*.11512925f))
+#define fromdB(x) (exp((x)*.11512925f))
/* The bark scale equations are approximations, since the original
table was somewhat hand rolled. The below are chosen to have the
/* The bark scale equations are approximations, since the original
table was somewhat hand rolled. The below are chosen to have the
@@
-85,4
+87,3
@@
static float unitnorm(float x){
#define fromOC(o) (exp(((o)+5.965784f)*.693147f))
#endif
#define fromOC(o) (exp(((o)+5.965784f)*.693147f))
#endif
-