Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions extern/dolphin/include/dolphin/thp/thp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ typedef struct _THPHuffmanTab {
u8* bits;
u32 pad3;
u32* codetab;
u32 pad2[2];
u32 pad2;
u16 num_Vij;
} THPHuffmanTab;

typedef struct _THPComponent {
u8 _;
THPCoeff predDC;
u8 pad;
u8 quantizationTableSelector;
Expand All @@ -51,18 +53,17 @@ typedef struct _THPFileInfo {
u16 nMCU;
u16 currMCU;
u8* dLC[3];
u32 pad2[(0x83d - 0x756) / 4];
u8 pad2[0x83d - 0x756];
THPComponent components[3];
} THPFileInfo;

typedef struct {
typedef struct {
s32 val0;
u16 val1;
u16 _pad;
u8 val2;
u8 val2;
} THPDec_8032FD40_Data;


static u8 __THPSetupBuffers(THPFileInfo*);
static u8 __THPReadFrameHeader(void);
static u8 __THPReadScaneHeader(THPFileInfo*);
Expand All @@ -76,19 +77,20 @@ static u8 __THPRestartDefinition(THPFileInfo*);
static void __THPPrepBitStream(THPFileInfo*);
static void __THPDecompressYUV(void*, void*, void*);
static void __THPGQRRestore(void);
static void __THPDecompressiMCURow512x448(void);
static void __THPDecompressiMCURow512x448(THPFileInfo*);
static void __THPDecompressiMCURow640x480(void);
static void __THPDecompressiMCURowNxN(void);
static void __THPInverseDCTNoYPos(THPCoeff*, u32);
static void __THPHuffDecodeDCTCompY(THPFileInfo*, THPCoeff*);
static void __THPHuffDecodeDCTCompU(THPFileInfo*, THPCoeff*);
static void __THPHuffDecodeDCTCompV(THPFileInfo*, THPCoeff*);

s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV, void* work);
s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV,
void* work);
s32 THPDec_803302EC(u8** data);
s32 THPDec_8032FD40(THPDec_8032FD40_Data* arg0, u16 arg1);
void THPDec_803300E0(u32* data);
BOOL THPInit(void);
void THPInit(void);

#ifdef __cplusplus
}
Expand Down
78 changes: 41 additions & 37 deletions extern/dolphin/src/dolphin/thp/THPDec.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV)

if (__THPInfo->xPixelSize == 512 && targetY == 448) {
while (currentY < targetY) {
__THPDecompressiMCURow512x448();
__THPDecompressiMCURow512x448(__THPInfo);
currentY += 16;
}
} else if (__THPInfo->xPixelSize == 640 && targetY == 480) {
Expand Down Expand Up @@ -240,7 +240,8 @@ s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV,
}
}

else {
else
{
goto _err_unsupported_marker;
}
}
Expand Down Expand Up @@ -493,7 +494,7 @@ static u8 __THPReadHuffmanTableSpecification(THPFileInfo* info)

info->huffmanTabs[tab_index].bits = huffmanBits;
info->huffmanTabs[tab_index].Vij = info->file;
info->huffmanTabs[tab_index].pad2[1] = num_Vij;
info->huffmanTabs[tab_index].num_Vij = num_Vij;
info->file += num_Vij;
result =
__THPHuffGenerateSizeTable(info, tab_index, (int) huffmanBits);
Expand Down Expand Up @@ -1229,55 +1230,55 @@ inline void __THPInverseDCTY8(register THPCoeff* in, register u32 xPos)
}
}

