Skip to content

Commit

Permalink
Adds new performance numbers of latest version of JPEGDEC
Browse files Browse the repository at this point in the history
  • Loading branch information
cgreening committed Apr 7, 2024
1 parent 4731a30 commit ed3df28
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ Here's the results running on an ESP32-S3 with PSRAM.
|------------------------|-------------|------------------|---------------|
| Bodmer/JPEGDecoder | 108 | 118 | 10 |
| Bodmer/TJpg_Decoder | 55 | 64 | 9 |
| bitbank2/JPEGDEC | 32 | 38 | 6 |
| ~~bitbank2/JPEGDEC~~ | ~~32~~ | ~~38~~ | ~~6~~ |
| bitbank2/JPEGDEC (New!) | 23 | 29 | 6 |
| ESP32_JPEG | 20 | 37 | 17 |

As you can see it is very fast - 20ms to decode the image.

NOTE - there's a new improved version of the bitbank2/JPEGDEC library which takes advantage of SIMD instructions on the ESP32S3. This now decodes JPEGS in just 23ms!

You might be wondering why the total draw+decode time does not look particularly good. There's a good explanation in the video and it comes down to using DMA to draw the image. With the other options we can overlap sending blocks of pixels to the screen with decoding the next block of pixels. With this library we have to wait for the entire image to be decoded before we can start sending it to the screen.

With the esp32-tv project this may not matter that much - we can display the current frame of the video while the next frame is being decoded. For displaying a single image it's still not terrible. We can do the decode very quickly and then the CPU is free to do other stuff while the display is being updated.
Expand Down
27 changes: 12 additions & 15 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,29 @@ lib_deps =
bitbank2/JPEGDEC
https://github.com/esp-arduino-libs/ESP32_JPEG
https://github.com/Bodmer/TJpg_Decoder
board_build.arduino.memory_type = qio_opi
; board_build.arduino.memory_type = qio_opi
; board_build.arduino.memory_type = dio_opi
build_flags =
-DBOARD_HAS_PSRAM
; -DBOARD_HAS_PSRAM
; maximum speed!
-Ofast
-DUSE_HSPI_PORT
-DTFT_POWER=GPIO_NUM_43
-DTFT_POWER_ON=LOW
; TFT_eSPI setup
-DUSER_SETUP_LOADED=1
-DTFT_WIDTH=240
-DTFT_HEIGHT=280
-DST7789_DRIVER=1
-DTFT_SCLK=4
-DTFT_MISO=15
-DTFT_MOSI=5
-DTFT_RST=6
-DTFT_DC=7
-DTFT_CS=15
-DTFT_BL=16
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_SCLK=41
-DTFT_MISO=-1
-DTFT_MOSI=40
-DTFT_RST=39
-DTFT_DC=44
-DTFT_CS=42
-DTFT_BL=0
-DLOAD_FONT2=1
-DSPI_FREQUENCY=80000000
; audio settings
-DI2S_SPEAKER_SERIAL_CLOCK=GPIO_NUM_39
-DI2S_SPEAKER_LEFT_RIGHT_CLOCK=GPIO_NUM_40
-DI2S_SPEAKER_SERIAL_DATA=GPIO_NUM_38
-DSAMPLE_RATE=16000
; make sure serial output works
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
Expand Down
30 changes: 19 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "ESP32JPEGTest.h"
#include "TJPEGTest.h"

#include "images/jpeg272x233.h"
// #include "images/jpeg280x240.h"
// #include "images/jpeg272x233.h"
#include "images/jpeg280x240.h"

TFT_eSPI tft = TFT_eSPI();

Expand All @@ -25,9 +25,16 @@ int testCount = sizeof(tests) / sizeof(tests[0]);
void setup()
{
Serial.begin(115200);

#ifdef TFT_POWER
if (TFT_POWER != GPIO_NUM_NC) {
Serial.println("Powering on TFT");
pinMode(TFT_POWER, OUTPUT);
digitalWrite(TFT_POWER, TFT_POWER_ON);
}
#endif
delay(1000);
tft.init();
tft.fillScreen(TFT_BLACK);
tft.fillScreen(TFT_GREEN);
tft.setRotation(3); // portrait
tft.initDMA();
tft.setTextFont(2);
Expand Down Expand Up @@ -62,7 +69,8 @@ void testit(uint8_t *data, int length) {
}
delay(1000);
Serial.printf("%s: %dms decode+draw, %dms decode, %d ms draw overhead\n", tests[testIndex]->description(), decodeDraw, decode, decodeDraw - decode);
tft.setTextColor(TFT_GREEN);
tft.fillScreen(TFT_GREEN);
tft.setTextColor(TFT_BLACK);
tft.setTextSize(2);
tft.setCursor(5, 140);
tft.printf("%s", tests[testIndex]->description());
Expand All @@ -80,12 +88,12 @@ void loop()
int freeRam = esp_get_free_heap_size();
Serial.printf("Free RAM: %d\n", freeRam);
Serial.printf("Free PSRAM: %d\n", ESP.getFreePsram());
// Serial.println("---------------------------");
// Serial.println("Testing with 280x240 image");
// Serial.println("---------------------------");
// testit(test_jpeg_280x240, test_jpeg_280x240_len);
Serial.println("---------------------------");
Serial.println("Testing with 272x233 image");
Serial.println("Testing with 280x240 image");
Serial.println("---------------------------");
testit(test_jpeg_272x233, test_jpeg_272x233_len);
testit(test_jpeg_280x240, test_jpeg_280x240_len);
// Serial.println("---------------------------");
// Serial.println("Testing with 272x233 image");
// Serial.println("---------------------------");
// testit(test_jpeg_272x233, test_jpeg_272x233_len);
}

0 comments on commit ed3df28

Please sign in to comment.