Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cgreening committed Sep 30, 2023
0 parents commit 9052453
Show file tree
Hide file tree
Showing 23 changed files with 4,766 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
patreon: atomic14
ko_fi: atomic14
github: atomic14
25 changes: 25 additions & 0 deletions .github/workflows/build_firmware.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Firmware

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: pip install --upgrade platformio

- name: Build PlatformIO Project
run: pio run --project-dir player

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.DS_Store
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"files.associations": {
"*.tcc": "cpp",
"array": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"random": "cpp"
},
"cmake.configureOnOpen": false
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[![Build Firmware](https://github.com/atomic14/esp32-jpeg-tests/actions/workflows/build_firmware.yml/badge.svg)](https://github.com/atomic14/esp32-jpeg-tests/actions/workflows/build_firmware.yml)

# ESP32 JPEG Performance Test
[![Demo Video](https://img.youtube.com/vi/OyoN1ypBSrQ/0.jpg)](https://www.youtube.com/watch?v=OyoN1ypBSrQ)

You can see a video explanation here [here](https://www.youtube.com/watch?v=OyoN1ypBSrQ).

I received an issue on my esp32-tv project: [Decoding JPEG with SIMD](https://github.com/atomic14/esp32-tv/issues/3) along with a link to some [demo code](https://github.com/esp-arduino-libs/ESP32_JPEG/blob/master/examples/DecodeTest/DecodeTest.ino).

So I thought I should do a bit of a comparison.

Turns out the suggested library is pretty fast - it even beats the amazing [JPEGDEC Library]() which is already unbelievably fast.

Here's the results running on an ESP32-S3 with PSRAM.

| Library | Decode (ms) | Decode+Draw (ms) | Draw Overhead (ms) |
|------------------------|-------------|------------------|---------------|
| Bodmer/JPEGDecoder | 108 | 118 | 10 |
| Bodmer/TJpg_Decoder | 55 | 64 | 9 |
| bitbank2/JPEGDEC | 32 | 38 | 6 |
| ESP32_JPEG | 20 | 37 | 17 |

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

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.

I've done some very adhoc tests and we can get almost 50fps! Which is pretty amazing.
Binary file added data/sample.wav
Binary file not shown.
1,868 changes: 1,868 additions & 0 deletions include/images/jpeg272x233.h

Large diffs are not rendered by default.

1,950 changes: 1,950 additions & 0 deletions include/images/jpeg280x240.h

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
143 changes: 143 additions & 0 deletions lib/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
lib_deps =
SPI
SPIFFS
SD
FS
bodmer/TFT_eSPI
bodmer/JPEGDecoder
bitbank2/JPEGDEC
https://github.com/esp-arduino-libs/ESP32_JPEG
build_flags =
; maximum speed!
-Ofast
; 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
-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
; link against the ESP32_JPEG library
-L.pio/libdeps/esp32-s3-devkitc-1/ESP32_JPEG/src/esp32s3/libesp_codec.a
-L.pio/libdeps/esp32-s3-devkitc-1/ESP32_JPEG/src/esp32s3/libesp_processing.a
; decode exceptions
monitor_filters = esp32_exception_decoder
monitor_speed = 115200


[env:cheep-yellow-display]
platform = espressif32
board = esp-wrover-kit
framework = arduino
lib_deps =
SPI
SPIFFS
SD
FS
bodmer/TFT_eSPI
bodmer/JPEGDecoder
bitbank2/JPEGDEC
build_flags =
; maximum speed!
-Ofast
; TFT_eSPI setup
-DUSER_SETUP_LOADED=1
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DILI9341_2_DRIVER=1
-DTFT_SCLK=14
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_RST=-1
-DTFT_DC=2
-DTFT_CS=15
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
; -DLOAD_GLCD=1
-DLOAD_FONT2=1
; -DLOAD_FONT4=1
; -DLOAD_FONT6=1
; -DLOAD_FONT7=1
; -DLOAD_FONT8=1
; -DLOAD_GFXFF=1
; -DSMOOTH_FONT=1
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
; audio settings
-DUSE_DAC_OUTPUT=1
-DDAC_CHANNEL=I2S_DAC_CHANNEL_LEFT_EN
-DSAMPLE_RATE=16000
; decode exceptions
monitor_filters = esp32_exception_decoder
monitor_speed = 115200

[env:touchdown]
platform = espressif32
board = esp-wrover-kit
framework = arduino
platform_packages =
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.5
lib_deps =
SPI
SPIFFS
SD
FS
bodmer/TFT_eSPI
bodmer/JPEGDecoder
bitbank2/JPEGDEC
build_flags =
; maximum speed!
-Ofast
; TFT_eSPI setup
-DUSER_SETUP_LOADED=1
-DILI9488_DRIVER=1
-DTFT_BL=32
-DTFT_MISO=19
-DTFT_MOSI=23
-DTFT_SCLK=18
-DTFT_CS=15
-DTFT_DC=2
-DTFT_RST=4
-DTOUCH_CS=-1
-DLOAD_FONT2
-DTFT_BACKLIGHT_ON=HIGH
-DSPI_FREQUENCY=27000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
; audio settings - cheap yellow display uses the DAC
-DUSE_DAC_AUDIO=1
; decode exceptions
monitor_filters = esp32_exception_decoder
monitor_speed = 115200

Loading

0 comments on commit 9052453

Please sign in to comment.