static void __THPDecompressiMCURow512x448(void)
static void __THPDecompressiMCURow512x448(THPFileInfo* info)
{
u8 cl_num;
u32 x_pos;
THPComponent* comp;

LCQueueWait(3);

for (cl_num = 0; cl_num < __THPInfo->MCUsPerRow; cl_num++) {
__THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[0]);
__THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[1]);
__THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[2]);
__THPHuffDecodeDCTCompY(__THPInfo, __THPMCUBuffer[3]);
__THPHuffDecodeDCTCompU(__THPInfo, __THPMCUBuffer[4]);
__THPHuffDecodeDCTCompV(__THPInfo, __THPMCUBuffer[5]);
for (cl_num = 0; cl_num < info->MCUsPerRow; cl_num++) {
__THPHuffDecodeDCTCompY(info, __THPMCUBuffer[0]);
__THPHuffDecodeDCTCompY(info, __THPMCUBuffer[1]);
__THPHuffDecodeDCTCompY(info, __THPMCUBuffer[2]);
__THPHuffDecodeDCTCompY(info, __THPMCUBuffer[3]);
__THPHuffDecodeDCTCompU(info, __THPMCUBuffer[4]);
__THPHuffDecodeDCTCompV(info, __THPMCUBuffer[5]);

comp = &__THPInfo->components[0];
comp = &info->components[0];
Gbase = __THPLCWork512[0];
Gwid = 512;
Gq = __THPInfo->quantTabs[comp->quantizationTableSelector];
Gq = info->quantTabs[comp->quantizationTableSelector];
x_pos = (u32) (cl_num * 16);
__THPInverseDCTNoYPos(__THPMCUBuffer[0], x_pos);
__THPInverseDCTNoYPos(__THPMCUBuffer[1], x_pos + 8);
__THPInverseDCTY8(__THPMCUBuffer[2], x_pos);
__THPInverseDCTY8(__THPMCUBuffer[3], x_pos + 8);

comp = &__THPInfo->components[1];
comp = &info->components[1];
Gbase = __THPLCWork512[1];
Gwid = 256;
Gq = __THPInfo->quantTabs[comp->quantizationTableSelector];
Gq = info->quantTabs[comp->quantizationTableSelector];
x_pos /= 2;
__THPInverseDCTNoYPos(__THPMCUBuffer[4], x_pos);
comp = &__THPInfo->components[2];
comp = &info->components[2];
Gbase = __THPLCWork512[2];
Gq = __THPInfo->quantTabs[comp->quantizationTableSelector];
Gq = info->quantTabs[comp->quantizationTableSelector];
__THPInverseDCTNoYPos(__THPMCUBuffer[5], x_pos);

if (__THPInfo->RST != 0) {
if ((--__THPInfo->currMCU) == 0) {
__THPInfo->currMCU = __THPInfo->nMCU;
__THPInfo->cnt = 1 + ((__THPInfo->cnt + 6) & 0xFFFFFFF8);
if (info->RST != 0) {
if ((--info->currMCU) == 0) {
info->currMCU = info->nMCU;
info->cnt = 1 + ((info->cnt + 6) & 0xFFFFFFF8);

if (__THPInfo->cnt > 33) {
__THPInfo->cnt = 33;
if (info->cnt > 33) {
info->cnt = 33;
}

__THPInfo->components[0].predDC = 0;
__THPInfo->components[1].predDC = 0;
__THPInfo->components[2].predDC = 0;
info->components[0].predDC = 0;
info->components[1].predDC = 0;
info->components[2].predDC = 0;
}
}
}
Expand Down Expand Up @@ -1760,8 +1761,7 @@ static void __THPHuffDecodeDCTCompY(register THPFileInfo* info,
}
#endif // clang-format on

for (k = 1; k < 64; k++)
{
for (k = 1; k < 64; k++) {
register s32 ssss;
register s32 rrrr;

Expand Down Expand Up @@ -2174,7 +2174,8 @@ static void __THPHuffDecodeDCTCompU(register THPFileInfo* info,
block[__THPJpegNaturalOrder[k]] = (s16) rrrr;
}

else {
else
{
if (rrrr != 15) {
break;
}
Expand Down Expand Up @@ -2351,10 +2352,14 @@ static inline void OSInitFastCast(void) {
// clang-format off


BOOL THPInit(void)
void THPInit(void)
{
u8* base;
//OSRegisterVersion(__THPVersion);

if (!(PPCMfhid2() & 0x10000000)) {
DCInvalidateRange((u8*)(0xE0000000), 0x4000);
LCEnable();
}
base = (u8*)(0xE000 << 16);

__THPLCWork512[0] = base;
Expand All @@ -2366,14 +2371,13 @@ BOOL THPInit(void)

base = (u8*)(0xE000 << 16);
__THPLCWork672[0] = base;
base += 0x2A00;
base += 0x2800;
__THPLCWork672[1] = base;
base += 0xA80;
base += 0xA00;
__THPLCWork672[2] = base;
base += 0xA80;

//OSInitFastCast();
OSInitFastCast();

__THPInitFlag = TRUE;
return TRUE;
}
return;
}
Loading