Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed May 10, 2024
1 parent 3a740a4 commit a5dd182
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/libesp32_div/ESP32_JPDEC/src/alt_esp_jpg_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "alt_tjpgd.h" // using software decoder

#include "alt_esp_jpg_decode.h"

#include "esp_system.h"
Expand All @@ -19,6 +22,13 @@
extern void AddLog(uint32_t loglevel, PGM_P formatP, ...);
enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE};

//#define JPEG_IN_ROM

#ifdef JPEG_IN_ROM
JRESULT jd_prepare(JDEC * jd, size_t (*infunc)(JDEC *, uint8_t *, size_t), void * pool, size_t sz_pool, void * dev);
JRESULT jd_decomp(JDEC * jd, int (*outfunc)(JDEC *, void *, JRECT *), uint8_t scale);
#endif

#if 1
/*
#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+
Expand All @@ -38,7 +48,7 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D
#endif
*/

#include "alt_tjpgd.h" // using software decoder



#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
Expand Down Expand Up @@ -118,7 +128,11 @@ esp_err_t alt_esp_jpg_decode(size_t len, uint8_t scale, alt_jpg_reader_cb reader
jpeg.scale = scale;
jpeg.index = 0;

#ifdef JPEG_IN_ROM
JRESULT jres = jd_prepare(&decoder, _jpg_read, work, ALT_JPEG_WORKSIZE, &jpeg);
#else
JRESULT jres = alt_jd_prepare(&decoder, _jpg_read, work, ALT_JPEG_WORKSIZE, &jpeg);
#endif
if (jres != JDR_OK){
//ESP_LOGE(TAG, "JPG Header Parse Failed! %s", jd_errors[jres]);
AddLog(LOG_LEVEL_INFO, PSTR("JPG Header Parse Failed! %s"), jd_errors[jres]);
Expand All @@ -132,7 +146,11 @@ esp_err_t alt_esp_jpg_decode(size_t len, uint8_t scale, alt_jpg_reader_cb reader
//output start
writer(arg, 0, 0, output_width, output_height, NULL);
//output write
#ifdef JPEG_IN_ROM
jres = jd_decomp(&decoder, _jpg_write, (uint8_t)jpeg.scale);
#else
jres = alt_jd_decomp(&decoder, _jpg_write, (uint8_t)jpeg.scale);
#endif
//output end
writer(arg, output_width, output_height, output_width, output_height, NULL);

Expand Down
4 changes: 4 additions & 0 deletions lib/libesp32_div/ESP32_JPDEC/src/alt_esp_jpg_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ typedef bool (* alt_jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t

esp_err_t alt_esp_jpg_decode(size_t len, u_int8_t scale, alt_jpg_reader_cb reader, alt_jpg_writer_cb writer, void * arg);

typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len);
typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data);


0 comments on commit a5dd182

Please sign in to comment.