mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Camera: Remember the JPEG quality that fit the last frame
Start from the quality that fit the previous frame instead of the top, so most frames encode once. Step down while a frame is too big, and step back up when one comes out under half the limit. Windows and the recompression fallback share the logic. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
07556d064e
commit
9e54cebcc2
3 files changed
+46
-28
No files matched your search
+10
-15
@@ -247,22 +247,17 @@ HRESULT ReaderCallback::OnReadSample(
|
||||
}
|
||||
}
|
||||
|
||||
// Compress image to jpeg from RGB24. Like the PSP camera, lower the quality until the frame
|
||||
// fits the size the game asked for: Go!Edit stores frames in fixed 15KB slots.
|
||||
const int maxFrameSize = Camera::getMaxFrameSize();
|
||||
jpge::params params;
|
||||
for (int quality = 85; ; quality -= 10) {
|
||||
imgJpegSize = device->imgJpegSize;
|
||||
// Compress image to jpeg from RGB24. Like the PSP camera, fit the size the game asked for:
|
||||
// Go!Edit stores frames in fixed 15KB slots.
|
||||
imgJpegSize = Camera::encodeToFit(Camera::getMaxFrameSize(), [&](int quality) {
|
||||
jpge::params params;
|
||||
params.m_quality = quality;
|
||||
jpge::compress_image_to_jpeg_file_in_memory(
|
||||
device->imageJpeg, imgJpegSize,
|
||||
dstW,
|
||||
dstH,
|
||||
3,
|
||||
device->imageRGB, params);
|
||||
if (imgJpegSize <= maxFrameSize || quality <= 15) {
|
||||
break;
|
||||
}
|
||||
int size = device->imgJpegSize;
|
||||
return jpge::compress_image_to_jpeg_file_in_memory(
|
||||
device->imageJpeg, size, dstW, dstH, 3, device->imageRGB, params) ? size : -1;
|
||||
});
|
||||
if (imgJpegSize < 0) {
|
||||
imgJpegSize = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user