Skip to content

Commit c1debe8

Browse files
authored
Merge pull request #317 from RegularRabbit05/master
Add sceJpegDecodeMJpegYCbCr, sceJpegCsc and sceJpegGetOutputInfo
2 parents 658d5bd + 6dced23 commit c1debe8

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/mpeg/pspjpeg.h

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ extern "C" {
1717

1818
#include <psptypes.h>
1919

20+
#define SCE_JPEG_ERROR_BAD_MARKER_LENGTH (0x80650004)
21+
#define SCE_JPEG_ERROR_INVALID_POINTER (0x80650010)
22+
#define SCE_JPEG_ERROR_UNSUPPORT_COLORSPACE (0x80650013)
23+
#define SCE_JPEG_ERROR_UNSUPPORT_SAMPLING (0x80650016)
24+
#define SCE_JPEG_ERROR_UNSUPPORT_IMAGE_SIZE (0x80650020)
25+
#define SCE_JPEG_ERROR_UNKNOWN_MARKER (0x80650035)
26+
2027
/**
2128
* Inits the MJpeg library
2229
*
@@ -49,7 +56,9 @@ int sceJpegCreateMJpeg(int width, int height);
4956
int sceJpegDeleteMJpeg(void);
5057

5158
/**
52-
* Decodes a mjpeg frame.
59+
* Decodes a mjpeg frame to RGBA encoding.
60+
* @note Input frame should be encoded as either yuv420p or yuvj420p,
61+
* returns SCE_JPEG_ERROR_UNSUPPORT_SAMPLING otherwise
5362
*
5463
* @param jpegbuf - the buffer with the mjpeg frame
5564
* @param size - size of the buffer pointed by jpegbuf
@@ -59,7 +68,48 @@ int sceJpegDeleteMJpeg(void);
5968
*
6069
* @return (width * 65536) + height on success, < 0 on error
6170
*/
62-
int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 unk);
71+
int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, u8 *rgba, u32 unk);
72+
73+
/**
74+
* Reads information from mjpeg frame
75+
*
76+
* @param jpegbuf - the buffer with the mjpeg frame
77+
* @param size - size of the mjpeg frame
78+
* @param colourInfo - address where the mjpeg chroma information will be stored
79+
* @param unk - Unknown, pass 0
80+
*
81+
* @return number of bytes needed in the buffer that will be used for YCbCr decoding, <= 0 on error
82+
*/
83+
int sceJpegGetOutputInfo(u8 *jpegbuf, SceSize size, int *colourInfo, int unk);
84+
85+
/**
86+
* Decodes a mjpeg frame to YCbCr encoding
87+
* @note Input frame should be encoded as either yuv420p or yuvj420p,
88+
* returns SCE_JPEG_ERROR_UNSUPPORT_SAMPLING otherwise
89+
*
90+
* @param jpegbuf - the buffer with the mjpeg frame
91+
* @param size - size of the buffer pointed by jpegbuf
92+
* @param yCbCr - buffer where the decoded data in YCbCr format will be stored
93+
* @param yCbCrSize - size of the buffer pointed by yCbCr (see sceJpegGetOutputInfo())
94+
* @param unk - Unknown, pass 0
95+
*
96+
* @return (width * 65536) + height on success, < 0 on error
97+
*/
98+
int sceJpegDecodeMJpegYCbCr(u8 *jpegbuf, SceSize size, u8 *yCbCr, SceSize yCbCrSize, u32 unk);
99+
100+
/**
101+
* Converts a frame from YCbCr to RGBA
102+
*
103+
* @param imageAddr - buffer where the converted data in RGBA format will be stored.
104+
* @param yCbCrAddr - the buffer with the YCbCr data
105+
* @param widthHeight - width and height of the frame (width * 65536) + height,
106+
* as returned by sceJpegDecodeMJpegYCbCr() or sceJpegDecodeMJpeg()
107+
* @param bufferWidth - number of pixels per row of the buffer
108+
* @param colourInfo - chroma subsampling mode, as provided by sceJpegGetOutputInfo()
109+
*
110+
* @return 0 on success, < 0 on error
111+
*/
112+
int sceJpegCsc(u8 *imageAddr, u8 *yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo);
63113

64114
#ifdef __cplusplus
65115
}

src/mpeg/sceJpeg.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
IMPORT_FUNC "sceJpeg",0x64B6F978,sceJpeg_64B6F978
2525
#endif
2626
#ifdef F_sceJpeg_0007
27-
IMPORT_FUNC "sceJpeg",0x67F0ED84,sceJpeg_67F0ED84
27+
IMPORT_FUNC "sceJpeg",0x67F0ED84,sceJpegCsc
2828
#endif
2929
#ifdef F_sceJpeg_0008
3030
IMPORT_FUNC "sceJpeg",0x7D2F3D7F,sceJpegFinishMJpeg

0 commit comments

Comments
 (0)