Skip to content

Commit

Permalink
THPAudioDecode progress
Browse files Browse the repository at this point in the history
ty sware and mk:dd
@HeartPiece44 your turn now :)
  • Loading branch information
EpochFlame committed Sep 12, 2023
1 parent e55c266 commit f0c739a
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 330 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"osbootinfo.h": "c",
"dvd.h": "c",
"osutil.h": "c",
"hw_regs.h": "c"
"hw_regs.h": "c",
"thpread.h": "c",
"thpbuffer.h": "c",
"thpinfo.h": "c",
"thpfile.h": "c"
}
}
6 changes: 3 additions & 3 deletions docs/recommended_todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectSpecialActor.cpp">JSTObjectSpecialActor.cpp</a> | 2289 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/illustratedBookMessage.cpp">illustratedBookMessage.cpp</a> | 2964 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/captionMessage.cpp">captionMessage.cpp</a> | 3528 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/messageObj.cpp">messageObj.cpp</a> | 4504 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/aramMgr.cpp">aramMgr.cpp</a> | 4920 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/gameflow.cpp">gameflow.cpp</a> | 5333 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/messageMgr.cpp">messageMgr.cpp</a> | 6825 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/section.cpp">section.cpp</a> | 7138 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/THPRead.c">THPRead.c</a> | 7147 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/THPAudioDecode.c">THPAudioDecode.c</a> | 7366 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/THPAudioDecode.c">THPAudioDecode.c</a> | 4835 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/aramMgr.cpp">aramMgr.cpp</a> | 4920 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/gameflow.cpp">gameflow.cpp</a> | 5333 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/messageMgr.cpp">messageMgr.cpp</a> | 6825 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/section.cpp">section.cpp</a> | 7138 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/THPRead.c">THPRead.c</a> | 7147 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/moviePlayerPauseAndDraw.cpp">moviePlayerPauseAndDraw.cpp</a> | 8587 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/screenScene.cpp">screenScene.cpp</a> | 9274 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/THPVideoDecode.c">THPVideoDecode.c</a> | 10029 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectParticleActor.cpp">JSTObjectParticleActor.cpp</a> | 11032 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/loadResource.cpp">loadResource.cpp</a> | 11781 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/heapStatus.cpp">heapStatus.cpp</a> | 12405 |
Expand Down
25 changes: 25 additions & 0 deletions include/THP/THPAudioDecode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef _THP_THPAUDIODECODE_H
#define _THP_THPAUDIODECODE_H

#include "Dolphin/os.h"

#ifdef __cplusplus
extern "C" {
#endif
int THPAudioDecode(s16* arg1, u8* arg2, int arg3); // TODO: determine args and name properly

BOOL CreateAudioDecodeThread(OSPriority, void*);
void AudioDecodeThreadStart();
void AudioDecodeThreadCancel();

void PushFreeAudioBuffer(void* buf);
void PushDecodedAudioBuffer(void* buf);

void* PopFreeAudioBuffer();
void* PopDecodedAudioBuffer(s32 flags);

#ifdef __cplusplus
}
#endif

#endif
33 changes: 33 additions & 0 deletions include/THP/THPBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef _THP_THPBUFFER_H
#define _THP_THPBUFFER_H

#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct THPTextureSet {
u8* ytexture;
u8* utexture;
u8* vtexture;
s32 frameNumber;
} THPTextureSet;

typedef struct THPAudioBuffer {
s16* buffer;
s16* curPtr;
u32 validSample;
} THPAudioBuffer;

typedef struct THPReadBuffer {
u8* ptr;
s32 frameNumber;
BOOL isValid;
} THPReadBuffer;

#ifdef __cplusplus
}
#endif

#endif
29 changes: 29 additions & 0 deletions include/THP/THPFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef _THP_THPFILE_H
#define _THP_THPFILE_H

