From c9c505740b385793d93e5880deb7c3647cb37fd5 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 4 Apr 2014 22:46:19 +0800 Subject: [PATCH 1/5] small improve in sceAac Reference from JPCSP source --- Core/HLE/sceMp4.cpp | 70 +++++++++++++++++++++++++++++++++++++-------- Core/HLE/sceMp4.h | 5 ++++ 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index bb4102225..b186eab86 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -18,6 +18,7 @@ #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/Reporting.h" +#include "Core/HLE/sceMp4.h" u32 sceMp4Init() @@ -134,9 +135,54 @@ u32 sceMp4SearchSyncSampleNum() return 0; } -u32 sceAacInit() +u32 sceAacInit(u32 parameters, u32 unknown1, u32 unknown2, u32 unknown3) { - ERROR_LOG_REPORT(ME, "UNIMPL sceAacInit()"); + ERROR_LOG(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); +// ERROR_LOG_REPORT(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); + if (!Memory::IsValidAddress(parameters)) + return ERROR_AAC_INVALID_ADDRESS; + long startPos = (long)Memory::Read_U32(parameters) << 32 | Memory::Read_U32(parameters + 4); // Audio data frame start position. + long endPos = (long)Memory::Read_U32(parameters + 8) << 32 | Memory::Read_U32(parameters + 12); // Audio data frame end position. + int bufferAddr = (long)Memory::Read_U32(parameters + 16); // Input AAC data buffer. + int bufferSize = Memory::Read_U32(parameters + 20); // Input AAC data buffer size. + int outputAddr = Memory::Read_U32(parameters + 24); // Output PCM data buffer. + int outputSize = Memory::Read_U32(parameters + 28); // Output PCM data buffer size. + int freq = Memory::Read_U32(parameters + 32); // Frequency. + int reserved = Memory::Read_U32(parameters + 36); // Always null. + if (bufferAddr == 0 || outputAddr == 0) { + ERROR_LOG(ME, "sceAacInit() AAC INVALID ADDRESS %08x", bufferAddr); + return ERROR_AAC_INVALID_ADDRESS; + } + if (startPos < 0 || startPos > endPos) { + ERROR_LOG(ME, "sceAacInit() AAC INVALID startPos %i", startPos); + return ERROR_AAC_INVALID_PARAMETER; + } + if (bufferSize < 8192 || outputSize < 8192 || reserved != 0) { + ERROR_LOG(ME, "sceAacInit() AAC INVALID PARAMETER, bufferSize %i outputSize %i reserved %i", bufferSize, outputSize, reserved); + return ERROR_AAC_INVALID_PARAMETER; + } + if (freq != 44100 && freq != 32000 && freq != 48000 && freq != 24000) { + ERROR_LOG(ME, "sceAacInit() AAC INVALID freq %i", freq); + return ERROR_AAC_INVALID_PARAMETER; + } + + /* + int id = -1; + for (int i = 0; i < ids.length; i++) { + if (!ids[i].isInit()) { + id = i; + break; + } + } + if (id < 0) { + return SceKernelErrors.ERROR_AAC_NO_MORE_FREE_ID; + } + + ids[id].init(bufferAddr, bufferSize, outputAddr, outputSize); + + return id; + */ + return 0; } @@ -158,9 +204,9 @@ u32 sceAacTermResource() return 0; } -u32 sceAacDecode() +u32 sceAacDecode(u32 id, u32 bufferAddress) { - ERROR_LOG(ME, "UNIMPL sceAacDecode()"); + ERROR_LOG(ME, "UNIMPL sceAacDecode(id %i, bufferAddress %08x)", id, bufferAddress); return 0; } @@ -176,9 +222,9 @@ u32 sceAacSetLoopNum() return 0; } -u32 sceAacCheckStreamDataNeeded() +u32 sceAacCheckStreamDataNeeded(u32 id) { - ERROR_LOG(ME, "UNIMPL sceAacCheckStreamDataNeeded()"); + ERROR_LOG(ME, "UNIMPL sceAacCheckStreamDataNeeded(%i)", id); return 0; } @@ -200,9 +246,9 @@ u32 sceAacGetMaxOutputSample() return 0; } -u32 sceAacGetSumDecodedSample() +u32 sceAacGetSumDecodedSample(u32 id) { - ERROR_LOG(ME, "UNIMPL sceAacGetSumDecodedSample()"); + ERROR_LOG(ME, "UNIMPL sceAacGetSumDecodedSample(%i)", id); return 0; } @@ -257,18 +303,18 @@ const HLEFunction sceMp4[] = // 395 const HLEFunction sceAac[] = { - {0xE0C89ACA, WrapU_V, "sceAacInit"}, + {0xE0C89ACA, WrapU_UUUU, "sceAacInit"}, {0x33B8C009, WrapU_V, "sceAacExit"}, {0x5CFFC57C, WrapU_V, "sceAacInitResource"}, {0x23D35CAE, WrapU_V, "sceAacTermResource"}, - {0x7E4CFEE4, WrapU_V, "sceAacDecode"}, + {0x7E4CFEE4, WrapU_UU, "sceAacDecode"}, {0x523347D9, WrapU_V, "sceAacGetLoopNum"}, {0xBBDD6403, WrapU_V, "sceAacSetLoopNum"}, - {0xD7C51541, WrapU_V, "sceAacCheckStreamDataNeeded"}, + {0xD7C51541, WrapU_U, "sceAacCheckStreamDataNeeded"}, {0xAC6DCBE3, WrapU_V, "sceAacNotifyAddStreamData"}, {0x02098C69, WrapU_V, "sceAacGetInfoToAddStreamData"}, {0x6DC7758A, WrapU_V, "sceAacGetMaxOutputSample"}, - {0x506BF66C, WrapU_V, "sceAacGetSumDecodedSample"}, + {0x506BF66C, WrapU_U, "sceAacGetSumDecodedSample"}, {0xD2DA2BBA, WrapU_V, "sceAacResetPlayPosition"}, }; diff --git a/Core/HLE/sceMp4.h b/Core/HLE/sceMp4.h index 5dfb300e6..2f50cb421 100644 --- a/Core/HLE/sceMp4.h +++ b/Core/HLE/sceMp4.h @@ -17,4 +17,9 @@ #pragma once +enum { + ERROR_AAC_INVALID_ADDRESS = 0x80691002, + ERROR_AAC_INVALID_PARAMETER = 0x80691003, +}; + void Register_sceMp4(); From c55204604d687b623b3330f4c55cd82ff5e07042 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 4 Apr 2014 22:48:58 +0800 Subject: [PATCH 2/5] oop --- Core/HLE/sceMp4.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index b186eab86..38e5ef689 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -137,8 +137,7 @@ u32 sceMp4SearchSyncSampleNum() u32 sceAacInit(u32 parameters, u32 unknown1, u32 unknown2, u32 unknown3) { - ERROR_LOG(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); -// ERROR_LOG_REPORT(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); + ERROR_LOG_REPORT(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); if (!Memory::IsValidAddress(parameters)) return ERROR_AAC_INVALID_ADDRESS; long startPos = (long)Memory::Read_U32(parameters) << 32 | Memory::Read_U32(parameters + 4); // Audio data frame start position. From 2495044c78d2c452986bd98fc73cd69ea3c861dc Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 4 Apr 2014 22:56:06 +0800 Subject: [PATCH 3/5] Add sceAacInitResource --- Core/HLE/sceMp4.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 38e5ef689..86dbf21e3 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -191,9 +191,9 @@ u32 sceAacExit() return 0; } -u32 sceAacInitResource() +u32 sceAacInitResource(u32 numberIds) { - ERROR_LOG_REPORT(ME, "UNIMPL sceAacInitResource()"); + ERROR_LOG_REPORT(ME, "UNIMPL sceAacInitResource(%i)", numberIds); return 0; } @@ -304,7 +304,7 @@ const HLEFunction sceMp4[] = const HLEFunction sceAac[] = { {0xE0C89ACA, WrapU_UUUU, "sceAacInit"}, {0x33B8C009, WrapU_V, "sceAacExit"}, - {0x5CFFC57C, WrapU_V, "sceAacInitResource"}, + {0x5CFFC57C, WrapU_U, "sceAacInitResource"}, {0x23D35CAE, WrapU_V, "sceAacTermResource"}, {0x7E4CFEE4, WrapU_UU, "sceAacDecode"}, {0x523347D9, WrapU_V, "sceAacGetLoopNum"}, From 075a0c7e3eb2f60dcb99eea7517555bddf413999 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 5 Apr 2014 05:33:29 +0800 Subject: [PATCH 4/5] Change long to u64,Add to do --- Core/HLE/sceMp4.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 86dbf21e3..635e7643c 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -140,9 +140,9 @@ u32 sceAacInit(u32 parameters, u32 unknown1, u32 unknown2, u32 unknown3) ERROR_LOG_REPORT(ME, "UNIMPL sceAacInit(parameters %08x, unknown1 %08x, unknown2 %08x, unknown3 %08x)", unknown1, unknown2, unknown3); if (!Memory::IsValidAddress(parameters)) return ERROR_AAC_INVALID_ADDRESS; - long startPos = (long)Memory::Read_U32(parameters) << 32 | Memory::Read_U32(parameters + 4); // Audio data frame start position. - long endPos = (long)Memory::Read_U32(parameters + 8) << 32 | Memory::Read_U32(parameters + 12); // Audio data frame end position. - int bufferAddr = (long)Memory::Read_U32(parameters + 16); // Input AAC data buffer. + u64 startPos = (u64)Memory::Read_U32(parameters) << 32 | Memory::Read_U32(parameters + 4); // Audio data frame start position. + u64 endPos = (u64)Memory::Read_U32(parameters + 8) << 32 | Memory::Read_U32(parameters + 12); // Audio data frame end position. + int bufferAddr = Memory::Read_U32(parameters + 16); // Input AAC data buffer. int bufferSize = Memory::Read_U32(parameters + 20); // Input AAC data buffer size. int outputAddr = Memory::Read_U32(parameters + 24); // Output PCM data buffer. int outputSize = Memory::Read_U32(parameters + 28); // Output PCM data buffer size. @@ -166,6 +166,7 @@ u32 sceAacInit(u32 parameters, u32 unknown1, u32 unknown2, u32 unknown3) } /* + To Do: Need translate the below code from JPCSP int id = -1; for (int i = 0; i < ids.length; i++) { if (!ids[i].isInit()) { From 5482ad8143fc10912aa46dec730aa7325c579fae Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 8 Apr 2014 20:52:05 +0800 Subject: [PATCH 5/5] Remove comment --- Core/HLE/sceMp4.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 635e7643c..427bead10 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -165,23 +165,7 @@ u32 sceAacInit(u32 parameters, u32 unknown1, u32 unknown2, u32 unknown3) return ERROR_AAC_INVALID_PARAMETER; } - /* - To Do: Need translate the below code from JPCSP - int id = -1; - for (int i = 0; i < ids.length; i++) { - if (!ids[i].isInit()) { - id = i; - break; - } - } - if (id < 0) { - return SceKernelErrors.ERROR_AAC_NO_MORE_FREE_ID; - } - - ids[id].init(bufferAddr, bufferSize, outputAddr, outputSize); - - return id; - */ + //To Do return 0; }