Camera: Compress webcam frames to fit the game's framesize

The PSP camera keeps JPEG frames within the framesize from the video setup.
Go!Edit stores frames in 15KB slots and only takes frames that fit, so our
uncompressed-quality webcam frames were dropped and one frame got repeated
for the whole clip. Lower the JPEG quality until a frame fits.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-29 11:44:10 -06:00
1 parent 948062907b
commit 9d33e828ab
3 files changed
+35 -7

No files matched your search

+17 -7
View File
@@ -247,13 +247,23 @@ HRESULT ReaderCallback::OnReadSample(
}
}
// Compress image to jpeg from RGB24.
jpge::compress_image_to_jpeg_file_in_memory(
device->imageJpeg, imgJpegSize,
dstW,
dstH,
3,
device->imageRGB);
// 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;
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;
}
}
}
#endif
Camera::pushCameraImage(imgJpegSize, device->imageJpeg);