From 0d2e9b6507692937b995705eebae16ea2fce879e Mon Sep 17 00:00:00 2001 From: Reg <69511985+RegularRabbit05@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:09:26 +0200 Subject: [PATCH 1/5] sceJpeg_67F0ED84 to sceJpegCsc --- src/mpeg/sceJpeg.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpeg/sceJpeg.S b/src/mpeg/sceJpeg.S index 775fd3c5..5f34a65a 100644 --- a/src/mpeg/sceJpeg.S +++ b/src/mpeg/sceJpeg.S @@ -24,7 +24,7 @@ IMPORT_FUNC "sceJpeg",0x64B6F978,sceJpeg_64B6F978 #endif #ifdef F_sceJpeg_0007 - IMPORT_FUNC "sceJpeg",0x67F0ED84,sceJpeg_67F0ED84 + IMPORT_FUNC "sceJpeg",0x67F0ED84,sceJpegCsc #endif #ifdef F_sceJpeg_0008 IMPORT_FUNC "sceJpeg",0x7D2F3D7F,sceJpegFinishMJpeg From 6b77137ab539bd22c8fb001b1c41a9b81f0a5920 Mon Sep 17 00:00:00 2001 From: Reg <69511985+RegularRabbit05@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:30:55 +0200 Subject: [PATCH 2/5] Add sceJpegDecodeMJpegYCbCr and sceJpegCsc to pspjpeg.h --- src/mpeg/pspjpeg.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/mpeg/pspjpeg.h b/src/mpeg/pspjpeg.h index 614add4d..cfa23334 100644 --- a/src/mpeg/pspjpeg.h +++ b/src/mpeg/pspjpeg.h @@ -55,11 +55,36 @@ int sceJpegDeleteMJpeg(void); * @param size - size of the buffer pointed by jpegbuf * @param rgba - buffer where the decoded data in RGBA format will be stored. * It should have a size of (width * height * 4). - * @param unk - Unknown, pass 0 + * @param dhtMode - Unknown, pass 0 * * @return (width * 65536) + height on success, < 0 on error */ -int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 unk); +int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 dhtMode); + +/** + * Decodes a mjpeg frame with YCbCr encoding. + * + * @param jpegbuf - the buffer with the mjpeg frame + * @param size - size of the buffer pointed by jpegbuf + * @param rgba - buffer where the decoded data in YCbCr format will be stored. + * @param dhtMode - Unknown, pass 0 + * + * @return (width * 65536) + height on success, < 0 on error +*/ +int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize size, void *yCbCr, u32 dhtMode); + +/** + * Converts a frame from YCbCr to ABGR + * + * @param imageAddr - buffer where the decoded data in abgr format will be stored. + * @param yCbCrAddr - the buffer with the YCbCr data + * @param widthHeight - width and height of the frame (width << 16) | height + * @param bufferWidth - number of pixels per row of the buffer + * @param colourInfo - chroma subsampling mode + * + * @return 0 on success, < 0 on error +*/ +int sceJpegCsc(u8 *imageAddr, u8 *yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo); #ifdef __cplusplus } From 125772869a92453f2c47217cce3e1527989c06ea Mon Sep 17 00:00:00 2001 From: Reg <69511985+RegularRabbit05@users.noreply.github.com> Date: Fri, 4 Jul 2025 19:34:10 +0200 Subject: [PATCH 3/5] sceJpegDecodeMJpegYCbCr signature --- src/mpeg/pspjpeg.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mpeg/pspjpeg.h b/src/mpeg/pspjpeg.h index cfa23334..b79311a0 100644 --- a/src/mpeg/pspjpeg.h +++ b/src/mpeg/pspjpeg.h @@ -66,12 +66,13 @@ int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 dhtMode); * * @param jpegbuf - the buffer with the mjpeg frame * @param size - size of the buffer pointed by jpegbuf - * @param rgba - buffer where the decoded data in YCbCr format will be stored. + * @param yCbCr - buffer where the decoded data in YCbCr format will be stored. + * @param yCbCrSize - size of the buffer pointed by yCbCr * @param dhtMode - Unknown, pass 0 * * @return (width * 65536) + height on success, < 0 on error */ -int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize size, void *yCbCr, u32 dhtMode); +int sceJpegDecodeMJpegYCbCr(u8 *jpegAddr, SceSize jpegSize, u8 *yCbCr, SceSize yCbCrSize, u32 dhtMode); /** * Converts a frame from YCbCr to ABGR From e79471103bd8362f2889c9425251c06d7dfc045c Mon Sep 17 00:00:00 2001 From: Reg <69511985+RegularRabbit05@users.noreply.github.com> Date: Fri, 4 Jul 2025 21:10:49 +0200 Subject: [PATCH 4/5] added sceJpegGetOutputInfo --- src/mpeg/pspjpeg.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mpeg/pspjpeg.h b/src/mpeg/pspjpeg.h index b79311a0..db0808fa 100644 --- a/src/mpeg/pspjpeg.h +++ b/src/mpeg/pspjpeg.h @@ -72,7 +72,7 @@ int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 dhtMode); * * @return (width * 65536) + height on success, < 0 on error */ -int sceJpegDecodeMJpegYCbCr(u8 *jpegAddr, SceSize jpegSize, u8 *yCbCr, SceSize yCbCrSize, u32 dhtMode); +int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize jpegSize, u8 *yCbCr, SceSize yCbCrSize, u32 dhtMode); /** * Converts a frame from YCbCr to ABGR @@ -87,6 +87,18 @@ int sceJpegDecodeMJpegYCbCr(u8 *jpegAddr, SceSize jpegSize, u8 *yCbCr, SceSize y */ int sceJpegCsc(u8 *imageAddr, u8 *yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo); +/** + * Reads information from mjpeg frame + * + * @param jpegbuf - the buffer with the mjpeg frame + * @param size - size of the mjpeg frame + * @param colourInfoAddr - address where the mjpeg chroma information will be stored + * @param dhtMode - Unknown, pass 0 + * + * @return 0 on success, < 0 on error +*/ +int sceJpegGetOutputInfo(u8* jpegbuf, SceSize size, int* colourInfoAddr, int dhtMode); + #ifdef __cplusplus } #endif From 6dced23b25d4945823d858b76b021cae862c774a Mon Sep 17 00:00:00 2001 From: Reg <69511985+RegularRabbit05@users.noreply.github.com> Date: Sun, 6 Jul 2025 00:10:02 +0200 Subject: [PATCH 5/5] More documentation for pspjpeg.h --- src/mpeg/pspjpeg.h | 76 +++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/mpeg/pspjpeg.h b/src/mpeg/pspjpeg.h index db0808fa..0760e2f0 100644 --- a/src/mpeg/pspjpeg.h +++ b/src/mpeg/pspjpeg.h @@ -17,6 +17,13 @@ extern "C" { #include +#define SCE_JPEG_ERROR_BAD_MARKER_LENGTH (0x80650004) +#define SCE_JPEG_ERROR_INVALID_POINTER (0x80650010) +#define SCE_JPEG_ERROR_UNSUPPORT_COLORSPACE (0x80650013) +#define SCE_JPEG_ERROR_UNSUPPORT_SAMPLING (0x80650016) +#define SCE_JPEG_ERROR_UNSUPPORT_IMAGE_SIZE (0x80650020) +#define SCE_JPEG_ERROR_UNKNOWN_MARKER (0x80650035) + /** * Inits the MJpeg library * @@ -49,55 +56,60 @@ int sceJpegCreateMJpeg(int width, int height); int sceJpegDeleteMJpeg(void); /** - * Decodes a mjpeg frame. + * Decodes a mjpeg frame to RGBA encoding. + * @note Input frame should be encoded as either yuv420p or yuvj420p, + * returns SCE_JPEG_ERROR_UNSUPPORT_SAMPLING otherwise * * @param jpegbuf - the buffer with the mjpeg frame * @param size - size of the buffer pointed by jpegbuf * @param rgba - buffer where the decoded data in RGBA format will be stored. * It should have a size of (width * height * 4). - * @param dhtMode - Unknown, pass 0 + * @param unk - Unknown, pass 0 * * @return (width * 65536) + height on success, < 0 on error */ -int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 dhtMode); - -/** - * Decodes a mjpeg frame with YCbCr encoding. - * - * @param jpegbuf - the buffer with the mjpeg frame - * @param size - size of the buffer pointed by jpegbuf - * @param yCbCr - buffer where the decoded data in YCbCr format will be stored. - * @param yCbCrSize - size of the buffer pointed by yCbCr - * @param dhtMode - Unknown, pass 0 - * - * @return (width * 65536) + height on success, < 0 on error -*/ -int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize jpegSize, u8 *yCbCr, SceSize yCbCrSize, u32 dhtMode); - -/** - * Converts a frame from YCbCr to ABGR - * - * @param imageAddr - buffer where the decoded data in abgr format will be stored. - * @param yCbCrAddr - the buffer with the YCbCr data - * @param widthHeight - width and height of the frame (width << 16) | height - * @param bufferWidth - number of pixels per row of the buffer - * @param colourInfo - chroma subsampling mode - * - * @return 0 on success, < 0 on error -*/ -int sceJpegCsc(u8 *imageAddr, u8 *yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo); +int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, u8 *rgba, u32 unk); /** * Reads information from mjpeg frame * * @param jpegbuf - the buffer with the mjpeg frame * @param size - size of the mjpeg frame - * @param colourInfoAddr - address where the mjpeg chroma information will be stored - * @param dhtMode - Unknown, pass 0 + * @param colourInfo - address where the mjpeg chroma information will be stored + * @param unk - Unknown, pass 0 + * + * @return number of bytes needed in the buffer that will be used for YCbCr decoding, <= 0 on error +*/ +int sceJpegGetOutputInfo(u8 *jpegbuf, SceSize size, int *colourInfo, int unk); + +/** + * Decodes a mjpeg frame to YCbCr encoding + * @note Input frame should be encoded as either yuv420p or yuvj420p, + * returns SCE_JPEG_ERROR_UNSUPPORT_SAMPLING otherwise + * + * @param jpegbuf - the buffer with the mjpeg frame + * @param size - size of the buffer pointed by jpegbuf + * @param yCbCr - buffer where the decoded data in YCbCr format will be stored + * @param yCbCrSize - size of the buffer pointed by yCbCr (see sceJpegGetOutputInfo()) + * @param unk - Unknown, pass 0 + * + * @return (width * 65536) + height on success, < 0 on error +*/ +int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize size, u8 *yCbCr, SceSize yCbCrSize, u32 unk); + +/** + * Converts a frame from YCbCr to RGBA + * + * @param imageAddr - buffer where the converted data in RGBA format will be stored. + * @param yCbCrAddr - the buffer with the YCbCr data + * @param widthHeight - width and height of the frame (width * 65536) + height, + * as returned by sceJpegDecodeMJpegYCbCr() or sceJpegDecodeMJpeg() + * @param bufferWidth - number of pixels per row of the buffer + * @param colourInfo - chroma subsampling mode, as provided by sceJpegGetOutputInfo() * * @return 0 on success, < 0 on error */ -int sceJpegGetOutputInfo(u8* jpegbuf, SceSize size, int* colourInfoAddr, int dhtMode); +int sceJpegCsc(u8 *imageAddr, u8 *yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo); #ifdef __cplusplus }