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] 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 }