Skip to content

Commit 92fba58

Browse files
authored
Merge branch 'moononournation:master' into master
2 parents 1169a4a + 6ea1f22 commit 92fba58

19 files changed

+1536
-284
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,14 @@ ESP32LCD8, ESP32LCD16 and ESP32RGBPanel only supported by arduino-esp32 v2.x and
353353
* [Makerfabs ESP32-S3 TFT 4.3" v1.3](https://www.makerfabs.com/esp32-s3-parallel-tft-with-touch-4-3-inch.html) [[demo video](https://youtu.be/oQ57L2gTHoo)]
354354
* [Odroid Go](https://www.hardkernel.com/shop/odroid-go/)
355355
* [seeed studio Wio Terminal](https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/)
356+
* [Waveshare ESP32-C6-LCD-1.47](https://www.waveshare.com/esp32-c6-lcd-1.47.htm?&aff_id=107987)
357+
* [Waveshare ESP32-S3 1.46inch Round Display Development Board](https://www.waveshare.com/esp32-s3-touch-lcd-1.46b.htm?&aff_id=107987) [[demo video](https://youtube.com/shorts/tqyqxdRA550)]
358+
* [Waveshare ESP32-S3-Touch-LCD-1.3](https://www.waveshare.com/esp32-s3-lcd-1.3.htm?&aff_id=107987) [[demo video](https://youtube.com/shorts/_n3qTa_nVGE)]
359+
* [Waveshare ESP32-S3-Touch-LCD-1.3 with case and prism cube](https://www.waveshare.com/esp32-s3-lcd-1.3.htm?sku=30559&aff_id=107987) [[demo video](https://youtube.com/shorts/tqyqxdRA550)]
360+
* [Waveshare ESP32-S3-Touch-LCD-2.8](https://www.waveshare.com/esp32-s3-touch-lcd-2.8.htm?&aff_id=107987) [[demo video](https://youtube.com/shorts/1RU_EanUgSU)
356361
* [Waveshare RP2040-LCD-0.96](https://www.waveshare.com/rp2040-lcd-0.96.htm?&aff_id=107987)
357362
* [Waveshare RP2040-LCD-1.28](https://www.waveshare.com/rp2040-lcd-1.28.htm?&aff_id=107987)
358363
* [Waveshare RP2350-LCD-0.96](https://www.waveshare.com/rp2350-lcd-0.96.htm?&aff_id=107987)
359-
* [Waveshare ESP32-C6-LCD-1.47](https://www.waveshare.com/esp32-c6-lcd-1.47.htm?&aff_id=107987)
360-
* [Waveshare ESP32-S3-Touch-LCD-2.8](https://www.waveshare.com/esp32-s3-touch-lcd-2.8.htm?&aff_id=107987)
361364
* [wireless-tag WT-32-SC01](http://www.wireless-tag.com/portfolio/wt32-sc01/)
362365
* [Elecrow ESP Terminal with 3.5" parallel RGB display DLC35010R](https://www.elecrow.com/esp-terminal-with-esp32-3-5-inch-parallel-480x320-tft-capacitive-touch-display-rgb-by-chip-ili9488.html) [[demo video](https://youtu.be/QRDVuwayNFw)]
363366
* [Elecrow Wizee-ESP32 WZ8048C050](https://www.elecrow.com/esp32-display-5-inch-hmi-display-rgb-tft-lcd-touch-screen-support-lvgl.html)
@@ -376,6 +379,7 @@ ESP32LCD8, ESP32LCD16 and ESP32RGBPanel only supported by arduino-esp32 v2.x and
376379
### Currently Supported Display [[Wiki](https://github.com/moononournation/Arduino_GFX/wiki/Display-Class)]
377380

378381
* GC9A01 240x240 round display [[demo video](https://youtu.be/kJrAFm20-zg)]
382+
* GC9C01 360x360 round display [[demo video](https://youtube.com/shorts/Sk9sVT9PawA)]
379383
* GC9106 80x160 [[demo video](https://youtu.be/RToGeeb1jxQ)]
380384
* GC9107 128x128 [[demo video](https://youtube.com/shorts/V1MCQ1tQ8PM)]
381385
* GC9503V 480x480 (RGB) [[demo video](https://youtube.com/shorts/hk7ZMBRCmjI)]
@@ -401,6 +405,7 @@ ESP32LCD8, ESP32LCD16 and ESP32RGBPanel only supported by arduino-esp32 v2.x and
401405
* NT35310 320x480 [[demo video](https://youtu.be/bvIz5CoYPNk)]
402406
* NT35510 480x800 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/C_1ASzUN3bg)]
403407
* NT39125 240x376 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/JGMrM18JAFA)]
408+
* NV3007 142x428 [[demo video](https://youtube.com/shorts/ePcf0LmMgOo)]
404409
* NV3041A 480x272 [[demo video](https://youtu.be/pd1DTW9QHkg)]
405410
* OTM8009A 480x800 (8-bit/16-bit Parallel)
406411
* R61529 320x480 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/s93gxjbIAT8)]
@@ -495,3 +500,5 @@ ESP32LCD8, ESP32LCD16 and ESP32RGBPanel only supported by arduino-esp32 v2.x and
495500
As you may already aware there are lack of sponsorship in this project. Convert the funding in terms of man power, it is much lower than 1 man hour per month. So don't expect too much on the support. Expecially the features not realted to my planned maker projects ;>
496501

497502
For the same reason, Arduino_GFX only focus on the Arduino IDE support. Any other IDE, e.g. PlatformIO, if you found an issue at that IDE but normal at Arduino IDE, please direct report to that IDE for better support.
503+
504+
**Please use Discussions space for new hardware support or new feature request. I will direct close any non-issue issues. And I will consider report the users who insist raising duplicate issue continuously.**

examples/ImgViewer/ImgViewerMjpeg_ESP32P4/MjpegClass.h

Lines changed: 73 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,17 @@
77
#pragma once
88

99
#if defined(ESP32)
10-
11-
#define READ_BUFFER_SIZE 1024
12-
1310
#include <driver/jpeg_decode.h>
1411

12+
#define READ_BATCH_SIZE 1024
13+
1514
class MjpegClass
1615
{
1716
public:
1817
bool setup(const char *path)
1918
{
2019
_input = fopen(path, "r");
21-
_inputindex = 0;
22-
23-
if (!_read_buf)
24-
{
25-
_read_buf = (uint8_t *)malloc(READ_BUFFER_SIZE);
26-
}
27-
28-
if (!_read_buf)
29-
{
30-
return false;
31-
}
20+
_read = 0;
3221

3322
jpeg_decode_engine_cfg_t decode_eng_cfg = {
3423
.intr_priority = 0,
@@ -62,106 +51,112 @@ class MjpegClass
6251

6352
bool readMjpegBuf()
6453
{
65-
if (_inputindex == 0)
54+
if (_read == 0)
6655
{
67-
_buf_read = fread(_read_buf, 1, READ_BUFFER_SIZE, _input);
68-
_inputindex += _buf_read;
56+
// _mjpeg_buf empty
57+
_read = fread(_mjpeg_buf, 1, READ_BATCH_SIZE, _input);
6958
}
70-
_mjpeg_buf_offset = 0;
71-
int i = 0;
59+
else
60+
{
61+
// pad previous remain data to the start of _mjpeg_buf
62+
memcpy(_mjpeg_buf, _p, _read);
63+
}
64+
7265
bool found_FFD8 = false;
73-
while ((_buf_read > 0) && (!found_FFD8))
66+
_p = _mjpeg_buf;
67+
while ((_read > 0) && (!found_FFD8))
7468
{
75-
i = 0;
76-
while ((i < _buf_read) && (!found_FFD8))
69+
while ((_read > 1) && (!found_FFD8))
7770
{
78-
if ((_read_buf[i] == 0xFF) && (_read_buf[i + 1] == 0xD8)) // JPEG header
71+
--_read;
72+
if ((*_p++ == 0xFF) && (*_p == 0xD8)) // JPEG header
7973
{
8074
// Serial.printf("Found FFD8 at: %d.\n", i);
8175
found_FFD8 = true;
8276
}
83-
++i;
8477
}
85-
if (found_FFD8)
78+
if (!found_FFD8)
8679
{
87-
--i;
88-
}
89-
else
90-
{
91-
_buf_read = fread(_read_buf, 1, READ_BUFFER_SIZE, _input);
80+
if (*_p == 0xFF)
81+
{
82+
_mjpeg_buf[0] = 0xFF;
83+
_read = fread(_mjpeg_buf + 1, 1, READ_BATCH_SIZE, _input) + 1;
84+
}
85+
else
86+
{
87+
_read = fread(_mjpeg_buf, 1, READ_BATCH_SIZE, _input);
88+
}
89+
_p = _mjpeg_buf;
9290
}
9391
}
94-
uint8_t *_p = _read_buf + i;
95-
_buf_read -= i;
92+
93+
if (!found_FFD8)
94+
{
95+
return false;
96+
}
97+
98+
// rewind 1 byte
99+
--_p;
100+
++_read;
101+
102+
// pad JPEG header to the start of _mjpeg_buf
103+
if (_p > _mjpeg_buf)
104+
{
105+
Serial.println("(_p > _mjpeg_buf)");
106+
memcpy(_mjpeg_buf, _p, _read);
107+
}
108+
109+
// skip JPEG header
110+
_p += 2;
111+
_read -= 2;
112+
113+
if (_read == 0)
114+
{
115+
_read = fread(_p, 1, READ_BATCH_SIZE, _input);
116+
}
117+
96118
bool found_FFD9 = false;
97-
if (_buf_read > 0)
119+
while ((_read > 0) && (!found_FFD9))
98120
{
99-
i = 3;
100-
while ((_buf_read > 0) && (!found_FFD9))
121+
while ((_read > 1) && (!found_FFD9))
101122
{
102-
if ((_mjpeg_buf_offset > 0) && (_mjpeg_buf[_mjpeg_buf_offset - 1] == 0xFF) && (_p[0] == 0xD9)) // JPEG trailer
123+
--_read;
124+
if ((*_p++ == 0xFF) && (*_p == 0xD9)) // JPEG trailer
103125
{
104126
// Serial.printf("Found FFD9 at: %d.\n", i);
105127
found_FFD9 = true;
106128
}
107-
else
108-
{
109-
while ((i < _buf_read) && (!found_FFD9))
110-
{
111-
if ((_p[i] == 0xFF) && (_p[i + 1] == 0xD9)) // JPEG trailer
112-
{
113-
found_FFD9 = true;
114-
++i;
115-
}
116-
++i;
117-
}
118-
}
119-
120-
// Serial.printf("i: %d\n", i);
121-
memcpy(_mjpeg_buf + _mjpeg_buf_offset, _p, i);
122-
_mjpeg_buf_offset += i;
123-
size_t o = _buf_read - i;
124-
if (o > 0)
125-
{
126-
// Serial.printf("o: %d\n", o);
127-
memcpy(_read_buf, _p + i, o);
128-
_buf_read = fread(_read_buf + o, 1, READ_BUFFER_SIZE - o, _input);
129-
_p = _read_buf;
130-
_inputindex += _buf_read;
131-
_buf_read += o;
132-
// Serial.printf("_buf_read: %d\n", _buf_read);
133-
}
134-
else
135-
{
136-
_buf_read = fread(_read_buf, 1, READ_BUFFER_SIZE, _input);
137-
_p = _read_buf;
138-
_inputindex += _buf_read;
139-
}
140-
i = 0;
141129
}
142-
if (found_FFD9)
130+
131+
if (!found_FFD9)
143132
{
144-
return true;
133+
_read += fread(_p + _read, 1, READ_BATCH_SIZE, _input);
134+
// Serial.printf("_read: %d\n", _read - 1);
145135
}
146136
}
147137

138+
if (found_FFD9)
139+
{
140+
++_p;
141+
--_read;
142+
return true;
143+
}
144+
148145
return false;
149146
}
150147

151148
bool decodeJpg()
152149
{
153-
_remain = _mjpeg_buf_offset;
154-
155150
jpeg_decode_picture_info_t header_info;
156-
ESP_ERROR_CHECK(jpeg_decoder_get_info(_mjpeg_buf, _remain, &header_info));
151+
ESP_ERROR_CHECK(jpeg_decoder_get_info(_mjpeg_buf, _p - _mjpeg_buf, &header_info));
157152
_w = header_info.width;
158153
_h = header_info.height;
159154
uint32_t out_size;
160155
jpeg_decode_cfg_t decode_cfg_rgb = {
161156
.output_format = JPEG_DECODE_OUT_FORMAT_RGB565,
162157
.rgb_order = JPEG_DEC_RGB_ELEMENT_ORDER_BGR,
163158
};
164-
ESP_ERROR_CHECK(jpeg_decoder_process(_decoder_engine, &decode_cfg_rgb, (const uint8_t *)_mjpeg_buf, _remain, (uint8_t *)_output_buf, MJPEG_OUTPUT_SIZE, &out_size));
159+
ESP_ERROR_CHECK(jpeg_decoder_process(_decoder_engine, &decode_cfg_rgb, (const uint8_t *)_mjpeg_buf, _p - _mjpeg_buf, (uint8_t *)_output_buf, MJPEG_OUTPUT_SIZE, &out_size));
165160

166161
return true;
167162
}
@@ -191,16 +186,11 @@ class MjpegClass
191186
uint8_t *_mjpeg_buf;
192187
uint16_t *_output_buf;
193188

194-
uint8_t *_read_buf;
195-
int32_t _mjpeg_buf_offset = 0;
196-
197189
jpeg_decoder_handle_t _decoder_engine;
198-
199190
int16_t _w = 0, _h = 0;
200191

201-
int32_t _inputindex = 0;
202-
int32_t _buf_read;
203-
int32_t _remain = 0;
192+
uint8_t *_p;
193+
int32_t _read;
204194
};
205195

206196
#endif // defined(ESP32)

0 commit comments

Comments
 (0)