1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Improved image decoding modules

* Huge improvement in the speed of cell{Png|Gif|Jpg}DecDecodeData when
reading input files.

Note: Sorry if this commit is too "small", but I need to sync every
change since I use two PCs.
This commit is contained in:
Alexandro Sánchez Bach 2013-09-19 23:40:43 +02:00
parent 20665b9f89
commit a11de0f607
3 changed files with 6 additions and 21 deletions

View File

@ -193,14 +193,9 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataC
//Decode GIF file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *gif = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
gif[i] = Memory.Read8(buffer+i);
}
unsigned char *gif = (unsigned char*)Memory.VirtualToRealAddr(buffer);
unsigned char *image = stbi_load_from_memory(gif, fileSize, &width, &height, &actual_components, 4);
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)gif, fileSize, &width, &height, &actual_components, 4);
delete[] gif;
if (!image) return CELL_GIFDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;

View File

@ -213,14 +213,9 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataC
//Decode JPG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *jpg = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
jpg[i] = Memory.Read8(buffer+i);
}
unsigned char *jpg = (unsigned char*)Memory.VirtualToRealAddr(buffer);
unsigned char *image = stbi_load_from_memory(jpg, fileSize, &width, &height, &actual_components, 4);
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)jpg, fileSize, &width, &height, &actual_components, 4);
delete[] jpg;
if (!image) return CELL_JPGDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;

View File

@ -198,14 +198,9 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, u32 data_addr, u32 dataC
//Decode PNG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
unsigned char *png = new unsigned char [fileSize];
for(u32 i = 0; i < fileSize; i++){
png[i] = Memory.Read8(buffer+i);
}
unsigned char *png = (unsigned char*)Memory.VirtualToRealAddr(buffer);
unsigned char *image = stbi_load_from_memory(png, fileSize, &width, &height, &actual_components, 4);
Memory.Free(buffer);
unsigned char *image = stbi_load_from_memory((const unsigned char*)png, fileSize, &width, &height, &actual_components, 4);
delete[] png;
if (!image) return CELL_PNGDEC_ERROR_STREAM_FORMAT;
u32 image_size = width * height * 4;