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