mirror of
https://github.com/libretro/libretro-common.git
synced 2024-06-23 06:32:43 -04:00
Update
This commit is contained in:
parent
268f9026c1
commit
783c1b3bed
|
@ -232,7 +232,7 @@ typedef struct math_matrix_4x4
|
|||
MAT_ELEM_4X4(out, 2, 3) = 0.0f; \
|
||||
MAT_ELEM_4X4(out, 3, 0) = -(xaxis[0] * eye[0] + xaxis[1] * eye[1] + xaxis[2] * eye[2]); \
|
||||
MAT_ELEM_4X4(out, 3, 1) = -(yaxis[0] * eye[0] + yaxis[1] * eye[1] + yaxis[2] * eye[2]); \
|
||||
MAT_ELEM_4X4(out, 3, 2) = -(zaxis[0] * eye[0] + zaxis[1] * eye[1] + zaxis[2] * eye[2]); \
|
||||
MAT_ELEM_4X4(out, 3, 2) = (zaxis[0] * eye[0] + zaxis[1] * eye[1] + zaxis[2] * eye[2]); \
|
||||
MAT_ELEM_4X4(out, 3, 3) = 1.f; \
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
|
@ -48,6 +49,90 @@ typedef float vec2_t[2];
|
|||
dst[0] = src[0]; \
|
||||
dst[1] = src[1]
|
||||
|
||||
static INLINE float overflow(void)
|
||||
{
|
||||
unsigned i;
|
||||
volatile float f = 1e10;
|
||||
|
||||
for(i = 0; i < 10; ++i)
|
||||
f *= f;
|
||||
return f;
|
||||
}
|
||||
|
||||
static INLINE int16_t tofloat16(float f)
|
||||
{
|
||||
union uif32
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
};
|
||||
|
||||
int i, s, e, m;
|
||||
union uif32 Entry;
|
||||
Entry.f = f;
|
||||
i = (int)Entry.i;
|
||||
s = (i >> 16) & 0x00008000;
|
||||
e = ((i >> 23) & 0x000000ff) - (127 - 15);
|
||||
m = i & 0x007fffff;
|
||||
|
||||
if(e <= 0)
|
||||
{
|
||||
if(e < -10)
|
||||
return (int16_t)(s);
|
||||
|
||||
m = (m | 0x00800000) >> (1 - e);
|
||||
|
||||
if(m & 0x00001000)
|
||||
m += 0x00002000;
|
||||
|
||||
return (int16_t)(s | (m >> 13));
|
||||
}
|
||||
|
||||
if(e == 0xff - (127 - 15))
|
||||
{
|
||||
if(m == 0)
|
||||
return (int16_t)(s | 0x7c00);
|
||||
|
||||
m >>= 13;
|
||||
|
||||
return (int16_t)(s | 0x7c00 | m | (m == 0));
|
||||
}
|
||||
|
||||
if(m & 0x00001000)
|
||||
{
|
||||
m += 0x00002000;
|
||||
|
||||
if(m & 0x00800000)
|
||||
{
|
||||
m = 0;
|
||||
e += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (e > 30)
|
||||
{
|
||||
overflow();
|
||||
|
||||
return (int16_t)(s | 0x7c00);
|
||||
}
|
||||
|
||||
return (int16_t)(s | (e << 10) | (m >> 13));
|
||||
}
|
||||
|
||||
static INLINE unsigned int vec2_packHalf2x16(float vec0, float vec1)
|
||||
{
|
||||
union
|
||||
{
|
||||
int16_t in[2];
|
||||
unsigned int out;
|
||||
} u;
|
||||
|
||||
u.in[0] = tofloat16(vec0);
|
||||
u.in[1] = tofloat16(vec1);
|
||||
|
||||
return u.out;
|
||||
}
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,10 +35,9 @@ typedef struct
|
|||
static INLINE fft_complex_t fft_complex_mul(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real * b.real - a.imag * b.imag,
|
||||
a.imag * b.real + a.real * b.imag,
|
||||
};
|
||||
fft_complex_t out;
|
||||
out.real = a.real * b.real - a.imag * b.imag;
|
||||
out.imag = a.imag * b.real + a.real * b.imag;
|
||||
|
||||
return out;
|
||||
|
||||
|
@ -47,10 +46,9 @@ static INLINE fft_complex_t fft_complex_mul(fft_complex_t a,
|
|||
static INLINE fft_complex_t fft_complex_add(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real + b.real,
|
||||
a.imag + b.imag,
|
||||
};
|
||||
fft_complex_t out;
|
||||
out.real = a.real + b.real;
|
||||
out.imag = a.imag + b.imag;
|
||||
|
||||
return out;
|
||||
|
||||
|
@ -59,10 +57,9 @@ static INLINE fft_complex_t fft_complex_add(fft_complex_t a,
|
|||
static INLINE fft_complex_t fft_complex_sub(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real - b.real,
|
||||
a.imag - b.imag,
|
||||
};
|
||||
fft_complex_t out;
|
||||
out.real = a.real - b.real;
|
||||
out.imag = a.imag - b.imag;
|
||||
|
||||
return out;
|
||||
|
||||
|
@ -70,9 +67,9 @@ static INLINE fft_complex_t fft_complex_sub(fft_complex_t a,
|
|||
|
||||
static INLINE fft_complex_t fft_complex_conj(fft_complex_t a)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real, -a.imag,
|
||||
};
|
||||
fft_complex_t out;
|
||||
out.real = a.real;
|
||||
out.imag = -a.imag;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -612,7 +612,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
|||
|
||||
/* Allow for easy reading of strings to be safe.
|
||||
* Will only work with sane character formatting (Unix). */
|
||||
((char*)content_buf)[content_buf_size] = '\0';
|
||||
((char*)content_buf)[ret] = '\0';
|
||||
|
||||
if (len)
|
||||
*len = ret;
|
||||
|
|
Loading…
Reference in a new issue