mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(jpeg): Fix several issues reported recently,
1. Fix decode images with dri marker failed, 2. Fix encode sometimes get length error
This commit is contained in:
parent
39a1e17c32
commit
7f97a9e524
@ -271,7 +271,6 @@ err:
|
||||
esp_err_t jpeg_del_decoder_engine(jpeg_decoder_handle_t decoder_engine)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(decoder_engine, ESP_ERR_INVALID_ARG, TAG, "jpeg decode handle is null");
|
||||
ESP_RETURN_ON_ERROR(jpeg_release_codec_handle(decoder_engine->codec_base), TAG, "release codec failed");
|
||||
|
||||
if (decoder_engine) {
|
||||
if (decoder_engine->rxlink) {
|
||||
@ -295,6 +294,7 @@ esp_err_t jpeg_del_decoder_engine(jpeg_decoder_handle_t decoder_engine)
|
||||
if (decoder_engine->intr_handle) {
|
||||
jpeg_isr_deregister(decoder_engine->codec_base, decoder_engine->intr_handle);
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(jpeg_release_codec_handle(decoder_engine->codec_base), TAG, "release codec failed");
|
||||
free(decoder_engine);
|
||||
}
|
||||
return ESP_OK;
|
||||
|
@ -262,6 +262,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
}
|
||||
|
||||
if (s_rcv_event.dma_evt & JPEG_DMA2D_RX_EOF) {
|
||||
ESP_GOTO_ON_ERROR(esp_cache_msync((void*)encoder_engine->rxlink, encoder_engine->dma_desc_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C), err, TAG, "sync memory to cache failed");
|
||||
compressed_size = s_dma_desc_get_len(encoder_engine->rxlink);
|
||||
uint32_t _compressed_size = JPEG_ALIGN_UP(compressed_size, cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA));
|
||||
ESP_GOTO_ON_ERROR(esp_cache_msync((void*)(bit_stream + encoder_engine->header_info->header_len), _compressed_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C), err, TAG, "sync memory to cache failed");
|
||||
@ -283,7 +284,6 @@ err:
|
||||
esp_err_t jpeg_del_encoder_engine(jpeg_encoder_handle_t encoder_engine)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(encoder_engine, ESP_ERR_INVALID_ARG, TAG, "jpeg encoder handle is null");
|
||||
ESP_RETURN_ON_ERROR(jpeg_release_codec_handle(encoder_engine->codec_base), TAG, "release codec failed");
|
||||
|
||||
if (encoder_engine) {
|
||||
if (encoder_engine->rxlink) {
|
||||
@ -307,6 +307,7 @@ esp_err_t jpeg_del_encoder_engine(jpeg_encoder_handle_t encoder_engine)
|
||||
if (encoder_engine->intr_handle) {
|
||||
jpeg_isr_deregister(encoder_engine->codec_base, encoder_engine->intr_handle);
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(jpeg_release_codec_handle(encoder_engine->codec_base), TAG, "release codec failed");
|
||||
free(encoder_engine);
|
||||
}
|
||||
return ESP_OK;
|
||||
|
@ -130,10 +130,10 @@ esp_err_t jpeg_parse_sof_marker(jpeg_dec_header_info_t *header_info)
|
||||
|
||||
// The vertical and horizontal in process must be divided by mcu block.
|
||||
if (header_info->origin_v % header_info->mcuy != 0) {
|
||||
header_info->process_v = (ceil(header_info->origin_v / header_info->mcuy) + 1) * header_info->mcuy;
|
||||
header_info->process_v = (uint32_t)(ceil(header_info->origin_v / header_info->mcuy) + 1) * header_info->mcuy;
|
||||
}
|
||||
if (header_info->origin_h % header_info->mcux != 0) {
|
||||
header_info->process_h = (ceil(header_info->origin_h / header_info->mcux) + 1) * header_info->mcux;
|
||||
header_info->process_h = (uint32_t)(ceil(header_info->origin_h / header_info->mcux) + 1) * header_info->mcux;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
|
@ -87,7 +87,7 @@ typedef struct {
|
||||
uint8_t huffcode[2][2][JPEG_HUFFMAN_AC_VALUE_TABLE_LEN]; // Huffman decoded data tables [id][dcac]
|
||||
uint32_t tmp_huff[JPEG_HUFFMAN_AC_VALUE_TABLE_LEN]; // temp buffer to store huffman code
|
||||
bool dri_marker; // If we have dri marker in table
|
||||
uint8_t ri; // Restart interval
|
||||
uint16_t ri; // Restart interval
|
||||
} jpeg_dec_header_info_t;
|
||||
|
||||
struct jpeg_decoder_t {
|
||||
|
Loading…
Reference in New Issue
Block a user