Merge pull request #19982 from hrydgard/assorted-cleanups

Remove unused float16 type, split out sceAac from sceMp4
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-02-14 10:49:38 -06:00
commit 4f2ceca071
14 files changed
+303 -350

No files matched your search

+2
View File
@@ -2276,6 +2276,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceMt19937.h
Core/HLE/sceMd5.cpp
Core/HLE/sceMd5.h
Core/HLE/sceAac.cpp
Core/HLE/sceAac.h
Core/HLE/sceMp4.cpp
Core/HLE/sceMp4.h
Core/HLE/sceMp3.cpp
+1 -9
View File
@@ -7,15 +7,6 @@
#include <cstring>
#include <cstdint>
typedef unsigned short float16;
inline float Float16ToFloat(float16 ix) {
uint32_t extended = ix;
float x;
memcpy(&x, &extended, sizeof(float));
return x;
}
inline bool isPowerOf2(int n) {
return n == 1 || (n & (n - 1)) == 0;
}
@@ -36,6 +27,7 @@ inline uint32_t RoundUpToPowerOf2(uint32_t v, uint32_t power) {
return (v + power - 1) & ~(power - 1);
}
// TODO: this should just use a bitscan.
inline uint32_t log2i(uint32_t val) {
unsigned int ret = -1;
while (val != 0) {
+2
View File
@@ -572,6 +572,7 @@
<ClCompile Include="HLE\KUBridge.cpp" />
<ClCompile Include="HLE\NetInetConstants.cpp" />
<ClCompile Include="HLE\Plugins.cpp" />
<ClCompile Include="HLE\sceAac.cpp" />
<ClCompile Include="HLE\sceKernelHeap.cpp" />
<ClCompile Include="HLE\sceNetApctl.cpp" />
<ClCompile Include="HLE\sceNetInet.cpp" />
@@ -1191,6 +1192,7 @@
<ClInclude Include="HLE\KUBridge.h" />
<ClInclude Include="HLE\NetInetConstants.h" />
<ClInclude Include="HLE\Plugins.h" />
<ClInclude Include="HLE\sceAac.h" />
<ClInclude Include="HLE\sceKernelHeap.h" />
<ClInclude Include="HLE\sceNetApctl.h" />
<ClInclude Include="HLE\sceNetInet.h" />
+6
View File
@@ -1339,6 +1339,9 @@
<ClCompile Include="HLE\SocketManager.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
<ClCompile Include="HLE\sceAac.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@@ -2157,6 +2160,9 @@
<ClInclude Include="HLE\SocketManager.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
<ClInclude Include="HLE\sceAac.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE.TXT" />
+2
View File
@@ -49,6 +49,7 @@
#include "sceKernelTime.h"
#include "sceMd5.h"
#include "sceMp4.h"
#include "sceAac.h"
#include "sceMp3.h"
#include "sceNet.h"
#include "sceNetAdhoc.h"
@@ -275,6 +276,7 @@ void RegisterAllModules() {
Register_sceGameUpdate();
Register_sceDeflt();
Register_sceMp4();
Register_sceAac();
Register_scePauth();
Register_sceNp();
Register_sceNpCommerce2();
+223
View File
@@ -0,0 +1,223 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Core/HLE/sceAac.h"
#include <algorithm>
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/Reporting.h"
#include "Core/HW/SimpleAudioDec.h"
static std::map<u32, AuCtx*> aacMap;
static AuCtx *getAacCtx(u32 id) {
if (aacMap.find(id) == aacMap.end())
return NULL;
return aacMap[id];
}
void __AACShutdown() {
for (auto it = aacMap.begin(), end = aacMap.end(); it != end; it++) {
delete it->second;
}
aacMap.clear();
}
void __AACDoState(PointerWrap &p) {
auto s = p.Section("sceAAC", 0, 1);
if (!s)
return;
Do(p, aacMap);
}
static u32 sceAacExit(u32 id) {
if (aacMap.find(id) != aacMap.end()) {
delete aacMap[id];
aacMap.erase(id);
} else {
return hleLogError(Log::ME, -1, "bad aac ID");
}
return hleLogInfo(Log::ME, 0);
}
static u32 sceAacInit(u32 id)
{
if (!Memory::IsValidAddress(id)) {
return hleLogError(Log::ME, ERROR_AAC_INVALID_ADDRESS, "AAC Invalid id address %08x", id);
}
AuCtx *aac = new AuCtx();
aac->startPos = Memory::Read_U64(id); // AUDIO stream start position.
aac->endPos = Memory::Read_U32(id + 8); // AUDIO stream end position.
aac->AuBuf = Memory::Read_U32(id + 16); // Input AAC data buffer.
aac->AuBufSize = Memory::Read_U32(id + 20); // Input AAC data buffer size.
aac->PCMBuf = Memory::Read_U32(id + 24); // Output PCM data buffer.
aac->PCMBufSize = Memory::Read_U32(id + 28); // Output PCM data buffer size.
aac->freq = Memory::Read_U32(id + 32); // Frequency.
if (aac->AuBuf == 0 || aac->PCMBuf == 0) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID ADDRESS AuBuf %08x PCMBuf %08x", aac->AuBuf, aac->PCMBuf);
delete aac;
return hleNoLog(ERROR_AAC_INVALID_ADDRESS);
}
if (aac->startPos > aac->endPos) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID startPos %lli endPos %lli", aac->startPos, aac->endPos);
delete aac;
return hleNoLog(ERROR_AAC_INVALID_PARAMETER);
}
if (aac->AuBufSize < 8192 || aac->PCMBufSize < 8192) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID PARAMETER, bufferSize %i outputSize %i", aac->AuBufSize, aac->PCMBufSize);
delete aac;
return hleNoLog(ERROR_AAC_INVALID_PARAMETER);
}
if (aac->freq != 24000 && aac->freq != 32000 && aac->freq != 44100 && aac->freq != 48000) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID freq %i", aac->freq);
delete aac;
return hleNoLog(ERROR_AAC_INVALID_PARAMETER);
}
DEBUG_LOG(Log::ME, "startPos %llx endPos %llx AuBuf %08x AuBufSize %08x PCMbuf %08x PCMbufSize %08x freq %d",
aac->startPos, aac->endPos, aac->AuBuf, aac->AuBufSize, aac->PCMBuf, aac->PCMBufSize, aac->freq);
aac->Channels = 2;
aac->MaxOutputSample = aac->PCMBufSize / 4;
aac->SetReadPos((int)aac->startPos);
// create aac decoder
aac->decoder = CreateAudioDecoder(PSP_CODEC_AAC);
// close the audio if id already exist.
if (aacMap.find(id) != aacMap.end()) {
delete aacMap[id];
aacMap.erase(id);
}
aacMap[id] = aac;
return hleNoLog(id);
}
static u32 sceAacInitResource(u32 numberIds) {
// Do nothing here
INFO_LOG_REPORT(Log::ME, "sceAacInitResource(%i)", numberIds);
return hleNoLog(0);
}
static u32 sceAacTermResource() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceAacDecode(u32 id, u32 pcmAddr) {
// return the size of output pcm, <0 error
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->AuDecode(pcmAddr));
}
static u32 sceAacGetLoopNum(u32 id) {
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogInfo(Log::ME, ctx->LoopNum);
}
static u32 sceAacSetLoopNum(u32 id, int loop) {
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
ctx->LoopNum = loop;
return hleLogInfo(Log::ME, 0);
}
static int sceAacCheckStreamDataNeeded(u32 id) {
// return 1 to read more data stream, 0 don't read, <0 error
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->AuCheckStreamDataNeeded());
}
static u32 sceAacNotifyAddStreamData(u32 id, int size) {
// check how many bytes we have read from source file
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->AuNotifyAddStreamData(size));
}
static u32 sceAacGetInfoToAddStreamData(u32 id, u32 buff, u32 size, u32 srcPos) {
// read from stream position srcPos of size bytes into buff
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->AuGetInfoToAddStreamData(buff, size, srcPos));
}
static u32 sceAacGetMaxOutputSample(u32 id) {
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->MaxOutputSample);
}
static u32 sceAacGetSumDecodedSample(u32 id) {
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogDebug(Log::ME, ctx->SumDecodedSamples);
}
static u32 sceAacResetPlayPosition(u32 id) {
INFO_LOG(Log::ME, "sceAacResetPlayPosition(id %i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
return hleLogError(Log::ME, -1, "bad aac id");
}
return hleLogInfo(Log::ME, ctx->AuResetPlayPosition());
}
const HLEFunction sceAac[] = {
{0XE0C89ACA, &WrapU_U<sceAacInit>, "sceAacInit", 'x', "x" },
{0X33B8C009, &WrapU_U<sceAacExit>, "sceAacExit", 'x', "x" },
{0X5CFFC57C, &WrapU_U<sceAacInitResource>, "sceAacInitResource", 'x', "x" },
{0X23D35CAE, &WrapU_V<sceAacTermResource>, "sceAacTermResource", 'x', "" },
{0X7E4CFEE4, &WrapU_UU<sceAacDecode>, "sceAacDecode", 'x', "xx" },
{0X523347D9, &WrapU_U<sceAacGetLoopNum>, "sceAacGetLoopNum", 'x', "x" },
{0XBBDD6403, &WrapU_UI<sceAacSetLoopNum>, "sceAacSetLoopNum", 'x', "xi" },
{0XD7C51541, &WrapI_U<sceAacCheckStreamDataNeeded>, "sceAacCheckStreamDataNeeded", 'i', "x" },
{0XAC6DCBE3, &WrapU_UI<sceAacNotifyAddStreamData>, "sceAacNotifyAddStreamData", 'x', "xi" },
{0X02098C69, &WrapU_UUUU<sceAacGetInfoToAddStreamData>, "sceAacGetInfoToAddStreamData", 'x', "xxxx" },
{0X6DC7758A, &WrapU_U<sceAacGetMaxOutputSample>, "sceAacGetMaxOutputSample", 'x', "x" },
{0X506BF66C, &WrapU_U<sceAacGetSumDecodedSample>, "sceAacGetSumDecodedSample", 'x', "x" },
{0XD2DA2BBA, &WrapU_U<sceAacResetPlayPosition>, "sceAacResetPlayPosition", 'x', "x" },
};
void Register_sceAac() {
RegisterModule("sceAac", ARRAY_SIZE(sceAac), sceAac);
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
#include "Common/Serialize/Serializer.h"
enum {
ERROR_AAC_INVALID_ADDRESS = 0x80691002,
ERROR_AAC_INVALID_PARAMETER = 0x80691003,
};
void __AACShutdown();
void __AACDoState(PointerWrap &p);
void Register_sceAac();
+1
View File
@@ -88,6 +88,7 @@
#include "sceHeap.h"
#include "sceDmac.h"
#include "sceMp4.h"
#include "sceAac.h"
#include "sceOpenPSID.h"
#include "sceHttp.h"
#include "Core/Util/PPGeDraw.h"
+44 -334
View File
@@ -25,57 +25,25 @@
#include "Core/HLE/sceMp4.h"
#include "Core/HW/SimpleAudioDec.h"
static std::map<u32, AuCtx*> aacMap;
static AuCtx *getAacCtx(u32 id) {
if (aacMap.find(id) == aacMap.end())
return NULL;
return aacMap[id];
static u32 sceMp4Init() {
return hleLogInfo(Log::ME, 0);
}
void __AACShutdown() {
for (auto it = aacMap.begin(), end = aacMap.end(); it != end; it++) {
delete it->second;
}
aacMap.clear();
static u32 sceMp4Finish() {
return hleLogError(Log::ME, 0);
}
void __AACDoState(PointerWrap &p) {
auto s = p.Section("sceAAC", 0, 1);
if (!s)
return;
Do(p, aacMap);
}
static u32 sceMp4Init()
{
INFO_LOG(Log::ME, "sceMp4Init()");
return 0;
}
static u32 sceMp4Finish()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4Finish()");
return 0;
}
static u32 sceMp4Create(u32 mp4, u32 callbacks, u32 readBufferAddr, u32 readBufferSize)
{
static u32 sceMp4Create(u32 mp4, u32 callbacks, u32 readBufferAddr, u32 readBufferSize) {
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMp4Create(mp4 %i,callbacks %08x,readBufferAddr %08x,readBufferSize %i)", mp4, callbacks, readBufferAddr, readBufferSize);
return 0;
}
static u32 sceMp4GetNumberOfSpecificTrack()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetNumberOfSpecificTrack()");
return 1;
static u32 sceMp4GetNumberOfSpecificTrack() {
return hleLogError(Log::ME, 1, "UNIMPL");
}
static u32 sceMp4GetMovieInfo(u32 mp4, u32 unknown2)
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetMovieInfo(mp4 %i, unknown2 %08x)",mp4, unknown2);
return 0;
static u32 sceMp4GetMovieInfo(u32 mp4, u32 unknown2) {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4TrackSampleBufAvailableSize(u32 mp4, u32 trackAddr, u32 writableSamplesAddr, u32 writableBytesAddr) {
@@ -86,327 +54,90 @@ static u32 sceMp4Delete(u32 mp4) {
return hleLogError(Log::ME, 0, "unimplemented");
}
static u32 sceMp4AacDecodeInitResource(int unknown)
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4AacDecodeInitResource(%i)",unknown);
return 0;
static u32 sceMp4AacDecodeInitResource(int unknown) {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4InitAu(u32 mp4, u32 unknown2, u32 auAddr)
{
static u32 sceMp4InitAu(u32 mp4, u32 unknown2, u32 auAddr) {
// unknown2 = return value of sceMpegAvcResourceGetAvcEsBuf()
ERROR_LOG(Log::ME, "UNIMPL sceMp4InitAu(mp4 %i,unknown2 %08x,auAddr %08x)", mp4, unknown2, auAddr);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL (mp4 %i,unknown2 %08x,auAddr %08x)", mp4, unknown2, auAddr);
}
static u32 sceMp4GetAvcAu(u32 mp4, u32 unknown2, u32 auAddr, u32 unknown4)
{
// unknown2 = return value of sceMpegAvcResourceGetAvcEsBuf()
ERROR_LOG(Log::ME, "UNIMPL sceMp4InitAu(mp4 %i,unknown2 %08x,auAddr %08x,unknown4 %08x)", mp4, unknown2, auAddr, unknown4);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL (mp4 %i,unknown2 %08x,auAddr %08x,unknown4 %08x)", mp4, unknown2, auAddr, unknown4);
}
static u32 sceMp4GetAvcTrackInfoData()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetAvcTrackInfoData()");
return 0;
static u32 sceMp4GetAvcTrackInfoData() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4TrackSampleBufConstruct(u32 mp4, u32 unknown2, u32 unknown3, u32 unknown4, u32 unknown5, u32 unknown6, u32 unknown7)
{
// unknown4 == value returned by sceMp4_BCA9389C
ERROR_LOG(Log::ME, "UNIMPL sceMp4TrackSampleBufConstruct(mp4 %i,unknown2 %08x,unknown3 %08x, unknown4 %08x, unknown5 %08x, unknown6 %08x, unknown7 %08x)", mp4, unknown2, unknown3, unknown4, unknown5, unknown6, unknown7);
return 0;
static u32 sceMp4TrackSampleBufConstruct(u32 mp4, u32 unknown2, u32 unknown3, u32 unknown4, u32 unknown5, u32 unknown6, u32 unknown7) {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4TrackSampleBufQueryMemSize(u32 unknown1, u32 unknown2, u32 unknown3, u32 unknown4, u32 unknown5)
{
u32 value = std::max(unknown2 * unknown3, unknown4 << 1) + (unknown2 << 6) + unknown5 + 256;
ERROR_LOG(Log::ME, "sceMp4TrackSampleBufQueryMemSize return %i",value);
return value;
return hleLogWarning(Log::ME, value);
}
static u32 sceMp4AacDecode(u32 mp4, u32 auAddr, u32 bufferAddr, u32 init, u32 frequency)
{
static u32 sceMp4AacDecode(u32 mp4, u32 auAddr, u32 bufferAddr, u32 init, u32 frequency) {
// Decode audio:
// - init: 1 at first call, 0 afterwards
// - frequency: 44100
ERROR_LOG(Log::ME, "sceMp4AacDecode(mp4 %i,auAddr %08x,bufferAddr %08x,init %i,frequency %i ", mp4, auAddr, bufferAddr, init, frequency);
return 0;
return hleLogError(Log::ME, 0, "mp4 % i, auAddr % 08x, bufferAddr % 08x, init % i, frequency % i ", mp4, auAddr, bufferAddr, init, frequency);
//This is hack
//return -1;
}
static u32 sceMp4GetAacAu(u32 mp4, u32 unknown2, u32 auAddr, u32 unknown4)
{
static u32 sceMp4GetAacAu(u32 mp4, u32 unknown2, u32 auAddr, u32 unknown4) {
// unknown4: pointer to a 40-bytes structure
ERROR_LOG(Log::ME, "sceMp4GetAacAu(mp4 %i,unknown2 %08x,auAddr %08x,unknown4 %i ", mp4, unknown2, auAddr, unknown4);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4GetSampleInfo()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetSampleInfo()");
return 0;
static u32 sceMp4GetSampleInfo() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4GetSampleNumWithTimeStamp()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetSampleNumWithTimeStamp()");
return 0;
static u32 sceMp4GetSampleNumWithTimeStamp() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4TrackSampleBufFlush()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4TrackSampleBufFlush()");
return 0;
static u32 sceMp4TrackSampleBufFlush() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4AacDecodeInit(int unknown)
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4AacDecodeInit(%i)",unknown);
return 0;
static u32 sceMp4AacDecodeInit(int unknown) {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4GetAacTrackInfoData()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetAacTrackInfoData()");
return 0;
static u32 sceMp4GetAacTrackInfoData() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4GetNumberOfMetaData()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4GetNumberOfMetaData()");
return 0;
static u32 sceMp4GetNumberOfMetaData() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4RegistTrack(u32 mp4, u32 unknown2, u32 unknown3, u32 callbacks, u32 unknown5)
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4RegistTrack(mp4 %i,unknown2 %i,unknown3 %i,callbacks %i unknown5 %i)",mp4,unknown2,unknown3,callbacks,unknown5);
return 0;
static u32 sceMp4RegistTrack(u32 mp4, u32 unknown2, u32 unknown3, u32 callbacks, u32 unknown5) {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMp4SearchSyncSampleNum()
{
ERROR_LOG(Log::ME, "UNIMPL sceMp4SearchSyncSampleNum()");
return 0;
}
// sceAac module starts from here
static u32 sceAacExit(u32 id)
{
INFO_LOG(Log::ME, "sceAacExit(id %i)", id);
if (aacMap.find(id) != aacMap.end()) {
delete aacMap[id];
aacMap.erase(id);
}
else{
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return 0;
}
static u32 sceAacInit(u32 id)
{
INFO_LOG(Log::ME, "UNIMPL sceAacInit(%08x)", id);
if (!Memory::IsValidAddress(id)){
ERROR_LOG(Log::ME, "sceAacInit() AAC Invalid id address %08x", id);
return ERROR_AAC_INVALID_ADDRESS;
}
AuCtx *aac = new AuCtx();
aac->startPos = Memory::Read_U64(id); // AUDIO stream start position.
aac->endPos = Memory::Read_U32(id + 8); // AUDIO stream end position.
aac->AuBuf = Memory::Read_U32(id + 16); // Input AAC data buffer.
aac->AuBufSize = Memory::Read_U32(id + 20); // Input AAC data buffer size.
aac->PCMBuf = Memory::Read_U32(id + 24); // Output PCM data buffer.
aac->PCMBufSize = Memory::Read_U32(id + 28); // Output PCM data buffer size.
aac->freq = Memory::Read_U32(id + 32); // Frequency.
if (aac->AuBuf == 0 || aac->PCMBuf == 0) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID ADDRESS AuBuf %08x PCMBuf %08x", aac->AuBuf, aac->PCMBuf);
delete aac;
return ERROR_AAC_INVALID_ADDRESS;
}
if (aac->startPos > aac->endPos) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID startPos %lli endPos %lli", aac->startPos, aac->endPos);
delete aac;
return ERROR_AAC_INVALID_PARAMETER;
}
if (aac->AuBufSize < 8192 || aac->PCMBufSize < 8192) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID PARAMETER, bufferSize %i outputSize %i", aac->AuBufSize, aac->PCMBufSize);
delete aac;
return ERROR_AAC_INVALID_PARAMETER;
}
if (aac->freq != 24000 && aac->freq != 32000 && aac->freq != 44100 && aac->freq != 48000) {
ERROR_LOG(Log::ME, "sceAacInit() AAC INVALID freq %i", aac->freq);
delete aac;
return ERROR_AAC_INVALID_PARAMETER;
}
DEBUG_LOG(Log::ME, "startPos %llx endPos %llx AuBuf %08x AuBufSize %08x PCMbuf %08x PCMbufSize %08x freq %d",
aac->startPos, aac->endPos, aac->AuBuf, aac->AuBufSize, aac->PCMBuf, aac->PCMBufSize, aac->freq);
aac->Channels = 2;
aac->MaxOutputSample = aac->PCMBufSize / 4;
aac->SetReadPos((int)aac->startPos);
// create aac decoder
aac->decoder = CreateAudioDecoder(PSP_CODEC_AAC);
// close the audio if id already exist.
if (aacMap.find(id) != aacMap.end()) {
delete aacMap[id];
aacMap.erase(id);
}
aacMap[id] = aac;
return id;
}
static u32 sceAacInitResource(u32 numberIds)
{
// Do nothing here
INFO_LOG_REPORT(Log::ME, "sceAacInitResource(%i)", numberIds);
return 0;
}
static u32 sceAacTermResource()
{
ERROR_LOG(Log::ME, "UNIMPL sceAacTermResource()");
return 0;
}
static u32 sceAacDecode(u32 id, u32 pcmAddr)
{
// return the size of output pcm, <0 error
DEBUG_LOG(Log::ME, "sceAacDecode(id %i, bufferAddress %08x)", id, pcmAddr);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->AuDecode(pcmAddr);
}
static u32 sceAacGetLoopNum(u32 id)
{
INFO_LOG(Log::ME, "sceAacGetLoopNum(id %i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->LoopNum;
}
static u32 sceAacSetLoopNum(u32 id, int loop)
{
INFO_LOG(Log::ME, "sceAacSetLoopNum(id %i,loop %d)", id, loop);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
ctx->LoopNum = loop;
return 0;
}
static int sceAacCheckStreamDataNeeded(u32 id)
{
// return 1 to read more data stream, 0 don't read, <0 error
DEBUG_LOG(Log::ME, "sceAacCheckStreamDataNeeded(%i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->AuCheckStreamDataNeeded();
}
static u32 sceAacNotifyAddStreamData(u32 id, int size)
{
// check how many bytes we have read from source file
DEBUG_LOG(Log::ME, "sceAacNotifyAddStreamData(%i, %08x)", id, size);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->AuNotifyAddStreamData(size);
}
static u32 sceAacGetInfoToAddStreamData(u32 id, u32 buff, u32 size, u32 srcPos)
{
// read from stream position srcPos of size bytes into buff
DEBUG_LOG(Log::ME, "sceAacGetInfoToAddStreamData(%08X, %08X, %08X, %08X)", id, buff, size, srcPos);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac handle %08x", __FUNCTION__, id);
return -1;
}
return ctx->AuGetInfoToAddStreamData(buff, size, srcPos);
}
static u32 sceAacGetMaxOutputSample(u32 id)
{
DEBUG_LOG(Log::ME, "sceAacGetMaxOutputSample(id %i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->MaxOutputSample;
}
static u32 sceAacGetSumDecodedSample(u32 id)
{
DEBUG_LOG(Log::ME, "sceAacGetSumDecodedSample(id %i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->SumDecodedSamples;
}
static u32 sceAacResetPlayPosition(u32 id)
{
INFO_LOG(Log::ME, "sceAacResetPlayPosition(id %i)", id);
auto ctx = getAacCtx(id);
if (!ctx) {
ERROR_LOG(Log::ME, "%s: bad aac id %08x", __FUNCTION__, id);
return -1;
}
return ctx->AuResetPlayPosition();
static u32 sceMp4SearchSyncSampleNum() {
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 mp4msv_3C2183C7(u32 unknown1, u32 unknown2) {
ERROR_LOG(Log::ME, "UNIMPL mp4msv_3C2183C7(%d, %x)", unknown1, unknown2);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 mp4msv_9CA13D1A(u32 unknown1, u32 unknown2) {
ERROR_LOG(Log::ME, "UNIMPL mp4msv_9CA13D1A(%d, %x)", unknown1, unknown2);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL");
}
const HLEFunction sceMp4[] =
{
const HLEFunction sceMp4[] = {
{0X68651CBC, &WrapU_V<sceMp4Init>, "sceMp4Init", 'x', "" },
{0X9042B257, &WrapU_V<sceMp4Finish>, "sceMp4Finish", 'x', "" },
{0XB1221EE7, &WrapU_UUUU<sceMp4Create>, "sceMp4Create", 'x', "xxxx" },
@@ -448,36 +179,15 @@ const HLEFunction sceMp4[] =
{0X9CA13D1A, nullptr, "mp4msv_9CA13D1A", '?', "" },
};
// 395
const HLEFunction sceAac[] = {
{0XE0C89ACA, &WrapU_U<sceAacInit>, "sceAacInit", 'x', "x" },
{0X33B8C009, &WrapU_U<sceAacExit>, "sceAacExit", 'x', "x" },
{0X5CFFC57C, &WrapU_U<sceAacInitResource>, "sceAacInitResource", 'x', "x" },
{0X23D35CAE, &WrapU_V<sceAacTermResource>, "sceAacTermResource", 'x', "" },
{0X7E4CFEE4, &WrapU_UU<sceAacDecode>, "sceAacDecode", 'x', "xx" },
{0X523347D9, &WrapU_U<sceAacGetLoopNum>, "sceAacGetLoopNum", 'x', "x" },
{0XBBDD6403, &WrapU_UI<sceAacSetLoopNum>, "sceAacSetLoopNum", 'x', "xi" },
{0XD7C51541, &WrapI_U<sceAacCheckStreamDataNeeded>, "sceAacCheckStreamDataNeeded", 'i', "x" },
{0XAC6DCBE3, &WrapU_UI<sceAacNotifyAddStreamData>, "sceAacNotifyAddStreamData", 'x', "xi" },
{0X02098C69, &WrapU_UUUU<sceAacGetInfoToAddStreamData>, "sceAacGetInfoToAddStreamData", 'x', "xxxx" },
{0X6DC7758A, &WrapU_U<sceAacGetMaxOutputSample>, "sceAacGetMaxOutputSample", 'x', "x" },
{0X506BF66C, &WrapU_U<sceAacGetSumDecodedSample>, "sceAacGetSumDecodedSample", 'x', "x" },
{0XD2DA2BBA, &WrapU_U<sceAacResetPlayPosition>, "sceAacResetPlayPosition", 'x', "x" },
};
const HLEFunction mp4msv[] = {
{0x3C2183C7, &WrapU_UU<mp4msv_3C2183C7>, "mp4msv_3C2183C7", 'x', "xx" },
{0x9CA13D1A, &WrapU_UU<mp4msv_9CA13D1A>, "mp4msv_9CA13D1A", 'x', "xx" },
};
void Register_sceMp4()
{
void Register_sceMp4() {
RegisterModule("sceMp4", ARRAY_SIZE(sceMp4), sceMp4);
RegisterModule("sceAac", ARRAY_SIZE(sceAac), sceAac);
}
void Register_mp4msv()
{
void Register_mp4msv() {
RegisterModule("mp4msv", ARRAY_SIZE(mp4msv), mp4msv);
}
-7
View File
@@ -17,12 +17,5 @@
#pragma once
enum {
ERROR_AAC_INVALID_ADDRESS = 0x80691002,
ERROR_AAC_INVALID_PARAMETER = 0x80691003,
};
void Register_sceMp4();
void __AACShutdown();
void __AACDoState(PointerWrap &p);
void Register_mp4msv();
+2
View File
@@ -231,6 +231,7 @@
<ClInclude Include="..\..\Core\HLE\sceMd5.h" />
<ClInclude Include="..\..\Core\HLE\sceMp3.h" />
<ClInclude Include="..\..\Core\HLE\sceMp4.h" />
<ClInclude Include="..\..\Core\HLE\sceAac.h" />
<ClInclude Include="..\..\Core\HLE\sceMpeg.h" />
<ClInclude Include="..\..\Core\HLE\sceMt19937.h" />
<ClInclude Include="..\..\Core\HLE\sceNet.h" />
@@ -491,6 +492,7 @@
<ClCompile Include="..\..\Core\HLE\sceMd5.cpp" />
<ClCompile Include="..\..\Core\HLE\sceMp3.cpp" />
<ClCompile Include="..\..\Core\HLE\sceMp4.cpp" />
<ClCompile Include="..\..\Core\HLE\sceAac.cpp" />
<ClCompile Include="..\..\Core\HLE\sceMpeg.cpp" />
<ClCompile Include="..\..\Core\HLE\sceMt19937.cpp" />
<ClCompile Include="..\..\Core\HLE\sceNet.cpp" />
+6
View File
@@ -450,6 +450,9 @@
<ClCompile Include="..\..\Core\HLE\sceMp4.cpp">
<Filter>HLE</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\HLE\sceAac.cpp">
<Filter>HLE</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\HLE\sceMpeg.cpp">
<Filter>HLE</Filter>
</ClCompile>
@@ -1540,6 +1543,9 @@
<ClInclude Include="..\..\Core\HLE\sceMp4.h">
<Filter>HLE</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\HLE\sceAac.h">
<Filter>HLE</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\HLE\sceMpeg.h">
<Filter>HLE</Filter>
</ClInclude>
+1
View File
@@ -705,6 +705,7 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/HLE/sceMpeg.cpp \
$(SRC)/Core/HLE/sceMd5.cpp \
$(SRC)/Core/HLE/sceMp4.cpp \
$(SRC)/Core/HLE/sceAac.cpp \
$(SRC)/Core/HLE/sceMp3.cpp \
$(SRC)/Core/HLE/sceNet.cpp \
$(SRC)/Core/HLE/sceNet_lib.cpp \
+1
View File
@@ -751,6 +751,7 @@ SOURCES_CXX += \
$(COREDIR)/HLE/sceP3da.cpp \
$(COREDIR)/HLE/sceMt19937.cpp \
$(COREDIR)/HLE/sceMd5.cpp \
$(COREDIR)/HLE/sceAac.cpp \
$(COREDIR)/HLE/sceMp4.cpp \
$(COREDIR)/HLE/sceMp3.cpp \
$(COREDIR)/HLE/sceParseHttp.cpp \