mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix memory leaks in sceJpeg
This commit is contained in:
parent
c599b6b3ad
commit
240ebcb085
2 changed files with 19 additions and 26 deletions
|
@ -87,7 +87,7 @@ static void __JpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferW
|
||||||
u8 cb = *Cb++;
|
u8 cb = *Cb++;
|
||||||
u8 cr = *Cr++;
|
u8 cr = *Cr++;
|
||||||
|
|
||||||
// Convert to ABGR
|
// Convert to ABGR. This is not a fast way to do it.
|
||||||
u32 abgr0 = convertYCbCrToABGR(y0, cb, cr);
|
u32 abgr0 = convertYCbCrToABGR(y0, cb, cr);
|
||||||
u32 abgr1 = convertYCbCrToABGR(y1, cb, cr);
|
u32 abgr1 = convertYCbCrToABGR(y1, cb, cr);
|
||||||
u32 abgr2 = convertYCbCrToABGR(y2, cb, cr);
|
u32 abgr2 = convertYCbCrToABGR(y2, cb, cr);
|
||||||
|
@ -170,6 +170,8 @@ static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
|
||||||
ERROR_LOG(ME, "sceJpegGetOutputInfo: Bad JPEG data");
|
ERROR_LOG(ME, "sceJpegGetOutputInfo: Bad JPEG data");
|
||||||
return getYCbCrBufferSize(0, 0);
|
return getYCbCrBufferSize(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(jpegBuf);
|
||||||
|
|
||||||
// Buffer to store info about the color space in use.
|
// Buffer to store info about the color space in use.
|
||||||
// - Bits 24 to 32 (Always empty): 0x00
|
// - Bits 24 to 32 (Always empty): 0x00
|
||||||
|
@ -196,6 +198,7 @@ static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
|
||||||
|
|
||||||
return getYCbCrBufferSize(width, height);
|
return getYCbCrBufferSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceJpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr, int dhtMode)
|
static int sceJpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr, int dhtMode)
|
||||||
{
|
{
|
||||||
if (!Memory::IsValidAddress(jpegAddr)) {
|
if (!Memory::IsValidAddress(jpegAddr)) {
|
||||||
|
@ -282,6 +285,8 @@ static int __JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr) {
|
||||||
__JpegConvertRGBToYCbCr(jpegBuf, yCbCrAddr, width, height);
|
__JpegConvertRGBToYCbCr(jpegBuf, yCbCrAddr, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(jpegBuf);
|
||||||
|
|
||||||
// TODO: There's more...
|
// TODO: There's more...
|
||||||
|
|
||||||
return getWidthHeight(width, height);
|
return getWidthHeight(width, height);
|
||||||
|
|
|
@ -837,8 +837,7 @@ struct EncodingBitsInfo {
|
||||||
u32 mask;
|
u32 mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
const EncodingBitsInfo encodingBits[NumEncodings] =
|
const EncodingBitsInfo encodingBits[NumEncodings] = {
|
||||||
{
|
|
||||||
EncodingBitsInfo(26, 6), //IMME
|
EncodingBitsInfo(26, 6), //IMME
|
||||||
EncodingBitsInfo(0, 6), //Special
|
EncodingBitsInfo(0, 6), //Special
|
||||||
EncodingBitsInfo(0, 6), //special2
|
EncodingBitsInfo(0, 6), //special2
|
||||||
|
@ -868,8 +867,7 @@ const EncodingBitsInfo encodingBits[NumEncodings] =
|
||||||
EncodingBitsInfo(0, 0), //Rese
|
EncodingBitsInfo(0, 0), //Rese
|
||||||
};
|
};
|
||||||
|
|
||||||
const MIPSInstruction *mipsTables[NumEncodings] =
|
const MIPSInstruction *mipsTables[NumEncodings] = {
|
||||||
{
|
|
||||||
tableImmediate,
|
tableImmediate,
|
||||||
tableSpecial,
|
tableSpecial,
|
||||||
tableSpecial2,
|
tableSpecial2,
|
||||||
|
@ -908,39 +906,32 @@ const MIPSInstruction *mipsTables[NumEncodings] =
|
||||||
// {Comp_AND, Dis_AND, Info_DP, 0, DATAP(0, 0), 0x20F, {0}},
|
// {Comp_AND, Dis_AND, Info_DP, 0, DATAP(0, 0), 0x20F, {0}},
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
// TODO : generate smart dispatcher functions from above tables
|
||||||
//Todo : generate dispatcher functions from above tables
|
// instead of this slow method.
|
||||||
//instead of this horribly slow abomination
|
const MIPSInstruction *MIPSGetInstruction(MIPSOpcode op) {
|
||||||
|
|
||||||
const MIPSInstruction *MIPSGetInstruction(MIPSOpcode op)
|
|
||||||
{
|
|
||||||
MipsEncoding encoding = Imme;
|
MipsEncoding encoding = Imme;
|
||||||
const MIPSInstruction *instr = &tableImmediate[op>>26];
|
const MIPSInstruction *instr = &tableImmediate[op.encoding >> 26];
|
||||||
while (instr->altEncoding != Instruc)
|
while (instr->altEncoding != Instruc) {
|
||||||
{
|
if (instr->altEncoding == Inval) {
|
||||||
if (instr->altEncoding == Inval)
|
|
||||||
{
|
|
||||||
//ERROR_LOG(CPU, "Invalid instruction %08x in table %i, entry %i", op, (int)encoding, subop);
|
//ERROR_LOG(CPU, "Invalid instruction %08x in table %i, entry %i", op, (int)encoding, subop);
|
||||||
return 0; //invalid instruction
|
return 0; //invalid instruction
|
||||||
}
|
}
|
||||||
encoding = instr->altEncoding;
|
encoding = instr->altEncoding;
|
||||||
|
|
||||||
const MIPSInstruction *table = mipsTables[encoding];
|
const MIPSInstruction *table = mipsTables[encoding];
|
||||||
const u32 subop = (op >> encodingBits[encoding].shift) & encodingBits[encoding].mask;
|
const u32 subop = (op.encoding >> encodingBits[encoding].shift) & encodingBits[encoding].mask;
|
||||||
instr = &table[subop];
|
instr = &table[subop];
|
||||||
}
|
}
|
||||||
//alright, we have a valid MIPS instruction!
|
//alright, we have a valid MIPS instruction!
|
||||||
return instr;
|
return instr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIPSCompileOp(MIPSOpcode op)
|
void MIPSCompileOp(MIPSOpcode op) {
|
||||||
{
|
|
||||||
if (op == 0)
|
if (op == 0)
|
||||||
return;
|
return;
|
||||||
const MIPSInstruction *instr = MIPSGetInstruction(op);
|
const MIPSInstruction *instr = MIPSGetInstruction(op);
|
||||||
const MIPSInfo info = MIPSGetInfo(op);
|
const MIPSInfo info = MIPSGetInfo(op);
|
||||||
if (instr)
|
if (instr) {
|
||||||
{
|
|
||||||
if (instr->compile) {
|
if (instr->compile) {
|
||||||
(MIPSComp::jit->*(instr->compile))(op);
|
(MIPSComp::jit->*(instr->compile))(op);
|
||||||
} else {
|
} else {
|
||||||
|
@ -949,15 +940,12 @@ void MIPSCompileOp(MIPSOpcode op)
|
||||||
|
|
||||||
if (info & OUT_EAT_PREFIX)
|
if (info & OUT_EAT_PREFIX)
|
||||||
MIPSComp::jit->EatPrefix();
|
MIPSComp::jit->EatPrefix();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ERROR_LOG_REPORT(CPU, "MIPSCompileOp: Invalid instruction %08x", op.encoding);
|
ERROR_LOG_REPORT(CPU, "MIPSCompileOp: Invalid instruction %08x", op.encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, bool tabsToSpaces)
|
void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, bool tabsToSpaces) {
|
||||||
{
|
|
||||||
if (op == 0) {
|
if (op == 0) {
|
||||||
sprintf(out,"nop");
|
sprintf(out,"nop");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue