2018-06-05 07:22 AM
Hello,
we are trying to decode a jpeg on the STM32F769I-DISCO and display it on the LCD while decoding. For that we modified the JPEG example JPEG_DecodingUsingFs_DMA a little bit. Here is the important part of code:
unsigned char* jpegData = new unsigned char[65000];
unsigned int jpegDataLength = decode_base64(input, jpegData);
unsigned int displayedMcus = 0;
unsigned int mcusTotal = 1200;
unsigned int imageWidthInByte = 2560;
unsigned int mcuPixel = 16;unsigned int bytePerPixel = 4;
unsigned int jpegBytesRead = JPEG_Decode_DMA(&hjpeg, jpegData, jpegDataLength, JPEG_OUTPUT_DATA_BUFFER);
HAL_JPEG_GetInfo(&hjpeg, &JPEG_Info);
uint32_t xPos = 0;
uint32_t yPos = 0;do {
jpegBytesRead += JPEG_InputHandler(&hjpeg, jpegData, jpegBytesRead, jpegDataLength); mcusProcessed = JPEG_OutputHandler(&hjpeg);if(displayedMcus < mcusProcessed) {
xRef = (((displayedMcus) * 16) / JPEG_Info.ImageWidth) * 16; yRef = (((displayedMcus) * 16) % JPEG_Info.ImageWidth); refline = imageWidthInByte * xRef + (bytePerPixel * yRef); DMA2D_CopyBuffer((uint32_t *)JPEG_OUTPUT_DATA_BUFFER + refline, (uint32_t *)LCD_FRAME_BUFFER, xPos , yPos, mcuPixel, mcuPixel); DMA2D_CopyBuffer((uint32_t *)JPEG_OUTPUT_DATA_BUFFER + refline + imageWidthInByte, (uint32_t *)LCD_FRAME_BUFFER, xPos , yPos + mcuPixel, mcuPixel, mcuPixel); xPos += 16; if (xPos >= JPEG_Info.ImageWidth) { xPos = xPos % JPEG_Info.ImageWidth; yPos += (mcusProcessed - displayedMcus) * 16; } displayedMcus = mcusProcessed; } } while (mcusProcessed < 1200);Our problem is: how do we know the right place to copy from the JPEG_OUTPUT_DATA_BUFFER to the LCD_FRAME_BUFFER with function DMA2D_CopyBuffer() (located in the above mentioned example).
We tried to understand JPEG_MCU_YCbCr420_ARGB_ConvertBlocks() in the jpeg_utils.c and rebuild the buffer access for copying the right MCUs from JPEG_OUTPUT_DATA_BUFFER to the LCD_FRAME_BUFFER but it's quite hard to understand how it works in detail.
Displaying the whole decoded jpeg works by the way.
Can someone give us a hint?
Thanks in advanced.
2018-06-05 09:46 AM
Doesn't the library have call-backs, or repeated decode calls, that allow you to fill an arbitrary length output buffer?
I haven't dug deeply into the model here, but typically you pass an output buffer by location/size, and each time the decoder fills that it gives you a whole buffer at the location you provided, and you write that raster data to a file or screen, or whatever output device you have. If the output buffer is a fractional size you call again to get the next piece.
The other alternative is to have the output buffer BE the frame buffer.
2018-06-06 02:39 AM
add to code WM_MULTIBUF_Enable(0);