2021-07-13 09:09 PM
Hi.
It took a long time to decoder JPEG images, so I measured the time.
[My code]
...
// Allocate and initialize JPEG decompression object. We set up the normal JPEG error routines.
cinfo.err = jpeg_std_error( &jerr );
// Now we can initialize the JPEG decompression object.
jpeg_create_decompress( &cinfo );
// Specify data source (eg, a file)
jpeg_stdio_src( &cinfo, &SDFile );
// Read file parameters with jpeg_read_header()
jpeg_read_header( &cinfo, TRUE );
// Start decompressor
jpeg_start_decompress( &cinfo );
// allocation memory
unsigned char* buffer = (unsigned char*) calloc( cinfo.output_width * cinfo.output_components, 1 );
static uint32_t time = 0;
static uint32_t index = 0;
static uint32_t laps[1024] = {0, };
// scan lines
while( cinfo.output_scanline < cinfo.output_height )
{
// get current tick time
time = HAL_GetTick();
// scan line
jpeg_read_scanlines( &cinfo, buffer, 1 );
// get lap time
laps[ index++ ] = HAL_GetTick() - time;
}
// Finish decompression
jpeg_finish_decompress( &cinfo );
// Release JPEG decompression object
jpeg_destroy_decompress( &cinfo );
...
Time required each time the function jpeg_read_scanlines is called.
As you can see, it takes 25 ms to 35 ms for every 16 lines.
For this reason, it takes more than 1 second to load the 800 x 480 size image.
How can we solve this time delay?
2021-07-14 08:02 PM
Converting more than 1 line at a time will almost certainly be more efficient. Increasing clock speed, or enabling cache can help. Compiling in Release mode will help.
There are chips within the STM32F7 and STM32H7 families with hardware JPEG decoding which is going to be much faster than doing it in software.