forked from espressif/esp-idf
test(jpeg_encoder): Add the test support for jpeg encoder
This commit is contained in:
@ -11,3 +11,4 @@ project(jpeg_test)
|
||||
|
||||
target_add_binary_data(jpeg_test.elf "${IDF_PATH}/examples/peripherals/jpeg/jpeg_decode/resources/esp720.jpg" BINARY)
|
||||
target_add_binary_data(jpeg_test.elf "${IDF_PATH}/examples/peripherals/jpeg/jpeg_decode/resources/esp1080.jpg" BINARY)
|
||||
target_add_binary_data(jpeg_test.elf "resources/esp480.rgb" BINARY)
|
||||
|
@ -1,7 +1,18 @@
|
||||
set(srcs "test_app_main.c"
|
||||
"test_jpeg_decode.c"
|
||||
)
|
||||
|
||||
if(CONFIG_SOC_JPEG_DECODE_SUPPORTED)
|
||||
list(APPEND srcs
|
||||
"test_jpeg_decode.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_JPEG_ENCODE_SUPPORTED)
|
||||
list(APPEND srcs
|
||||
"test_jpeg_encode.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_driver_jpeg unity esp_psram test_utils
|
||||
WHOLE_ARCHIVE)
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "unity.h"
|
||||
#include "test_utils.h"
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "driver/jpeg_encode.h"
|
||||
#include "esp_log.h"
|
||||
#include "test_jpeg_performance.h"
|
||||
#include "esp_system.h"
|
||||
#include "ccomp_timer.h"
|
||||
|
||||
extern const uint8_t image_esp480_rgb_start[] asm("_binary_esp480_rgb_start");
|
||||
extern const uint8_t image_esp480_rgb_end[] asm("_binary_esp480_rgb_end");
|
||||
|
||||
TEST_CASE("JPEG encode driver memory leaking check", "[jpeg]")
|
||||
{
|
||||
jpeg_encoder_handle_t encoder_handle;
|
||||
|
||||
jpeg_encode_engine_cfg_t encode_eng_cfg = {
|
||||
.timeout_ms = 40,
|
||||
};
|
||||
|
||||
int size = esp_get_free_heap_size();
|
||||
for (uint32_t i = 0; i <= 10; i++) {
|
||||
TEST_ESP_OK(jpeg_new_encoder_engine(&encode_eng_cfg, &encoder_handle));
|
||||
TEST_ESP_OK(jpeg_del_encoder_engine(encoder_handle));
|
||||
}
|
||||
|
||||
TEST_ASSERT_INT_WITHIN(400, size, esp_get_free_heap_size());
|
||||
}
|
||||
|
||||
TEST_CASE("JPEG encode performance test for 480*640 RGB->YUV picture", "[jpeg]")
|
||||
{
|
||||
jpeg_encoder_handle_t jpeg_handle = NULL;
|
||||
|
||||
jpeg_encode_engine_cfg_t encode_eng_cfg = {
|
||||
.intr_priority = 0,
|
||||
.timeout_ms = 40,
|
||||
};
|
||||
|
||||
jpeg_encode_cfg_t enc_config = {
|
||||
.src_type = JPEG_ENCODE_IN_FORMAT_RGB888,
|
||||
.sub_sample = JPEG_DOWN_SAMPLING_YUV422,
|
||||
.image_quality = 80,
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
};
|
||||
|
||||
jpeg_encode_memory_alloc_cfg_t rx_mem_cfg = {
|
||||
.buffer_direction = JPEG_DEC_ALLOC_OUTPUT_BUFFER,
|
||||
};
|
||||
|
||||
jpeg_encode_memory_alloc_cfg_t tx_mem_cfg = {
|
||||
.buffer_direction = JPEG_DEC_ALLOC_INPUT_BUFFER,
|
||||
};
|
||||
|
||||
size_t rx_buffer_size = 0;
|
||||
uint8_t *jpg_buf_480p = (uint8_t*)jpeg_alloc_encoder_mem(480 * 640 * 3, &rx_mem_cfg, &rx_buffer_size);
|
||||
|
||||
uint32_t jpg_size_480p = 0;
|
||||
|
||||
size_t bit_stream_length = (size_t)image_esp480_rgb_end - (size_t)image_esp480_rgb_start;
|
||||
|
||||
size_t tx_buffer_size = 0;
|
||||
uint8_t *raw_buf_480p = (uint8_t*)jpeg_alloc_encoder_mem(bit_stream_length, &tx_mem_cfg, &tx_buffer_size);
|
||||
// Copy bit stream to psram
|
||||
memcpy(raw_buf_480p, image_esp480_rgb_start, bit_stream_length);
|
||||
TEST_ESP_OK(jpeg_new_encoder_engine(&encode_eng_cfg, &jpeg_handle));
|
||||
|
||||
ccomp_timer_start();
|
||||
|
||||
// Decode picture for 50 times, and get the average
|
||||
uint8_t cnt = 50;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
TEST_ESP_OK(jpeg_encoder_process(jpeg_handle, &enc_config, raw_buf_480p, bit_stream_length, jpg_buf_480p, rx_buffer_size, &jpg_size_480p));
|
||||
}
|
||||
int64_t encode_time = ccomp_timer_stop();
|
||||
|
||||
TEST_PERFORMANCE_GREATER_THAN(JPEG_ENCODE_RGB888_2_480P_PERFORMANCE, "480p from rgb888 -> *.jpg speed is %lld fps", 1 * 1000 * 1000 / (encode_time / cnt));
|
||||
|
||||
free(jpg_buf_480p);
|
||||
free(raw_buf_480p);
|
||||
TEST_ESP_OK(jpeg_del_encoder_engine(jpeg_handle));
|
||||
}
|
@ -11,8 +11,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Decoder performance lists
|
||||
#define IDF_PERFORMANCE_MIN_JPEG_DECODE_1080P_2_RGB565_PERFORMANCE 40 // 40 fps for 1080p decoder.
|
||||
|
||||
// Encoder performance lists
|
||||
#define IDF_PERFORMANCE_MIN_JPEG_ENCODE_RGB888_2_480P_PERFORMANCE 160 // 160 fps for 480p encoder.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,5 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x6000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
factory, app, factory, , 2M,
|
|
Binary file not shown.
@ -7,3 +7,9 @@ CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_MODE_HEX=y
|
||||
CONFIG_SPIRAM_SPEED_200M=y
|
||||
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
|
||||
|
||||
# Partition table configurations
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
|
Reference in New Issue
Block a user