cancel
Showing results for 
Search instead for 
Did you mean: 

Compress JPEG fail at jpeg_set_default

ULOK
Associate II

Hi,

I am a newbie and trying to compress RGB image data to JPEG and save to SD card. Step by step I monitor the debugging of CubeMX, which is very useful to me. And finally I see it can not pass the jpeg_set_default() function due to "out of memory", does this mean I need to upgrade to high memory MCU?  btw, I do not allocate memory for cinfo, before the main(), I declare cinfo as structure instead of a structure pointer.

I hope to get your support. thank you!!!

it stops here (as below) inside the jpeg_set_default( )

/* Allocate comp_info array large enough for maximum component count.
* Array is made permanent in case application wants to compress
* multiple images at same param settings.
*/
if (cinfo->comp_info == NULL)
cinfo->comp_info = (jpeg_component_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
MAX_COMPONENTS * SIZEOF(jpeg_component_info));

 

 

 

2 REPLIES 2
Imen.D
ST Employee

Hello @ULOK ,

Check memory Allocation, I think there is insufficient memory. So, ensure that your system has enough free memory and the buffer used to store the JPEG data is large enough to handle the compressed data.

Make sure that the input data being passed to the JPEG compression functions is valid and correctly formatted.

If you are using DMA for data transfer, make sure it is configured correctly to handle the data size and transfer speed.

 

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi @Imen.D ,

Thank you for quick reply. I perhaps think another way to save jpeg data to SD card.

I notice DCMI has a JPEG mode, I guess that means it can transmit JPEG data stream from CAMERA to the internal memory, am I correct? 

If so, then can I directly use f_write () function to write the JPEG data stream to a file that created in SD card, let's say I use SDIO interact with SD card.   Can I get a readable jpeg image by Windows? or I do have to handle the JPEG header info when doing f_write() function...