Skip to content

feat: Use esp_jpeg component for decoding #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
**/build
**/sdkconfig
**/sdkconfig.old
**/dependencies.lock
**/dependencies.lock
**/managed_components/**
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(srcs
conversions/to_jpg.cpp
conversions/to_bmp.c
conversions/jpge.cpp
conversions/esp_jpg_decode.c
)

set(priv_include_dirs
Expand Down Expand Up @@ -61,7 +60,6 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
list(APPEND srcs
target/xclk.c
target/esp32s2/ll_cam.c
target/tjpgd.c
)

list(APPEND priv_include_dirs
Expand All @@ -83,7 +81,7 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
endif()

# include the SCCB I2C driver
# this uses either the legacy I2C API or the newwer version from IDF v5.4
# this uses either the legacy I2C API or the newer version from IDF v5.4
# as this features a method to obtain the I2C driver from a port number
if (idf_version VERSION_GREATER_EQUAL "5.4")
list(APPEND srcs driver/sccb-ng.c)
Expand All @@ -93,17 +91,6 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST

endif()

# CONFIG_ESP_ROM_HAS_JPEG_DECODE is available from IDF v4.4 but
# previous IDF supported chips already support JPEG decoder, hence okay to use this
if(idf_version VERSION_GREATER_EQUAL "4.4" AND NOT CONFIG_ESP_ROM_HAS_JPEG_DECODE)
list(APPEND srcs
target/tjpgd.c
)
list(APPEND priv_include_dirs
target/jpeg_include/
)
endif()

idf_component_register(
SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
Expand Down
140 changes: 0 additions & 140 deletions conversions/esp_jpg_decode.c

This file was deleted.

43 changes: 0 additions & 43 deletions conversions/include/esp_jpg_decode.h

This file was deleted.

12 changes: 9 additions & 3 deletions conversions/include/img_converters.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
// Copyright 2015-2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include "esp_camera.h"
#include "esp_jpg_decode.h"
#include "jpeg_decoder.h"

typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len);

Expand Down Expand Up @@ -121,7 +121,13 @@ bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len);
*/
bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf);

bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale);
// Macros for backwards compatibility
#define JPG_SCALE_NONE JPEG_IMAGE_SCALE_0
#define JPG_SCALE_2X JPEG_IMAGE_SCALE_1_2
#define JPG_SCALE_4X JPEG_IMAGE_SCALE_1_4
#define JPG_SCALE_8X JPEG_IMAGE_SCALE_1_8
#define JPG_SCALE_MAX JPEG_IMAGE_SCALE_1_8
bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, esp_jpeg_image_scale_t scale);

#ifdef __cplusplus
}
Expand Down
Loading