2025-11-07 6:32 AM - last edited on 2025-11-07 6:51 AM by mƎALLEm
Hi everyone, I'm using an STM32H743 MCU with an LTDC display and lvgl for management.
I'm using the graphics accelerator correctly to decode an mjpeg video in YCbCr, but I can't convert it to RGB565 with DMA2D.
If I try to convert without DMA2D, I get times of about 350 ms per frame (792*408). Decoding is successful in DMA.
static void video_playback_task(lv_timer_t * t)
{
if (!MJPEG_GetNextFrame(Video_Buffer, Video_Size, &offset, &frame))
{
lv_timer_del(video_timer);
video_timer = NULL;
printf("Fine video\n");
return;
}
JPEG_Decode_DMA(&hjpeg, frame.start, frame.size, Frame_Buffer);
DMA2D_CopyBuffer((uint32_t*)Frame_Buffer, uint32_t*)Frame_Buffer_Rgb, IMAGE_WIDTH, IMAGE_HEIGHT);
img_dsc.data = Frame_Buffer_Rgb;
lv_img_set_src(img, &img_dsc);
lv_obj_invalidate(img);
HAL_GPIO_TogglePin(Check_ADAS_GPIO_Port, Check_ADAS_Pin);
}
static void JPEG_Decode_DMA(JPEG_HandleTypeDef *hjpeg, uint8_t *FrameSrc, uint32_t FrameSize, uint8_t *YCbCr_Dst)
{
JPEGSourceAddress = FrameSrc;
FrameBufferAddress = YCbCr_Dst;
Input_frameIndex = 0;
Input_frameSize = FrameSize;
Jpeg_HWDecodingEnd = 0;
HAL_JPEG_Decode_DMA(hjpeg, (uint8_t *)JPEGSourceAddress, CHUNK_SIZE_IN, (uint8_t *)FrameBufferAddress, CHUNK_SIZE_OUT);
while (Jpeg_HWDecodingEnd == 0)
{
// Attende completamento DMA (non blocca CPU pesantemente)
}
}
2025-11-20 1:45 AM
Hello @Giovanni3,
I recommend referring to AN4996: How to use the JPEG codec peripheral on STM32 MCUs, especially section 4.1 which explains MCU reordering and color conversion using DMA2D.
Also, check Table 6 in AN4996, which lists useful JPEG decoding examples for STM32H7 MCUs to guide your implementation.
I hope my answer has been helpful. When your question is resolved, please mark this topic as the solution. This will help others find the answer more quickly.
Thank you for your contribution.
Best regards,
Dor_RH