#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct THPHeader {
char magic[4];
u32 version;
u32 bufsize;
u32 audioMaxSamples;
f32 frameRate;
u32 numFrames;
u32 firstFrameSize;
u32 movieDataSize;
u32 compInfoDataOffsets;
u32 offsetDataOffsets;
u32 movieDataOffsets;
u32 finalFrameDataOffsets;
} THPHeader;

#ifdef __cplusplus
}
#endif

#endif
32 changes: 32 additions & 0 deletions include/THP/THPInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef _THP_THPINFO_H
#define _THP_THPINFO_H

#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct THPVideoInfo {
u32 xSize;
u32 ySize;
u32 videoType;
} THPVideoInfo;

typedef struct THPAudioInfo {
u32 sndChannels;
u32 sndFrequency;
u32 sndNumSamples;
u32 sndNumTracks;
} THPAudioInfo;

typedef struct THPFrameCompInfo {
u32 numComponents;
u8 frameComp[16];
} THPFrameCompInfo;

#ifdef __cplusplus
}
#endif

#endif
85 changes: 85 additions & 0 deletions include/THP/THPPlayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef _THP_THPPLAYER_H
#define _THP_THPPLAYER_H

#include "types.h"
#include "Dolphin/os.h"
#include "Dolphin/gx.h"
#include "THP/THPBuffer.h"
#include "THP/THPFile.h"
#include "THP/THPInfo.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct THPPlayer {
DVDFileInfo fileInfo;
THPHeader header;
THPFrameCompInfo compInfo;
THPVideoInfo videoInfo;
THPAudioInfo audioInfo;
void* thpWork;
BOOL open;
u8 state;
u8 internalState;
u8 playFlag;
u8 audioExist;
s32 dvdError;
s32 videoError;
BOOL onMemory;
u8* movieData;
s32 initOffset;
s32 initReadSize;
s32 initReadFrame;
u32 curField;
s64 retaceCount;
s32 prevCount;
s32 curCount;
s32 videoDecodeCount;
f32 curVolume;
f32 targetVolume;
f32 deltaVolume;
s32 rampCount;
s32 curAudioTrack;
s32 curVideoNumber;
s32 curAudioNumber;
THPTextureSet* dispTextureSet;
THPAudioBuffer* playAudioBuffer;
THPReadBuffer readBuffer[10];
THPTextureSet textureSet[3];
THPAudioBuffer audioBuffer[6];
} THPPlayer; // Size: 0x1f0

extern THPPlayer ActivePlayer;

BOOL THPPlayerInit();
void THPPlayerQuit();
BOOL THPPlayerOpen(const char* fileName, BOOL onMemory);
BOOL THPPlayerClose();
BOOL THPPlayerPlay();
void THPPlayerStop();
BOOL THPPlayerPause();
BOOL THPPlayerPrepare(s32 offset, u8 flag, s32 audioTrack);

BOOL THPPlayerSetBuffer(u8* data);

u32 THPPlayerCalcNeedMemory();

BOOL THPPlayerGetVideoInfo(void* dst);
// BOOL THPPlayerGetAudioInfo(void *dst);
// f32 THPPlayerGetFrameRate();
BOOL THPPlayerSetVolume(s32 vol, s32 duration);

s32 THPPlayerDrawCurrentFrame(GXRenderModeObj* rmode, s32, s32, s32, s32); // TODO, parameter names from dwarf info if it exists
u32 THPPlayerGetTotalFrame();
u8 THPPlayerGetState();

void THPPlayerPostDrawDone();

#ifdef __cplusplus
}
#endif

void PrepareReady(int msg);

#endif /* _THP_THPPLAYER_H */
5 changes: 1 addition & 4 deletions include/THP/THPRead.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

#include "Dolphin/os.h"
#include "types.h"
#include "THP/THPBuffer.h"

#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus

typedef struct THPReadBuffer {
u32 _00;
} THPReadBuffer;

BOOL CreateReadThread(int);
void ReadThreadStart();
void ReadThreadCancel();
Expand Down
Loading

0 comments on commit f0c739a

Please sign in to comment.