mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 15:07:41 +00:00
Moved DSP decoder to amuse
This commit is contained in:
@@ -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
Submodule amuse updated: 60f873e76e...1102d50f8f
2
hecl
2
hecl
Submodule hecl updated: 5ef33fff84...17a36b0d4d
2
specter
2
specter
Submodule specter updated: a48e2b4ec5...feccc76842
Reference in New Issue
Block a user