mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
Move MULSC stuff into a separate include file
This commit is contained in:
parent
1706ff5ccb
commit
e073786abe
4 changed files with 42 additions and 31 deletions
36
dumb/include/internal/mulsc.h
Normal file
36
dumb/include/internal/mulsc.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef INTERNAL_MULSC_H
|
||||||
|
#define INTERNAL_MULSC_H
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER) || !defined(_M_IX86) || _MSC_VER >= 1800
|
||||||
|
//#define MULSC(a, b) ((int)((LONG_LONG)(a) * (b) >> 16))
|
||||||
|
//#define MULSC(a, b) ((a) * ((b) >> 2) >> 14)
|
||||||
|
#define MULSCV(a, b) ((int)((LONG_LONG)(a) * (b) >> 32))
|
||||||
|
#define MULSCA(a, b) ((int)((LONG_LONG)((a) << 4) * (b) >> 32))
|
||||||
|
#define MULSC(a, b) ((int)((LONG_LONG)((a) << 4) * ((b) << 12) >> 32))
|
||||||
|
#define MULSC16(a, b) ((int)((LONG_LONG)((a) << 12) * ((b) << 12) >> 32))
|
||||||
|
#else
|
||||||
|
/* VC++ calls __allmull and __allshr for the above math. I don't know why.
|
||||||
|
* [Need to check if this still applies to recent versions of the compiler.] */
|
||||||
|
static __forceinline unsigned long long MULLL(int a, int b)
|
||||||
|
{
|
||||||
|
__asm mov eax,a
|
||||||
|
__asm imul b
|
||||||
|
}
|
||||||
|
static __forceinline int MULSCV (int a, int b)
|
||||||
|
{
|
||||||
|
#ifndef _DEBUG
|
||||||
|
union { unsigned long long q; struct { int l, h; }; } val;
|
||||||
|
val.q = MULLL(a,b);
|
||||||
|
return val.h;
|
||||||
|
#else
|
||||||
|
__asm mov eax,a
|
||||||
|
__asm imul b
|
||||||
|
__asm mov eax,edx
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#define MULSCA(a, b) MULSCV((a) << 4, b)
|
||||||
|
#define MULSC(a, b) MULSCV((a) << 4, (b) << 12)
|
||||||
|
#define MULSC16(a, b) MULSCV((a) << 12, (b) << 12)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* INTERNAL_MULSC_H */
|
|
@ -46,6 +46,7 @@
|
||||||
#include "dumb.h"
|
#include "dumb.h"
|
||||||
|
|
||||||
#include "internal/resampler.h"
|
#include "internal/resampler.h"
|
||||||
|
#include "internal/mulsc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,36 +86,6 @@ int dumb_resampling_quality = DUMB_RQ_CUBIC;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || !defined(_M_IX86) || _MSC_VER >= 1800
|
|
||||||
//#define MULSC(a, b) ((int)((LONG_LONG)(a) * (b) >> 16))
|
|
||||||
//#define MULSC(a, b) ((a) * ((b) >> 2) >> 14)
|
|
||||||
#define MULSCV(a, b) ((int)((LONG_LONG)(a) * (b) >> 32))
|
|
||||||
#define MULSC(a, b) ((int)((LONG_LONG)((a) << 4) * ((b) << 12) >> 32))
|
|
||||||
#define MULSC16(a, b) ((int)((LONG_LONG)((a) << 12) * ((b) << 12) >> 32))
|
|
||||||
#else
|
|
||||||
/* VC++ calls __allmull and __allshr for the above math. I don't know why.
|
|
||||||
* [Need to check if this still applies to recent versions of the compiler.] */
|
|
||||||
static __forceinline unsigned long long MULLL(int a, int b)
|
|
||||||
{
|
|
||||||
__asm mov eax,a
|
|
||||||
__asm imul b
|
|
||||||
}
|
|
||||||
static __forceinline int MULSCV (int a, int b)
|
|
||||||
{
|
|
||||||
#ifndef _DEBUG
|
|
||||||
union { unsigned long long q; struct { int l, h; }; } val;
|
|
||||||
val.q = MULLL(a,b);
|
|
||||||
return val.h;
|
|
||||||
#else
|
|
||||||
__asm mov eax,a
|
|
||||||
__asm imul b
|
|
||||||
__asm mov eax,edx
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define MULSC(a, b) MULSCV((a) << 4, (b) << 12)
|
|
||||||
#define MULSC16(a, b) MULSCV((a) << 12, ((b) << 12))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* From xs_Float.h ==============================================*/
|
/* From xs_Float.h ==============================================*/
|
||||||
#if __BIG_ENDIAN__
|
#if __BIG_ENDIAN__
|
||||||
#define _xs_iman_ 1
|
#define _xs_iman_ 1
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "internal/lpc.h"
|
#include "internal/lpc.h"
|
||||||
|
|
||||||
#include "internal/resampler.h"
|
#include "internal/resampler.h"
|
||||||
|
#include "internal/mulsc.h"
|
||||||
|
|
||||||
// #define BIT_ARRAY_BULLSHIT
|
// #define BIT_ARRAY_BULLSHIT
|
||||||
|
|
||||||
|
@ -601,7 +602,6 @@ static void it_filter_int(DUMB_CLICK_REMOVER *cr, IT_FILTER_STATE *state, sample
|
||||||
|
|
||||||
#define INT_FILTERS
|
#define INT_FILTERS
|
||||||
#ifdef INT_FILTERS
|
#ifdef INT_FILTERS
|
||||||
#define MULSCA(a, b) ((int)((LONG_LONG)((a) << 4) * (b) >> 32))
|
|
||||||
#define SCALEB 12
|
#define SCALEB 12
|
||||||
{
|
{
|
||||||
int ai = (int)(a * (1 << (16+SCALEB)));
|
int ai = (int)(a * (1 << (16+SCALEB)));
|
||||||
|
|
|
@ -2041,6 +2041,10 @@
|
||||||
RelativePath="..\..\include\internal\lpc.h"
|
RelativePath="..\..\include\internal\lpc.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\internal\mulsc.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\internal\resampler.h"
|
RelativePath="..\..\include\internal\resampler.h"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue