cellPngDec (nothing changed)

This commit is contained in:
Nekotekina 2014-09-08 18:56:47 +04:00
parent 311a3b3e47
commit 5d951451c5
4 changed files with 321 additions and 154 deletions

View file

@ -9,7 +9,7 @@ bool LogBase::CheckLogging() const
return Ini.HLELogging.GetValue(); return Ini.HLELogging.GetValue();
} }
void LogBase::LogOutput(LogType type, const char* info, const std::string& text) void LogBase::LogOutput(LogType type, const char* info, const std::string& text) const
{ {
switch (type) switch (type)
{ {
@ -20,7 +20,7 @@ void LogBase::LogOutput(LogType type, const char* info, const std::string& text)
} }
} }
void LogBase::LogOutput(LogType type, const u32 id, const char* info, const std::string& text) void LogBase::LogOutput(LogType type, const u32 id, const char* info, const std::string& text) const
{ {
switch (type) switch (type)
{ {
@ -30,3 +30,53 @@ void LogBase::LogOutput(LogType type, const u32 id, const char* info, const std:
case LogError: LOG_ERROR(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break; case LogError: LOG_ERROR(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break;
} }
} }
hle::error::error(s32 errorCode, const char* errorText)
: code(errorCode)
, base(nullptr)
, text(errorText)
{
}
hle::error::error(s32 errorCode, const LogBase& errorBase, const char* errorText)
: code(errorCode)
, base(&errorBase)
, text(errorText)
{
}
hle::error::error(s32 errorCode, const LogBase* errorBase, const char* errorText)
: code(errorCode)
, base(errorBase)
, text(errorText)
{
}
void hle::error::print(const char* func)
{
if (!text.empty())
{
if (base)
{
if (func)
{
base->Error("%s(): %s (0x%X)", func, text.c_str(), code);
}
else
{
base->Error("%s (0x%X)", text.c_str(), code);
}
}
else
{
if (func)
{
LOG_ERROR(HLE, "%s(): %s (0x%X)", func, text.c_str(), code);
}
else
{
LOG_ERROR(HLE, "%s (0x%X)", text.c_str(), code);
}
}
}
}

View file

@ -13,8 +13,8 @@ class LogBase
LogError, LogError,
}; };
void LogOutput(LogType type, const char* info, const std::string& text); void LogOutput(LogType type, const char* info, const std::string& text) const;
void LogOutput(LogType type, const u32 id, const char* info, const std::string& text); void LogOutput(LogType type, const u32 id, const char* info, const std::string& text) const;
public: public:
void SetLogging(bool value) void SetLogging(bool value)
@ -29,17 +29,17 @@ public:
virtual const std::string& GetName() const = 0; virtual const std::string& GetName() const = 0;
template<typename... Targs> void Notice(const u32 id, const char* fmt, Targs... args) template<typename... Targs> void Notice(const u32 id, const char* fmt, Targs... args) const
{ {
LogOutput(LogNotice, id, ": ", fmt::Format(fmt, args...)); LogOutput(LogNotice, id, ": ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Notice(const char* fmt, Targs... args) template<typename... Targs> void Notice(const char* fmt, Targs... args) const
{ {
LogOutput(LogNotice, ": ", fmt::Format(fmt, args...)); LogOutput(LogNotice, ": ", fmt::Format(fmt, args...));
} }
template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args) template<typename... Targs> __forceinline void Log(const char* fmt, Targs... args) const
{ {
if (CheckLogging()) if (CheckLogging())
{ {
@ -47,7 +47,7 @@ public:
} }
} }
template<typename... Targs> __forceinline void Log(const u32 id, const char* fmt, Targs... args) template<typename... Targs> __forceinline void Log(const u32 id, const char* fmt, Targs... args) const
{ {
if (CheckLogging()) if (CheckLogging())
{ {
@ -55,43 +55,59 @@ public:
} }
} }
template<typename... Targs> void Success(const u32 id, const char* fmt, Targs... args) template<typename... Targs> void Success(const u32 id, const char* fmt, Targs... args) const
{ {
LogOutput(LogSuccess, id, ": ", fmt::Format(fmt, args...)); LogOutput(LogSuccess, id, ": ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Success(const char* fmt, Targs... args) template<typename... Targs> void Success(const char* fmt, Targs... args) const
{ {
LogOutput(LogSuccess, ": ", fmt::Format(fmt, args...)); LogOutput(LogSuccess, ": ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Warning(const u32 id, const char* fmt, Targs... args) template<typename... Targs> void Warning(const u32 id, const char* fmt, Targs... args) const
{ {
LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...)); LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Warning(const char* fmt, Targs... args) template<typename... Targs> void Warning(const char* fmt, Targs... args) const
{ {
LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...)); LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Error(const u32 id, const char* fmt, Targs... args) template<typename... Targs> void Error(const u32 id, const char* fmt, Targs... args) const
{ {
LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...)); LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Error(const char* fmt, Targs... args) template<typename... Targs> void Error(const char* fmt, Targs... args) const
{ {
LogOutput(LogError, " error: ", fmt::Format(fmt, args...)); LogOutput(LogError, " error: ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Todo(const u32 id, const char* fmt, Targs... args) template<typename... Targs> void Todo(const u32 id, const char* fmt, Targs... args) const
{ {
LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...)); LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...));
} }
template<typename... Targs> void Todo(const char* fmt, Targs... args) template<typename... Targs> void Todo(const char* fmt, Targs... args) const
{ {
LogOutput(LogError, " TODO: ", fmt::Format(fmt, args...)); LogOutput(LogError, " TODO: ", fmt::Format(fmt, args...));
} }
}; };
namespace hle
{
struct error
{
const s32 code;
const LogBase* const base;
const std::string text;
error(s32 errorCode, const char* errorText = nullptr);
error(s32 errorCode, const LogBase& base, const char* errorText = nullptr);
error(s32 errorCode, const LogBase* base, const char* errorText = nullptr);
void print(const char* func = nullptr);
};
}

View file

@ -18,11 +18,18 @@ u32 libpngdec;
u32 libpngdec_rtoc; u32 libpngdec_rtoc;
#endif #endif
u32 pngDecCreate(vm::ptr<const CellPngDecThreadInParam> param, vm::ptr<const CellPngDecExtThreadInParam> ext = {}) u32 pngDecCreate(
vm::ptr<const CellPngDecThreadInParam> param,
vm::ptr<const CellPngDecExtThreadInParam> ext = {})
{ {
// alloc memory (should probably use param->cbCtrlMallocFunc) // alloc memory (should probably use param->cbCtrlMallocFunc)
auto dec = CellPngDecMainHandle::make(Memory.Alloc(sizeof(PngDecoder), 128)); auto dec = CellPngDecMainHandle::make(Memory.Alloc(sizeof(PngDecoder), 128));
if (!dec)
{
throw hle::error(CELL_PNGDEC_ERROR_FATAL, "Memory allocation failed");
}
// initialize decoder // initialize decoder
dec->malloc = param->cbCtrlMallocFunc; dec->malloc = param->cbCtrlMallocFunc;
dec->malloc_arg = param->cbCtrlMallocArg; dec->malloc_arg = param->cbCtrlMallocArg;
@ -39,14 +46,26 @@ u32 pngDecCreate(vm::ptr<const CellPngDecThreadInParam> param, vm::ptr<const Cel
void pngDecDestroy(CellPngDecMainHandle dec) void pngDecDestroy(CellPngDecMainHandle dec)
{ {
Memory.Free(dec.addr()); if (!Memory.Free(dec.addr()))
{
throw hle::error(CELL_PNGDEC_ERROR_FATAL, "Memory deallocation failed");
}
} }
u32 pngDecOpen(CellPngDecMainHandle dec, vm::ptr<const CellPngDecSrc> src, vm::ptr<const CellPngDecCbCtrlStrm> cb = {}, vm::ptr<const CellPngDecOpnParam> param = {}) u32 pngDecOpen(
CellPngDecMainHandle dec,
vm::ptr<const CellPngDecSrc> src,
vm::ptr<const CellPngDecCbCtrlStrm> cb = {},
vm::ptr<const CellPngDecOpnParam> param = {})
{ {
// alloc memory (should probably use dec->malloc) // alloc memory (should probably use dec->malloc)
auto stream = CellPngDecSubHandle::make(Memory.Alloc(sizeof(PngStream), 128)); auto stream = CellPngDecSubHandle::make(Memory.Alloc(sizeof(PngStream), 128));
if (!stream)
{
throw hle::error(CELL_PNGDEC_ERROR_FATAL, "Memory allocation failed");
}
// initialize stream // initialize stream
stream->fd = 0; stream->fd = 0;
stream->src = *src; stream->src = *src;
@ -89,14 +108,23 @@ u32 pngDecOpen(CellPngDecMainHandle dec, vm::ptr<const CellPngDecSrc> src, vm::p
void pngDecClose(CellPngDecSubHandle stream) void pngDecClose(CellPngDecSubHandle stream)
{ {
cellFsClose(stream->fd); cellFsClose(stream->fd);
Memory.Free(stream.addr()); if (!Memory.Free(stream.addr()))
{
throw hle::error(CELL_PNGDEC_ERROR_FATAL, "Memory deallocation failed");
}
} }
void pngReadHeader(CellPngDecSubHandle stream, vm::ptr<CellPngDecInfo> info, vm::ptr<CellPngDecExtInfo> extInfo = {}) void pngReadHeader(
CellPngDecSubHandle stream,
vm::ptr<CellPngDecInfo> info,
vm::ptr<CellPngDecExtInfo> extInfo = {})
{ {
CellPngDecInfo& current_info = stream->info; CellPngDecInfo& current_info = stream->info;
assert(stream->fileSize >= 29); // Error: The file is smaller than the length of a PNG header if (stream->fileSize < 29)
{
throw hle::error(CELL_PNGDEC_ERROR_HEADER, "The file is smaller than the length of a PNG header");
}
//Write the header to buffer //Write the header to buffer
vm::var<u8[34]> buffer; // Alloc buffer for PNG header vm::var<u8[34]> buffer; // Alloc buffer for PNG header
@ -106,7 +134,7 @@ void pngReadHeader(CellPngDecSubHandle stream, vm::ptr<CellPngDecInfo> info, vm:
switch (stream->src.srcSelect.ToBE()) switch (stream->src.srcSelect.ToBE())
{ {
case se32(CELL_PNGDEC_BUFFER): case se32(CELL_PNGDEC_BUFFER):
memmove(buffer.begin(), vm::get_ptr<void>(stream->src.streamPtr), buffer.size()); memmove(buffer.begin(), stream->src.streamPtr.get_ptr(), buffer.size());
break; break;
case se32(CELL_PNGDEC_FILE): case se32(CELL_PNGDEC_FILE):
cellFsLseek(stream->fd, 0, CELL_SEEK_SET, pos); cellFsLseek(stream->fd, 0, CELL_SEEK_SET, pos);
@ -114,9 +142,12 @@ void pngReadHeader(CellPngDecSubHandle stream, vm::ptr<CellPngDecInfo> info, vm:
break; break;
} }
assert(buffer_32[0].ToBE() == se32(0x89504E47) && if (buffer_32[0].ToBE() != se32(0x89504E47) ||
buffer_32[1].ToBE() == se32(0x0D0A1A0A) && // Error: The first 8 bytes are not a valid PNG signature buffer_32[1].ToBE() != se32(0x0D0A1A0A) || // Error: The first 8 bytes are not a valid PNG signature
buffer_32[3].ToBE() == se32(0x49484452)); // Error: The PNG file does not start with an IHDR chunk buffer_32[3].ToBE() != se32(0x49484452)) // Error: The PNG file does not start with an IHDR chunk
{
throw hle::error(CELL_PNGDEC_ERROR_HEADER, "Invalid PNG header");
}
switch (buffer[25]) switch (buffer[25])
{ {
@ -125,7 +156,7 @@ void pngReadHeader(CellPngDecSubHandle stream, vm::ptr<CellPngDecInfo> info, vm:
case 3: current_info.colorSpace = CELL_PNGDEC_PALETTE; current_info.numComponents = 1; break; case 3: current_info.colorSpace = CELL_PNGDEC_PALETTE; current_info.numComponents = 1; break;
case 4: current_info.colorSpace = CELL_PNGDEC_GRAYSCALE_ALPHA; current_info.numComponents = 2; break; case 4: current_info.colorSpace = CELL_PNGDEC_GRAYSCALE_ALPHA; current_info.numComponents = 2; break;
case 6: current_info.colorSpace = CELL_PNGDEC_RGBA; current_info.numComponents = 4; break; case 6: current_info.colorSpace = CELL_PNGDEC_RGBA; current_info.numComponents = 4; break;
default: assert(!"Unknown color type"); return; // Not supported color type default: throw hle::error(CELL_PNGDEC_ERROR_HEADER, "Unknown color space (%d)"); return;
} }
current_info.imageWidth = buffer_32[4]; current_info.imageWidth = buffer_32[4];
@ -137,30 +168,65 @@ void pngReadHeader(CellPngDecSubHandle stream, vm::ptr<CellPngDecInfo> info, vm:
*info = current_info; *info = current_info;
} }
/* void pngDecSetParameter(
CellPngDecSubHandle stream,
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam, vm::ptr<CellPngDecDataOutInfo> dataOutInfo) vm::ptr<const CellPngDecInParam> inParam,
vm::ptr<CellPngDecOutParam> outParam,
vm::ptr<const CellPngDecExtInParam> extInParam = {},
vm::ptr<CellPngDecExtOutParam> extOutParam = {})
{ {
cellPngDec->Warning("cellPngDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)", CellPngDecInfo& current_info = stream->info;
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr()); CellPngDecOutParam& current_outParam = stream->outParam;
current_outParam.outputWidthByte = (current_info.imageWidth * current_info.numComponents * current_info.bitDepth) / 8;
current_outParam.outputWidth = current_info.imageWidth;
current_outParam.outputHeight = current_info.imageHeight;
current_outParam.outputColorSpace = inParam->outputColorSpace;
switch ((u32)current_outParam.outputColorSpace)
{
case CELL_PNGDEC_PALETTE:
case CELL_PNGDEC_GRAYSCALE: current_outParam.outputComponents = 1; break;
case CELL_PNGDEC_GRAYSCALE_ALPHA: current_outParam.outputComponents = 2; break;
case CELL_PNGDEC_RGB: current_outParam.outputComponents = 3; break;
case CELL_PNGDEC_RGBA:
case CELL_PNGDEC_ARGB: current_outParam.outputComponents = 4; break;
default: throw hle::error(CELL_PNGDEC_ERROR_ARG, fmt::Format("Unknown color space (%d)", (u32)current_outParam.outputColorSpace).c_str());
}
current_outParam.outputBitDepth = inParam->outputBitDepth;
current_outParam.outputMode = inParam->outputMode;
current_outParam.useMemorySpace = 0; // Unimplemented
*outParam = current_outParam;
}
void pngDecodeData(
CellPngDecSubHandle stream,
vm::ptr<u8> data,
vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellPngDecDataOutInfo> dataOutInfo,
vm::ptr<const CellPngDecCbCtrlDisp> cbCtrlDisp = {},
vm::ptr<CellPngDecDispParam> dispParam = {})
{
dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP; dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP;
CellPngDecSubHandle* subHandle_data;
if(!cellPngDec->CheckId(subHandle, subHandle_data))
return CELL_PNGDEC_ERROR_FATAL;
const u32& fd = subHandle_data->fd; const u32& fd = stream->fd;
const u64& fileSize = subHandle_data->fileSize; const u64& fileSize = stream->fileSize;
const CellPngDecOutParam& current_outParam = subHandle_data->outParam; const CellPngDecOutParam& current_outParam = stream->outParam;
//Copy the PNG file to a buffer //Copy the PNG file to a buffer
vm::var<unsigned char[]> png((u32)fileSize); vm::var<unsigned char[]> png((u32)fileSize);
vm::var<be_t<u64>> pos, nread; vm::var<be_t<u64>> pos, nread;
switch(subHandle_data->src.srcSelect.ToBE()) switch (stream->src.srcSelect.ToBE())
{ {
case se32(CELL_PNGDEC_BUFFER): case se32(CELL_PNGDEC_BUFFER):
memmove(png.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), png.size()); memmove(png.begin(), stream->src.streamPtr.get_ptr(), png.size());
break; break;
case se32(CELL_PNGDEC_FILE): case se32(CELL_PNGDEC_FILE):
@ -176,7 +242,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
stbi_load_from_memory(png.ptr(), (s32)fileSize, &width, &height, &actual_components, 4), stbi_load_from_memory(png.ptr(), (s32)fileSize, &width, &height, &actual_components, 4),
&::free &::free
); );
if (!image) return CELL_PNGDEC_ERROR_STREAM_FORMAT; if (!image) throw hle::error(CELL_PNGDEC_ERROR_STREAM_FORMAT);
const bool flip = current_outParam.outputMode == CELL_PNGDEC_BOTTOM_TO_TOP; const bool flip = current_outParam.outputMode == CELL_PNGDEC_BOTTOM_TO_TOP;
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine; const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
@ -255,75 +321,12 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
break; break;
default: default:
return CELL_PNGDEC_ERROR_ARG; throw hle::error(CELL_PNGDEC_ERROR_ARG);
} }
dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_FINISH; dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_FINISH;
return CELL_OK;
} }
int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellPngDecDataOutInfo> dataOutInfo, vm::ptr<CellPngDecCbCtrlDisp> cbCtrlDisp, vm::ptr<CellPngDecDispParam> dispParam)
{
cellPngDec->Warning("cellPngDecExtDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x, cbCtrlDisp_addr=0x%x, dispParam=0x%x)",
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr(), cbCtrlDisp.addr(), dispParam.addr());
if (cbCtrlDisp) cellPngDec->Warning("*** cbCtrlDisp->cbCtrlDispFunc_addr=0x%x", (u32)cbCtrlDisp->cbCtrlDispFunc_addr);
return cellPngDecDecodeData(mainHandle, subHandle, data, dataCtrlParam, dataOutInfo);
}
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam)
{
cellPngDec->Warning("cellPngDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
mainHandle, subHandle, inParam.addr(), outParam.addr());
CellPngDecSubHandle* subHandle_data;
if(!cellPngDec->CheckId(subHandle, subHandle_data))
return CELL_PNGDEC_ERROR_FATAL;
CellPngDecInfo& current_info = subHandle_data->info;
CellPngDecOutParam& current_outParam = subHandle_data->outParam;
current_outParam.outputWidthByte = (current_info.imageWidth * current_info.numComponents * current_info.bitDepth) / 8;
current_outParam.outputWidth = current_info.imageWidth;
current_outParam.outputHeight = current_info.imageHeight;
current_outParam.outputColorSpace = inParam->outputColorSpace;
switch ((u32)current_outParam.outputColorSpace)
{
case CELL_PNGDEC_PALETTE:
case CELL_PNGDEC_GRAYSCALE: current_outParam.outputComponents = 1; break;
case CELL_PNGDEC_GRAYSCALE_ALPHA: current_outParam.outputComponents = 2; break;
case CELL_PNGDEC_RGB: current_outParam.outputComponents = 3; break;
case CELL_PNGDEC_RGBA:
case CELL_PNGDEC_ARGB: current_outParam.outputComponents = 4; break;
default: return CELL_PNGDEC_ERROR_ARG; // Not supported color space
}
current_outParam.outputBitDepth = inParam->outputBitDepth;
current_outParam.outputMode = inParam->outputMode;
current_outParam.useMemorySpace = 0; // Unimplemented
*outParam = current_outParam;
return CELL_OK;
}
int cellPngDecExtSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam,
vm::ptr<CellPngDecExtInParam> extInParam, vm::ptr<CellPngDecExtOutParam> extOutParam)
{
cellPngDec->Warning("cellPngDecExtSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x, extInParam=0x%x, extOutParam=0x%x",
mainHandle, subHandle, inParam.addr(), outParam.addr(), extInParam.addr(), extOutParam.addr());
return cellPngDecSetParameter(mainHandle, subHandle, inParam, outParam);
}*/
s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInParam> threadInParam, vm::ptr<CellPngDecThreadOutParam> threadOutParam) s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInParam> threadInParam, vm::ptr<CellPngDecThreadOutParam> threadOutParam)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
@ -333,7 +336,16 @@ s32 cellPngDecCreate(vm::ptr<u32> mainHandle, vm::ptr<const CellPngDecThreadInPa
cellPngDec->Warning("cellPngDecCreate(mainHandle_addr=0x%x, threadInParam_addr=0x%x, threadOutParam_addr=0x%x)", cellPngDec->Warning("cellPngDecCreate(mainHandle_addr=0x%x, threadInParam_addr=0x%x, threadOutParam_addr=0x%x)",
mainHandle.addr(), threadInParam.addr(), threadOutParam.addr()); mainHandle.addr(), threadInParam.addr(), threadOutParam.addr());
try
{
// create decoder
*mainHandle = pngDecCreate(threadInParam); *mainHandle = pngDecCreate(threadInParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
// set codec version // set codec version
threadOutParam->pngCodecVersion = PNGDEC_CODEC_VERSION; threadOutParam->pngCodecVersion = PNGDEC_CODEC_VERSION;
@ -356,8 +368,16 @@ s32 cellPngDecExtCreate(
cellPngDec->Warning("cellPngDecCreate(mainHandle_addr=0x%x, threadInParam_addr=0x%x, threadOutParam_addr=0x%x, extThreadInParam_addr=0x%x, extThreadOutParam_addr=0x%x)", cellPngDec->Warning("cellPngDecCreate(mainHandle_addr=0x%x, threadInParam_addr=0x%x, threadOutParam_addr=0x%x, extThreadInParam_addr=0x%x, extThreadOutParam_addr=0x%x)",
mainHandle.addr(), threadInParam.addr(), threadOutParam.addr(), extThreadInParam.addr(), extThreadOutParam.addr()); mainHandle.addr(), threadInParam.addr(), threadOutParam.addr(), extThreadInParam.addr(), extThreadOutParam.addr());
try
{
// create decoder // create decoder
*mainHandle = pngDecCreate(threadInParam, extThreadInParam); *mainHandle = pngDecCreate(threadInParam, extThreadInParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
// set codec version // set codec version
threadOutParam->pngCodecVersion = PNGDEC_CODEC_VERSION; threadOutParam->pngCodecVersion = PNGDEC_CODEC_VERSION;
@ -376,7 +396,16 @@ s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle)
#else #else
cellPngDec->Warning("cellPngDecDestroy(mainHandle=0x%x)", mainHandle.addr()); cellPngDec->Warning("cellPngDecDestroy(mainHandle=0x%x)", mainHandle.addr());
try
{
pngDecDestroy(mainHandle); pngDecDestroy(mainHandle);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
} }
@ -394,8 +423,16 @@ s32 cellPngDecOpen(
cellPngDec->Warning("cellPngDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)", cellPngDec->Warning("cellPngDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), src.addr(), openInfo.addr()); mainHandle.addr(), subHandle.addr(), src.addr(), openInfo.addr());
try
{
// create stream handle // create stream handle
*subHandle = pngDecOpen(mainHandle, src); *subHandle = pngDecOpen(mainHandle, src);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
// set memory info // set memory info
openInfo->initSpaceAllocated = 4096; openInfo->initSpaceAllocated = 4096;
@ -419,8 +456,16 @@ s32 cellPngDecExtOpen(
cellPngDec->Warning("cellPngDecExtOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x, cbCtrlStrm_addr=0x%x, opnParam_addr=0x%x)", cellPngDec->Warning("cellPngDecExtOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x, cbCtrlStrm_addr=0x%x, opnParam_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), src.addr(), openInfo.addr(), cbCtrlStrm.addr(), opnParam.addr()); mainHandle.addr(), subHandle.addr(), src.addr(), openInfo.addr(), cbCtrlStrm.addr(), opnParam.addr());
try
{
// create stream handle // create stream handle
*subHandle = pngDecOpen(mainHandle, src, cbCtrlStrm, opnParam); *subHandle = pngDecOpen(mainHandle, src, cbCtrlStrm, opnParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
// set memory info // set memory info
openInfo->initSpaceAllocated = 4096; openInfo->initSpaceAllocated = 4096;
@ -437,7 +482,15 @@ s32 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHand
#else #else
cellPngDec->Warning("cellPngDecClose(mainHandle=0x%x, subHandle=0x%x)", mainHandle.addr(), subHandle.addr()); cellPngDec->Warning("cellPngDecClose(mainHandle=0x%x, subHandle=0x%x)", mainHandle.addr(), subHandle.addr());
try
{
pngDecClose(subHandle); pngDecClose(subHandle);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
@ -452,7 +505,15 @@ s32 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle su
cellPngDec->Warning("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", cellPngDec->Warning("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), info.addr()); mainHandle.addr(), subHandle.addr(), info.addr());
try
{
pngReadHeader(subHandle, info); pngReadHeader(subHandle, info);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
@ -471,7 +532,15 @@ s32 cellPngDecExtReadHeader(
cellPngDec->Warning("cellPngDecExtReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x, extInfo_addr=0x%x)", cellPngDec->Warning("cellPngDecExtReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x, extInfo_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), info.addr(), extInfo.addr()); mainHandle.addr(), subHandle.addr(), info.addr(), extInfo.addr());
try
{
pngReadHeader(subHandle, info, extInfo); pngReadHeader(subHandle, info, extInfo);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
@ -487,7 +556,19 @@ s32 cellPngDecSetParameter(
cellPngDec->Warning("%s()", __FUNCTION__); cellPngDec->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libpngdec + 0x33F4, libpngdec_rtoc); return GetCurrentPPUThread().FastCall2(libpngdec + 0x33F4, libpngdec_rtoc);
#else #else
UNIMPLEMENTED_FUNC(cellPngDec); cellPngDec->Warning("cellPngDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), inParam.addr(), outParam.addr());
try
{
pngDecSetParameter(subHandle, inParam, outParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
} }
@ -504,7 +585,19 @@ s32 cellPngDecExtSetParameter(
cellPngDec->Warning("%s()", __FUNCTION__); cellPngDec->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libpngdec + 0x33EC, libpngdec_rtoc); return GetCurrentPPUThread().FastCall2(libpngdec + 0x33EC, libpngdec_rtoc);
#else #else
UNIMPLEMENTED_FUNC(cellPngDec); cellPngDec->Warning("cellPngDecExtSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x, extInParam=0x%x, extOutParam=0x%x",
mainHandle.addr(), subHandle.addr(), inParam.addr(), outParam.addr(), extInParam.addr(), extOutParam.addr());
try
{
pngDecSetParameter(subHandle, inParam, outParam, extInParam, extOutParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
} }
@ -520,7 +613,19 @@ s32 cellPngDecDecodeData(
cellPngDec->Warning("%s()", __FUNCTION__); cellPngDec->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libpngdec + 0x5D40, libpngdec_rtoc); return GetCurrentPPUThread().FastCall2(libpngdec + 0x5D40, libpngdec_rtoc);
#else #else
UNIMPLEMENTED_FUNC(cellPngDec); cellPngDec->Warning("cellPngDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
try
{
pngDecodeData(subHandle, data, dataCtrlParam, dataOutInfo);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
} }
@ -538,7 +643,19 @@ s32 cellPngDecExtDecodeData(
cellPngDec->Warning("%s()", __FUNCTION__); cellPngDec->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libpngdec + 0x5D38, libpngdec_rtoc); return GetCurrentPPUThread().FastCall2(libpngdec + 0x5D38, libpngdec_rtoc);
#else #else
UNIMPLEMENTED_FUNC(cellPngDec); cellPngDec->Warning("cellPngDecExtDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x, cbCtrlDisp_addr=0x%x, dispParam_addr=0x%x)",
mainHandle.addr(), subHandle.addr(), data.addr(), dataCtrlParam.addr(), dataOutInfo.addr(), cbCtrlDisp.addr(), dispParam.addr());
try
{
pngDecodeData(subHandle, data, dataCtrlParam, dataOutInfo, cbCtrlDisp, dispParam);
}
catch (hle::error& e)
{
e.print(__FUNCTION__);
return e.code;
}
return CELL_OK; return CELL_OK;
#endif #endif
} }
@ -546,7 +663,7 @@ s32 cellPngDecExtDecodeData(
s32 cellPngDecGetUnknownChunks( s32 cellPngDecGetUnknownChunks(
CellPngDecMainHandle mainHandle, CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle, CellPngDecSubHandle subHandle,
vm::ptr<CellPngUnknownChunk, 2> unknownChunk, vm::ptr<vm::bptr<CellPngUnknownChunk>> unknownChunk,
vm::ptr<u32> unknownChunkNumber) vm::ptr<u32> unknownChunkNumber)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
@ -727,7 +844,7 @@ s32 cellPngDecGetTextChunk(
CellPngDecMainHandle mainHandle, CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle, CellPngDecSubHandle subHandle,
vm::ptr<u32> textInfoNum, vm::ptr<u32> textInfoNum,
vm::ptr<CellPngTextInfo, 2> textInfo) vm::ptr<vm::bptr<CellPngTextInfo>> textInfo)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellPngDec->Warning("%s()", __FUNCTION__); cellPngDec->Warning("%s()", __FUNCTION__);

View file

@ -221,7 +221,7 @@ s32 cellPngDecGetTextChunk(
CellPngDecMainHandle mainHandle, CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle, CellPngDecSubHandle subHandle,
vm::ptr<u32> textInfoNum, vm::ptr<u32> textInfoNum,
vm::ptr<CellPngTextInfo, 2> textInfo); vm::ptr<vm::bptr<CellPngTextInfo>> textInfo);
s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngPLTE> plte); s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr<CellPngPLTE> plte);
@ -256,7 +256,7 @@ s32 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa
s32 cellPngDecGetUnknownChunks( s32 cellPngDecGetUnknownChunks(
CellPngDecMainHandle mainHandle, CellPngDecMainHandle mainHandle,
CellPngDecSubHandle subHandle, CellPngDecSubHandle subHandle,
vm::ptr<CellPngUnknownChunk, 2> unknownChunk, vm::ptr<vm::bptr<CellPngUnknownChunk>> unknownChunk,
vm::ptr<u32> unknownChunkNumber); vm::ptr<u32> unknownChunkNumber);
@ -380,23 +380,7 @@ s32 cellPngDecExtDecodeData(
vm::ptr<const CellPngDecCbCtrlDisp> cbCtrlDisp, vm::ptr<const CellPngDecCbCtrlDisp> cbCtrlDisp,
vm::ptr<CellPngDecDispParam> dispParam); vm::ptr<CellPngDecDispParam> dispParam);
//// Custom structs // Custom structs
//struct CellPngDecSubHandle
//{
// be_t<u32> fd;
// be_t<u64> fileSize;
// CellPngDecInfo info;
// CellPngDecOutParam outParam;
// CellPngDecSrc src;
//};
//
//struct CellPngDecMainHandle
//{
// be_t<u32> mainHandle;
// be_t<u32> threadInParam;
// be_t<u32> threadOutParam;
//};
struct PngDecoder struct PngDecoder
{ {
vm::ptr<CellPngDecCbControlMalloc> malloc; vm::ptr<CellPngDecCbControlMalloc> malloc;