mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
InitLowLevel parameter cleanup
This commit is contained in:
parent
4a4332b22e
commit
01076d2a4f
7 changed files with 21 additions and 13 deletions
|
@ -1197,13 +1197,13 @@ int Atrac::ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrit
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Atrac::InitLowLevel(u32 paramsAddr, bool jointStereo, int codecType) {
|
||||
void Atrac::InitLowLevel(const Atrac3LowLevelParams ¶ms, bool jointStereo, int codecType) {
|
||||
track_ = Track();
|
||||
track_.codecType = codecType;
|
||||
track_.endSample = 0;
|
||||
track_.channels = Memory::Read_U32(paramsAddr);
|
||||
outputChannels_ = Memory::Read_U32(paramsAddr + 4);
|
||||
bufferMaxSize_ = Memory::Read_U32(paramsAddr + 8);
|
||||
track_.channels = params.encodedChannels;
|
||||
outputChannels_ = params.outputChannels;
|
||||
bufferMaxSize_ = params.bytesPerFrame;
|
||||
track_.bytesPerFrame = bufferMaxSize_;
|
||||
first_.writableBytes = track_.bytesPerFrame;
|
||||
ResetData();
|
||||
|
|
|
@ -225,7 +225,7 @@ public:
|
|||
virtual u32 DecodeData(u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u32 *finish, int *remains) = 0;
|
||||
virtual int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) = 0;
|
||||
virtual u32 GetNextSamples() = 0;
|
||||
virtual void InitLowLevel(u32 paramsAddr, bool jointStereo, int codecType) = 0;
|
||||
virtual void InitLowLevel(const Atrac3LowLevelParams ¶ms, bool jointStereo, int codecType) = 0;
|
||||
|
||||
virtual int GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const = 0;
|
||||
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) override;
|
||||
// Returns how many samples the next DecodeData will write.
|
||||
u32 GetNextSamples() override;
|
||||
void InitLowLevel(u32 paramsAddr, bool jointStereo, int codecType) override;
|
||||
void InitLowLevel(const Atrac3LowLevelParams ¶ms, bool jointStereo, int codecType) override;
|
||||
|
||||
int GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const override;
|
||||
|
||||
|
|
|
@ -966,12 +966,12 @@ int Atrac2::Bitrate() const {
|
|||
return bitrate;
|
||||
}
|
||||
|
||||
void Atrac2::InitLowLevel(u32 paramsAddr, bool jointStereo, int codecType) {
|
||||
void Atrac2::InitLowLevel(const Atrac3LowLevelParams ¶ms, bool jointStereo, int codecType) {
|
||||
SceAtracIdInfo &info = context_->info;
|
||||
info.codec = codecType;
|
||||
info.numChan = Memory::ReadUnchecked_U32(paramsAddr);
|
||||
outputChannels_ = Memory::ReadUnchecked_U32(paramsAddr + 4);
|
||||
info.sampleSize = Memory::ReadUnchecked_U32(paramsAddr + 8);
|
||||
info.numChan = params.encodedChannels;
|
||||
outputChannels_ = params.outputChannels;
|
||||
info.sampleSize = params.bytesPerFrame;
|
||||
info.dataOff = 0;
|
||||
info.decodePos = 0;
|
||||
info.state = ATRAC_STATUS_LOW_LEVEL;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) override;
|
||||
u32 GetNextSamples() override;
|
||||
|
||||
void InitLowLevel(u32 paramsAddr, bool jointStereo, int codecType) override;
|
||||
void InitLowLevel(const Atrac3LowLevelParams ¶ms, bool jointStereo, int codecType) override;
|
||||
|
||||
int GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const override;
|
||||
|
||||
|
|
|
@ -974,6 +974,8 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
|
|||
return hleReportError(Log::ME, 0, "invalid pointers");
|
||||
}
|
||||
|
||||
auto params = PSPPointer<Atrac3LowLevelParams>::Create(paramsAddr);
|
||||
|
||||
int codecType = atracContextTypes[atracID];
|
||||
|
||||
bool jointStereo = false;
|
||||
|
@ -992,7 +994,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
|
|||
}
|
||||
}
|
||||
|
||||
atrac->InitLowLevel(paramsAddr, jointStereo, codecType);
|
||||
atrac->InitLowLevel(*params, jointStereo, codecType);
|
||||
|
||||
const char *codecName = atrac->CodecType() == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
|
||||
const char *channelName = atrac->Channels() == 1 ? "mono" : "stereo";
|
||||
|
|
|
@ -119,6 +119,12 @@ struct SceAtracContext {
|
|||
SceAtracIdInfo info;
|
||||
};
|
||||
|
||||
struct Atrac3LowLevelParams {
|
||||
int encodedChannels;
|
||||
int outputChannels;
|
||||
int bytesPerFrame;
|
||||
};
|
||||
|
||||
constexpr int PSP_MAX_ATRAC_IDS = 6;
|
||||
|
||||
class AtracBase;
|
||||
|
|
|
@ -117,7 +117,7 @@ static const ModuleLoadInfo moduleLoadInfo[] = {
|
|||
ModuleLoadInfo(0x2ff, 0x00000000, "unk_0x2ff"),
|
||||
ModuleLoadInfo(0x300, 0x00000000, "av_avcodec", &NotifyLoadStatusAvcodec), // AudioCodec
|
||||
ModuleLoadInfo(0x301, 0x00000000, "av_sascore"),
|
||||
// TODO: We should put the Atrac contexts inside the allocated bss space. Also, current actual full size (including text, on latest fw) seems to be 0x45C0.
|
||||
// The size varies a bit per version, from about 0x3C00 to 0x4500 bytes. We could make a lookup table...
|
||||
ModuleLoadInfo(0x302, 0x00004000, "av_atrac3plus", atrac3PlusModuleDeps, &NotifyLoadStatusAtrac),
|
||||
ModuleLoadInfo(0x303, 0x0000c000, "av_mpegbase", mpegBaseModuleDeps),
|
||||
ModuleLoadInfo(0x304, 0x00004000, "av_mp3"),
|
||||
|
|
Loading…
Add table
Reference in a new issue