Set dolphin/card to matching
Imported thp, THPDec.c is matching
This commit is contained in:
parent
be6ea5de09
commit
3c7ab99b35
4 changed files with 2472 additions and 23 deletions
|
|
@ -5816,8 +5816,8 @@ Vachuff = .sbss:0x801D46E0; // type:object size:0x4 scope:local align:32 data:4b
|
|||
__THPHuffmanBits = .sbss:0x801D46E4; // type:object size:0x4 scope:local data:4byte
|
||||
__THPHuffmanSizeTab = .sbss:0x801D46E8; // type:object size:0x4 scope:local data:4byte
|
||||
__THPHuffmanCodeTab = .sbss:0x801D46EC; // type:object size:0x4 scope:local data:4byte
|
||||
Gbase = .sbss:0x801D4700; // type:object size:0x20 align:32 data:4byte
|
||||
Gwid = .sbss:0x801D4720; // type:object size:0x20 align:32 data:4byte
|
||||
Gbase = .sbss:0x801D4700; // type:object size:0x20 scope:local align:32 data:4byte
|
||||
Gwid = .sbss:0x801D4720; // type:object size:0x20 scope:local align:32 data:4byte
|
||||
Gq = .sbss:0x801D4740; // type:object size:0x4 scope:local align:32 data:4byte
|
||||
__THPOldGQR5 = .sbss:0x801D4744; // type:object size:0x4 scope:local data:4byte
|
||||
__THPOldGQR6 = .sbss:0x801D4748; // type:object size:0x4 scope:local data:4byte
|
||||
|
|
|
|||
49
configure.py
49
configure.py
|
|
@ -216,6 +216,10 @@ cflags_dolphin = [
|
|||
"-fp_contract off",
|
||||
]
|
||||
|
||||
cflags_thp = [
|
||||
*cflags_base,
|
||||
]
|
||||
|
||||
# Metrowerks library flags
|
||||
cflags_msl = [
|
||||
*cflags_base,
|
||||
|
|
@ -574,21 +578,21 @@ config.libs = [
|
|||
DolphinLib(
|
||||
"card",
|
||||
[
|
||||
Object(NonMatching, "dolphin/card/CARDBios.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDUnlock.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDRdwr.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDBlock.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDDir.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDCheck.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDMount.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDFormat.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDOpen.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDCreate.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDRead.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDWrite.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDDelete.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDStat.c"),
|
||||
Object(NonMatching, "dolphin/card/CARDNet.c"),
|
||||
Object(Matching, "dolphin/card/CARDBios.c"),
|
||||
Object(Matching, "dolphin/card/CARDUnlock.c"),
|
||||
Object(Matching, "dolphin/card/CARDRdwr.c"),
|
||||
Object(Matching, "dolphin/card/CARDBlock.c"),
|
||||
Object(Matching, "dolphin/card/CARDDir.c"),
|
||||
Object(Matching, "dolphin/card/CARDCheck.c"),
|
||||
Object(Matching, "dolphin/card/CARDMount.c"),
|
||||
Object(Matching, "dolphin/card/CARDFormat.c"),
|
||||
Object(Matching, "dolphin/card/CARDOpen.c"),
|
||||
Object(Matching, "dolphin/card/CARDCreate.c"),
|
||||
Object(Matching, "dolphin/card/CARDRead.c"),
|
||||
Object(Matching, "dolphin/card/CARDWrite.c"),
|
||||
Object(Matching, "dolphin/card/CARDDelete.c"),
|
||||
Object(Matching, "dolphin/card/CARDStat.c"),
|
||||
Object(Matching, "dolphin/card/CARDNet.c"),
|
||||
],
|
||||
),
|
||||
DolphinLib(
|
||||
|
|
@ -605,13 +609,16 @@ config.libs = [
|
|||
Object(Matching, "dolphin/si/SISamplingRate.c"),
|
||||
],
|
||||
),
|
||||
DolphinLib(
|
||||
"thp",
|
||||
[
|
||||
Object(NonMatching, "dolphin/thp/THPDec.c"),
|
||||
Object(NonMatching, "dolphin/thp/THPAudio.c"),
|
||||
{
|
||||
"lib": "thp",
|
||||
"mw_version": "GC/1.2.5",
|
||||
"cflags": cflags_thp,
|
||||
"host": False,
|
||||
"objects": [
|
||||
Object(Matching, "thp/THPDec.c"),
|
||||
Object(NonMatching, "thp/THPAudio.c"),
|
||||
],
|
||||
),
|
||||
},
|
||||
{
|
||||
"lib": "Runtime.PPCEABI.H",
|
||||
"mw_version": config.linker_version,
|
||||
|
|
|
|||
162
src/thp/THPAudio.c
Normal file
162
src/thp/THPAudio.c
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
#include <dolphin/thp.h>
|
||||
|
||||
u32 THPAudioDecode(s16 *audioBuffer, u8 *audioFrame, s32 flag)
|
||||
{
|
||||
// THPAudioRecordHeader *header;
|
||||
// THPAudioDecodeInfo decInfo;
|
||||
// u8 *left, *right;
|
||||
// s16 *decLeftPtr, *decRightPtr;
|
||||
// s16 yn1, yn2;
|
||||
// s32 i;
|
||||
// s32 step;
|
||||
// s32 sample;
|
||||
// s64 yn;
|
||||
|
||||
// if (audioBuffer == NULL || audioFrame == NULL) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// header = (THPAudioRecordHeader *)audioFrame;
|
||||
// left = audioFrame + sizeof(THPAudioRecordHeader);
|
||||
// right = left + header->offsetNextChannel;
|
||||
|
||||
// if (flag == 1) {
|
||||
// decRightPtr = audioBuffer;
|
||||
// decLeftPtr = audioBuffer + header->sampleSize;
|
||||
// step = 1;
|
||||
// }
|
||||
// else {
|
||||
// decRightPtr = audioBuffer;
|
||||
// decLeftPtr = audioBuffer + 1;
|
||||
// step = 2;
|
||||
// }
|
||||
|
||||
// if (header->offsetNextChannel == 0) {
|
||||
// __THPAudioInitialize(&decInfo, left);
|
||||
|
||||
// yn1 = header->lYn1;
|
||||
// yn2 = header->lYn2;
|
||||
|
||||
// for (i = 0; i < header->sampleSize; i++) {
|
||||
// sample = __THPAudioGetNewSample(&decInfo);
|
||||
// yn = header->lCoef[decInfo.predictor][1] * yn2;
|
||||
// yn += header->lCoef[decInfo.predictor][0] * yn1;
|
||||
// yn += (sample << decInfo.scale) << 11;
|
||||
// yn <<= 5;
|
||||
|
||||
// if (sample > 0x8000) {
|
||||
// yn += 0x10000;
|
||||
// }
|
||||
// else if ((sample == 0x8000) && ((yn & 0x10000) != 0)) {
|
||||
// yn += 0x10000;
|
||||
// }
|
||||
|
||||
// yn += 0x8000;
|
||||
|
||||
// if (yn > 2147483647LL) {
|
||||
// yn = 2147483647LL;
|
||||
// }
|
||||
|
||||
// if (yn < -2147483648LL) {
|
||||
// yn = -2147483648LL;
|
||||
// }
|
||||
|
||||
// *decLeftPtr = (s16)(yn >> 16);
|
||||
// decLeftPtr += step;
|
||||
// *decRightPtr = (s16)(yn >> 16);
|
||||
// decRightPtr += step;
|
||||
// yn2 = yn1;
|
||||
// yn1 = (s16)(yn >> 16);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// __THPAudioInitialize(&decInfo, left);
|
||||
|
||||
// yn1 = header->lYn1;
|
||||
// yn2 = header->lYn2;
|
||||
|
||||
// for (i = 0; i < header->sampleSize; i++) {
|
||||
// sample = __THPAudioGetNewSample(&decInfo);
|
||||
// yn = header->lCoef[decInfo.predictor][1] * yn2;
|
||||
// yn += header->lCoef[decInfo.predictor][0] * yn1;
|
||||
// yn += (sample << decInfo.scale) << 11;
|
||||
// yn <<= 5;
|
||||
// yn += 0x8000;
|
||||
|
||||
// if (yn > 2147483647LL) {
|
||||
// yn = 2147483647LL;
|
||||
// }
|
||||
|
||||
// if (yn < -2147483648LL) {
|
||||
// yn = -2147483648LL;
|
||||
// }
|
||||
|
||||
// *decLeftPtr = (s16)(yn >> 16);
|
||||
// decLeftPtr += step;
|
||||
// yn2 = yn1;
|
||||
// yn1 = (s16)(yn >> 16);
|
||||
// }
|
||||
|
||||
// __THPAudioInitialize(&decInfo, right);
|
||||
|
||||
// yn1 = header->rYn1;
|
||||
// yn2 = header->rYn2;
|
||||
|
||||
// for (i = 0; i < header->sampleSize; i++) {
|
||||
// sample = __THPAudioGetNewSample(&decInfo);
|
||||
// yn = header->rCoef[decInfo.predictor][1] * yn2;
|
||||
// yn += header->rCoef[decInfo.predictor][0] * yn1;
|
||||
// yn += (sample << decInfo.scale) << 11;
|
||||
// yn <<= 5;
|
||||
|
||||
// yn += 0x8000;
|
||||
|
||||
// if (yn > 2147483647LL) {
|
||||
// yn = 2147483647LL;
|
||||
// }
|
||||
|
||||
// if (yn < -2147483648LL) {
|
||||
// yn = -2147483648LL;
|
||||
// }
|
||||
|
||||
// *decRightPtr = (s16)(yn >> 16);
|
||||
// decRightPtr += step;
|
||||
// yn2 = yn1;
|
||||
// yn1 = (s16)(yn >> 16);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return header->sampleSize;
|
||||
}
|
||||
|
||||
static s32 __THPAudioGetNewSample(THPAudioDecodeInfo *info)
|
||||
{
|
||||
s32 sample;
|
||||
|
||||
if (!(info->offsetNibbles & 0x0f)) {
|
||||
info->predictor = (u8)((*(info->encodeData) & 0x70) >> 4);
|
||||
info->scale = (u8)((*(info->encodeData) & 0xF));
|
||||
info->encodeData++;
|
||||
info->offsetNibbles += 2;
|
||||
}
|
||||
|
||||
if (info->offsetNibbles & 0x1) {
|
||||
sample = (s32)((*(info->encodeData) & 0xF) << 28) >> 28;
|
||||
info->encodeData++;
|
||||
}
|
||||
else {
|
||||
sample = (s32)((*(info->encodeData) & 0xF0) << 24) >> 28;
|
||||
}
|
||||
|
||||
info->offsetNibbles++;
|
||||
return sample;
|
||||
}
|
||||
|
||||
static void __THPAudioInitialize(THPAudioDecodeInfo *info, u8 *ptr)
|
||||
{
|
||||
info->encodeData = ptr;
|
||||
info->offsetNibbles = 2;
|
||||
info->predictor = (u8)((*(info->encodeData) & 0x70) >> 4);
|
||||
info->scale = (u8)((*(info->encodeData) & 0xF));
|
||||
info->encodeData++;
|
||||
}
|
||||
2280
src/thp/THPDec.c
Normal file
2280
src/thp/THPDec.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue