Skip to content

Commit

Permalink
Merge pull request #132 from fjtrujy/updateJPGAddons
Browse files Browse the repository at this point in the history
Update some libraries
  • Loading branch information
uyjulian authored Dec 28, 2023
2 parents a01ac8a + bdc46e3 commit 742c3f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 106 deletions.
12 changes: 3 additions & 9 deletions build-cmakelibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,8 @@ git clone --depth 1 -b 1.9.5 https://github.com/open-source-parsers/jsoncpp.git
pushd jsoncpp
sed -i -e 's/std::snprintf/snprintf/' include/json/config.h
popd
# We need to clone the whole repo and point to the specific hash for now,
# till they release a new version with cmake compatibility
git clone https://github.com/libxmp/libxmp.git || { exit 1; }
(cd libxmp && git checkout b0769774109d338554d534d9c122439d61d2bdd1 && cd -) || { exit 1; }
# We need to clone the whole repo and point to the specific hash for now,
# till they release a new version with cmake compatibility
git clone https://github.com/xiph/opus.git || { exit 1; }
(cd opus && git checkout ab04fbb1b7d0b727636d28fc2cadb5df9febe515 && cd -) || { exit 1; }
git clone --depth 1 -b libxmp-4.6.0 https://github.com/libxmp/libxmp.git || { exit 1; }
git clone --depth 1 -b v1.4 https://github.com/xiph/opus.git || { exit 1; }
# We need to clone the whole repo and point to the specific hash for now,
# till they release a new version with cmake compatibility
git clone https://github.com/xiph/opusfile.git || { exit 1; }
Expand All @@ -83,7 +77,7 @@ git clone https://github.com/sezero/mikmod.git mikmod-mikmod || { exit 1; }
git clone --depth 1 -b feature/cmake https://github.com/mcmtroffaes/theora.git || { exit 1; }

# SDL requires to have gsKit
git clone --depth 1 -b v1.3.5 https://github.com/ps2dev/gsKit || { exit 1; }
git clone --depth 1 -b v1.3.6 https://github.com/ps2dev/gsKit || { exit 1; }

# We need to clone the whole repo and point to the specific hash for now,
# till a new version is released after this commit
Expand Down
1 change: 0 additions & 1 deletion libjpeg_ps2_addons/include/libjpg_ps2_addons.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jpgData *jpgFromRAW(void *data, int size, int mode);
jpgData *jpgFromFilename(const char *filename, int mode);
jpgData *jpgFromFILE(FILE *in_file, int mode);
void jpgFileFromJpgData(const char *filename, int quality, jpgData *jpg);
int jpgScreenshot(const char* pFilename,unsigned int VramAdress, unsigned int Width, unsigned int Height, unsigned int Psm);

#ifdef __cplusplus
}
Expand Down
97 changes: 1 addition & 96 deletions libjpeg_ps2_addons/src/libjpg_ps2_addons.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <screenshot.h>
#include <jpeglib.h>
#include <setjmp.h>
#include <gs_psm.h>

#include "../include/libjpg_ps2_addons.h"

Expand Down Expand Up @@ -204,97 +202,4 @@ void jpgFileFromJpgData(const char *filename, int quality, jpgData *jpg) {
fclose(outfile);

jpeg_destroy_compress(&cinfo);
}

int jpgScreenshot(const char* filename,unsigned int vramAdress, unsigned int width, unsigned int height, unsigned int psm)
{
int y;
static uint32_t in_buffer[1024*4]; // max 1024*32bit for a line, should be ok
uint8_t *p_out;
jpgData *jpg;

jpg = malloc(sizeof(jpgData));
if(jpg == NULL)
return -1;

jpg->buffer = malloc(width * height * 3);
if (jpg->buffer == NULL) {
free(jpg);
return -1;
}

p_out = jpg->buffer;

// Check if we have a tempbuffer, if we do we use it
for (y = 0; y < height; y++)
{
ps2_screenshot(in_buffer, vramAdress, 0, y, width, 1, psm);

if (psm == GS_PSM_16)
{
uint32_t x;
uint16_t* p_in = (uint16_t*)&in_buffer;

for (x = 0; x < width; x++)
{
uint32_t r = (p_in[x] & 31) << 3;
uint32_t g = ((p_in[x] >> 5) & 31) << 3;
uint32_t b = ((p_in[x] >> 10) & 31) << 3;

p_out[x*3+0] = r;
p_out[x*3+1] = g;
p_out[x*3+2] = b;
}
}
else
{
if (psm == GS_PSM_24)
{
uint32_t x;
uint8_t* p_in = (uint8_t*)&in_buffer;

for (x = 0; x < width; x++)
{
uint8_t r = *p_in++;
uint8_t g = *p_in++;
uint8_t b = *p_in++;

p_out[x*3+0] = r;
p_out[x*3+1] = g;
p_out[x*3+2] = b;
}
}
else
{
uint8_t *p_in = (uint8_t *) &in_buffer;
uint32_t x;

for(x = 0; x < width; x++)
{
uint8_t r = *p_in++;
uint8_t g = *p_in++;
uint8_t b = *p_in++;

p_in++;

p_out[x*3+0] = r;
p_out[x*3+1] = g;
p_out[x*3+2] = b;
}
}

p_out+= width*3;
}
}

jpg->width = width;
jpg->height = height;
jpg->bpp = 24;

jpgFileFromJpgData(filename, 100, jpg);

free(jpg->buffer);
free(jpg);

return 0;
}
}

0 comments on commit 742c3f9

Please sign in to comment.