mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Cleanup trailing data on jpeg images
This commit is contained in:
parent
a0bb1726e3
commit
c12415d001
@ -374,6 +374,15 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
|
||||
|
||||
HAL_JPEG_DeInit(&JPEG_Handle);
|
||||
|
||||
if (!jpeg_enc.overflow) {
|
||||
// Clean trailing data.
|
||||
while ((dst->bpp >= 2)
|
||||
&& ((dst->pixels[dst->bpp-2] != 0xFF)
|
||||
|| (dst->pixels[dst->bpp-1] != 0xD9))) {
|
||||
dst->bpp -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return jpeg_enc.overflow;
|
||||
}
|
||||
|
||||
|
||||
@ -1478,6 +1478,12 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, streaming_cb_t streaming_c
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t*)MAIN_FB()->pixels, OMV_RAW_BUF_SIZE);
|
||||
#endif
|
||||
}
|
||||
// Clean trailing data.
|
||||
while ((MAIN_FB()->bpp >= 2)
|
||||
&& ((MAIN_FB()->pixels[MAIN_FB()->bpp-2] != 0xFF)
|
||||
|| (MAIN_FB()->pixels[MAIN_FB()->bpp-1] != 0xD9))) {
|
||||
MAIN_FB()->bpp -= 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user