From ed3df2810cee6ba0ceedbb5a761dbf08f84bbd49 Mon Sep 17 00:00:00 2001 From: Chris Greening Date: Sun, 7 Apr 2024 10:44:57 +0100 Subject: [PATCH] Adds new performance numbers of latest version of JPEGDEC --- README.md | 5 ++++- platformio.ini | 27 ++++++++++++--------------- src/main.cpp | 30 +++++++++++++++++++----------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index ab99cd9..80c9627 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/platformio.ini b/platformio.ini index e4c07af..ec9a80d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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 diff --git a/src/main.cpp b/src/main.cpp index c78e440..647390d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(); @@ -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); @@ -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()); @@ -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); }