cancel
Showing results for 
Search instead for 
Did you mean: 

Compress JPEG fail at jpeg_set_default

ULOK
Visitor

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));

 

 

 

1 REPLY 1
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