mirror of https://github.com/AxioDL/metaforce.git
Moved DSP decoder to amuse
This commit is contained in:
parent
859e64a2d8
commit
28e3d3c6fa
|
@ -3,7 +3,6 @@ set(AUDIO_SOURCES
|
|||
CAudioStateWin.hpp CAudioStateWin.cpp
|
||||
CSfxManager.hpp CSfxManager.cpp
|
||||
CSfxHandle.hpp CSfxHandle.cpp
|
||||
dsp.c dsp.h
|
||||
g721.c g721.h)
|
||||
|
||||
runtime_add_list(Audio AUDIO_SOURCES)
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
#include "dsp.h"
|
||||
|
||||
static const int32_t NibbleToInt[16] = {0,1,2,3,4,5,6,7,-8,-7,-6,-5,-4,-3,-2,-1};
|
||||
|
||||
void DSPDecompressFrame(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample)
|
||||
{
|
||||
uint8_t cIdx = (in[0]>>4) & 0xf;
|
||||
int32_t factor1 = coefs[cIdx][0];
|
||||
int32_t factor2 = coefs[cIdx][1];
|
||||
uint8_t exp = in[0] & 0xf;
|
||||
for (int s=0 ; s<14 && s<lastSample ; ++s)
|
||||
{
|
||||
int32_t sampleData = (s&1)?
|
||||
NibbleToInt[(in[s/2+1])&0xf]:
|
||||
NibbleToInt[(in[s/2+1]>>4)&0xf];
|
||||
sampleData <<= exp;
|
||||
sampleData <<= 11;
|
||||
sampleData += 1024;
|
||||
sampleData +=
|
||||
factor1 * ((int32_t)(*prev1)) +
|
||||
factor2 * ((int32_t)(*prev2));
|
||||
sampleData >>= 11;
|
||||
sampleData = DSPSampClamp(sampleData);
|
||||
out[s] = sampleData;
|
||||
*prev2 = *prev1;
|
||||
*prev1 = sampleData;
|
||||
}
|
||||
}
|
||||
|
||||
void DSPDecompressFrameStereoStride(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample)
|
||||
{
|
||||
uint32_t cIdx = (in[0]>>4) & 0xf;
|
||||
int32_t factor1 = coefs[cIdx][0];
|
||||
int32_t factor2 = coefs[cIdx][1];
|
||||
uint32_t exp = in[0] & 0xf;
|
||||
for (int s=0 ; s<14 && s<lastSample ; ++s)
|
||||
{
|
||||
int sampleData = (s&1)?
|
||||
NibbleToInt[(in[s/2+1])&0xf]:
|
||||
NibbleToInt[(in[s/2+1]>>4)&0xf];
|
||||
sampleData <<= exp;
|
||||
sampleData <<= 11;
|
||||
sampleData += 1024;
|
||||
sampleData +=
|
||||
factor1 * ((int32_t)(*prev1)) +
|
||||
factor2 * ((int32_t)(*prev2));
|
||||
sampleData >>= 11;
|
||||
sampleData = DSPSampClamp(sampleData);
|
||||
out[s*2] = sampleData;
|
||||
*prev2 = *prev1;
|
||||
*prev1 = sampleData;
|
||||
}
|
||||
}
|
||||
|
||||
void DSPDecompressFrameStereoDupe(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample)
|
||||
{
|
||||
uint8_t cIdx = (in[0]>>4) & 0xf;
|
||||
int32_t factor1 = coefs[cIdx][0];
|
||||
int32_t factor2 = coefs[cIdx][1];
|
||||
uint8_t exp = in[0] & 0xf;
|
||||
for (int s=0 ; s<14 && s<lastSample ; ++s)
|
||||
{
|
||||
int sampleData = (s&1)?
|
||||
NibbleToInt[(in[s/2+1])&0xf]:
|
||||
NibbleToInt[(in[s/2+1]>>4)&0xf];
|
||||
sampleData <<= exp;
|
||||
sampleData <<= 11;
|
||||
sampleData += 1024;
|
||||
sampleData +=
|
||||
factor1 * ((int32_t)(*prev1)) +
|
||||
factor2 * ((int32_t)(*prev2));
|
||||
sampleData >>= 11;
|
||||
sampleData = DSPSampClamp(sampleData);
|
||||
out[s*2] = sampleData;
|
||||
out[s*2+1] = sampleData;
|
||||
*prev2 = *prev1;
|
||||
*prev1 = sampleData;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef _DSP_h
|
||||
#define _DSP_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline int16_t DSPSampClamp(int32_t val)
|
||||
{
|
||||
if (val < -32768) val = -32768;
|
||||
else if (val > 32767) val = 32767;
|
||||
return val;
|
||||
}
|
||||
|
||||
void DSPDecompressFrame(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample);
|
||||
void DSPDecompressFrameStereoStride(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample);
|
||||
void DSPDecompressFrameStereoDupe(int16_t* out, const uint8_t* in,
|
||||
const int16_t coefs[8][2], int16_t* prev1, int16_t* prev2,
|
||||
unsigned lastSample);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _DSP_h
|
|
@ -3,7 +3,7 @@
|
|||
#include "specter/View.hpp"
|
||||
#include "CGraphics.hpp"
|
||||
#include "Audio/g721.h"
|
||||
#include "Audio/dsp.h"
|
||||
#include "amuse/dsp.h"
|
||||
#include "CDvdRequest.hpp"
|
||||
#include <turbojpeg.h>
|
||||
|
||||
|
|
2
amuse
2
amuse
|
@ -1 +1 @@
|
|||
Subproject commit 60f873e76e5fecdb302073b5b0d1c34ef141cfaf
|
||||
Subproject commit 1102d50f8f8c3f1a0fabdcafd657ab1d4564b908
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 5ef33fff84051c55004438ff83f379867f6b9fb6
|
||||
Subproject commit 17a36b0d4d2281eed7e73b75932af1bcca77441e
|
2
specter
2
specter
|
@ -1 +1 @@
|
|||
Subproject commit a48e2b4ec5087bcb167f15763c84fbac2ca4c272
|
||||
Subproject commit feccc768424181f2c7287ed9e936f1ae3acdaca7
|
Loading…
Reference in New Issue