Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@RegularRabbit05
Copy link
Contributor

No description provided.

@sharkwouter
Copy link
Member

Cool, this is great to have. Have you tested they work? Then I'll merge them.

@RegularRabbit05
Copy link
Contributor Author

RegularRabbit05 commented Jul 4, 2025

Sorry for the wait (and multiple commits) as I got the signature wrong.

With this code i get the following result on ppsspp
image

As for hardware on a psp i get -2140864490 / 0x80650016 from sceJpegDecodeMJpegYCbCr (which should mean unsupported sampling) for most images while some load (from time to time for some reason while stb_image always works with the same data) but all of this could be an error on my end so if anyone can test it too as a double check would be appreciated

@RegularRabbit05 RegularRabbit05 changed the title Add sceJpegDecodeMJpegYCbCr and sceJpegCsc Add sceJpegDecodeMJpegYCbCr, sceJpegCsc and sceJpegGetOutputInfo Jul 4, 2025
@RegularRabbit05
Copy link
Contributor Author

Seems like the functions currently in this header might work specifically with yuvj420p chromas on real hardware vs any jpeg on ppsspp, we'll research more on it and update the header accordingly

@RegularRabbit05
Copy link
Contributor Author

I've tested the functions and they do "work" on real hardware (only if the input resolution is at maximum about 480p and 4:2:0 chroma subsampling format).
This is the test program i created to try the jpeg combinations, though I don't think committing it as a sample is a great idea as it's slightly over-complicated and uses raylib instead of the native functions for drawing so it wouldn't build with the sdk alone.

To use OutputInfo, YCbCr and Csc instead of the call to DecodeMJpeg just swap the decode with:

    int decRes, w, h, col, reqSize;
    getJpegSize(buf, bufSize, w, h);
    sceJpegCreateMJpeg(w, h);
    uint8_t *conversion = (uint8_t *) malloc(w*h*4);
    reqSize = sceJpegGetOutputInfo(buf, bufSize, &col, 0);
    uint8_t *yCbCrBuf = (uint8_t *) malloc(reqSize);
    decRes = sceJpegDecodeMJpegYCbCr(buf, bufSize, yCbCrBuf, reqSize, 0);
    sceJpegCsc(conversion, yCbCrBuf, decRes, w, col);
    free(yCbCrBuf);
    sceJpegDeleteMJpeg();

I've also cleaned up a bit the docs with the findings and added some defines with the errors I've encountered while testing so that they can be used to error check the functions.

I don't think I am capable to do much more to help so if you think this version is satisfactory it can be merged, else if anyone has more information contributions are welcomed

@sharkwouter
Copy link
Member

This is a really great addition, thanks for looking into this and finding out how it works!

@sharkwouter sharkwouter merged commit c1debe8 into pspdev:master Jul 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants