
本帖最后由 hpdell 于 2017-5-20 16:43 编辑 使用st官网的硬件 解码 jpg,只能解码一次是神马情况? 使用的是st官网提供的中断模式 解码 jpg 具体如下: uint8_t JPEG_Display(char *_path) { uint32_t TimeBegin, TimeEnd; uint32_t xPos = 0, yPos = 0; FRESULT res; FATFS * _jpeg_fs = 0; DIR picdir; //图片目录 TimeBegin = HAL_GetTick(); _jpeg_fs = (FATFS *)mymalloc(SRAMIN, sizeof(FATFS)); if( (!_jpeg_fs) ) return 0xff; /*##-4- Register the file system object to the FatFs module ##############*/ res = f_mount(_jpeg_fs, (TCHAR const*)"0:", 0); // == FR_OK) if(res == FR_OK ) { res = f_opendir(&picdir,(const TCHAR*)"0 ![]() if(res != FR_OK) return 3; /*##-5- Open the JPG file with read access #############################*/ res = f_open(&JPEG_File, (TCHAR const*)_path, FA_READ); if(res == FR_OK ) { /*##-6- JPEG decoding with IT (Not Blocking ) Method ################*/ JPEG_Decode_IT(&JPEG_Handle, &JPEG_File, JPEG_OUTPUT_DATA_BUFFER); /*##-7- Wait till end of JPEG decoding and perfom Input/Output Processing in BackGround #*/ do { JPEG_InputHandler(&JPEG_Handle); JpegProcessing_End = JPEG_OutputHandler(&JPEG_Handle); }while(JpegProcessing_End == 0); // 程序解码第二次时,会死在这个地方 ??? /*##-8- Get JPEG Info ###############################################*/ HAL_JPEG_GetInfo(&JPEG_Handle, &JPEG_Info); printf("JPEG_Info.ImageWidth = %d\r\n", JPEG_Info.ImageWidth); printf("JPEG_Info.ImageHeight = %d\r\n", JPEG_Info.ImageHeight); /*##-9- Copy RGB decoded Data to the display FrameBuffer ############*/ if(( g_LcdDirection == 0) || (g_LcdDirection == 2)) // 竖屏,竖屏180 { xPos = (BSP_LCD_GetXSize() - JPEG_Info.ImageWidth) / 2; yPos = (BSP_LCD_GetYSize() - JPEG_Info.ImageHeight) / 2; } else // 横屏,横屏180 { xPos = (BSP_LCD_GetYSize() - JPEG_Info.ImageWidth) / 2; yPos = (BSP_LCD_GetXSize() - JPEG_Info.ImageHeight) / 2; } JPEG_DMA2D_CopyBuffer((uint32_t *)JPEG_OUTPUT_DATA_BUFFER, (uint32_t *)JPEG_LCD_FRAME_BUFFER, xPos , yPos, JPEG_Info.ImageWidth, JPEG_Info.ImageHeight); /*##-10- Close the JPG file ##########################################*/ // f_close(&JPEG_File); } else { printf("JPEG_Display f_open Error \r\n"); } } else { printf("JPEG_Display f_mount Error \r\n"); } TimeEnd = HAL_GetTick(); printf("JPEG Display End ... ... %dms\r\n" , TimeEnd - TimeBegin); f_mount(NULL, (TCHAR const*)"0:", 0); // 显示文件名 BSP_LTDC_DispStringAt(240, 1280/2-230, LCD_COLOR_BLUE, // 显示的文本颜色 LCD_COLOR_TRANSPARENT, // 显示的背景颜色 &FontAscii16x24, (uint8_t *)_path); // return 0; } int main(void) { ... ... JPEG_Display("0:dfdfd.jpg"); // 第一次能够正常解码并显示 JPEG_Display("0:dfdfd.jpg"); // 第二次就死在了上面的 do while里面了 这是为何啊 ???? } |