mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bugfix(jpeg): Fix that jpeg driver does not distinguish err handle mode
This commit is contained in:
parent
a4e6f57a40
commit
a20d865bf5
@ -217,12 +217,12 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
|
||||
decoder_engine->conv_std = decode_cfg->conv_std;
|
||||
decoder_engine->decoded_buf = decode_outbuf;
|
||||
|
||||
ESP_GOTO_ON_ERROR(jpeg_parse_marker(decoder_engine, bit_stream, stream_size), err, TAG, "jpeg parse marker failed");
|
||||
ESP_GOTO_ON_ERROR(jpeg_parse_header_info_to_hw(decoder_engine), err, TAG, "write header info to hw failed");
|
||||
ESP_GOTO_ON_ERROR(jpeg_dec_config_dma_descriptor(decoder_engine), err, TAG, "config dma descriptor failed");
|
||||
ESP_GOTO_ON_ERROR(jpeg_parse_marker(decoder_engine, bit_stream, stream_size), err2, TAG, "jpeg parse marker failed");
|
||||
ESP_GOTO_ON_ERROR(jpeg_parse_header_info_to_hw(decoder_engine), err2, TAG, "write header info to hw failed");
|
||||
ESP_GOTO_ON_ERROR(jpeg_dec_config_dma_descriptor(decoder_engine), err2, TAG, "config dma descriptor failed");
|
||||
|
||||
*out_size = decoder_engine->header_info->process_h * decoder_engine->header_info->process_v * decoder_engine->bit_per_pixel / 8;
|
||||
ESP_GOTO_ON_FALSE((*out_size <= outbuf_size), ESP_ERR_INVALID_ARG, err, TAG, "Given buffer size % " PRId32 " is smaller than actual jpeg decode output size % " PRId32 "the height and width of output picture size will be adjusted to 16 bytes aligned automatically", outbuf_size, *out_size);
|
||||
ESP_GOTO_ON_FALSE((*out_size <= outbuf_size), ESP_ERR_INVALID_ARG, err2, TAG, "Given buffer size % " PRId32 " is smaller than actual jpeg decode output size % " PRId32 "the height and width of output picture size will be adjusted to 16 bytes aligned automatically", outbuf_size, *out_size);
|
||||
|
||||
dma2d_trans_config_t trans_desc = {
|
||||
.tx_channel_num = 1,
|
||||
@ -236,20 +236,20 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
|
||||
ret = esp_cache_msync((void*)decoder_engine->header_info->buffer_offset, decoder_engine->header_info->buffer_left, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
ESP_GOTO_ON_ERROR(dma2d_enqueue(decoder_engine->dma2d_group_handle, &trans_desc, decoder_engine->trans_desc), err, TAG, "enqueue dma2d failed");
|
||||
ESP_GOTO_ON_ERROR(dma2d_enqueue(decoder_engine->dma2d_group_handle, &trans_desc, decoder_engine->trans_desc), err2, TAG, "enqueue dma2d failed");
|
||||
bool need_yield;
|
||||
// Blocking for JPEG decode transaction finishes.
|
||||
while (1) {
|
||||
jpeg_dma2d_dec_evt_t jpeg_dma2d_event;
|
||||
BaseType_t ret_val = xQueueReceive(decoder_engine->evt_queue, &jpeg_dma2d_event, decoder_engine->timeout_tick);
|
||||
ESP_GOTO_ON_FALSE(ret_val == pdTRUE, ESP_ERR_TIMEOUT, err, TAG, "jpeg-dma2d handle jpeg decode timeout, please check image accuracy and `timeout_ms` ");
|
||||
ESP_GOTO_ON_FALSE(ret_val == pdTRUE, ESP_ERR_TIMEOUT, err1, TAG, "jpeg-dma2d handle jpeg decode timeout, please check image accuracy and `timeout_ms` ");
|
||||
|
||||
// Dealing with JPEG event
|
||||
if (jpeg_dma2d_event.jpgd_status != 0) {
|
||||
uint32_t status = jpeg_dma2d_event.jpgd_status;
|
||||
s_decoder_error_log_print(status);
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
goto err;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
if (jpeg_dma2d_event.dma_evt & JPEG_DMA2D_RX_EOF) {
|
||||
@ -265,8 +265,9 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
err1:
|
||||
dma2d_force_end(decoder_engine->trans_desc, &need_yield);
|
||||
err2:
|
||||
xSemaphoreGive(decoder_engine->codec_base->codec_mutex);
|
||||
if (decoder_engine->codec_base->pm_lock) {
|
||||
esp_pm_lock_release(decoder_engine->codec_base->pm_lock);
|
||||
|
@ -186,7 +186,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
default:
|
||||
ESP_LOGE(TAG, "wrong, we don't support encode from such format.");
|
||||
ret = ESP_ERR_NOT_SUPPORTED;
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
encoder_engine->header_info->sub_sample = encode_cfg->sub_sample;
|
||||
encoder_engine->header_info->quality = encode_cfg->image_quality;
|
||||
@ -202,7 +202,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
jpeg_ll_add_tail(hal->dev, true);
|
||||
jpeg_ll_enable_ff_check(hal->dev, true);
|
||||
jpeg_ll_set_qnr_presition(hal->dev, 0);
|
||||
ESP_GOTO_ON_ERROR(s_jpeg_set_header_info(encoder_engine), err, TAG, "set header failed");
|
||||
ESP_GOTO_ON_ERROR(s_jpeg_set_header_info(encoder_engine), err2, TAG, "set header failed");
|
||||
jpeg_hal_set_quantization_coefficient(hal, encoder_engine->header_info->m_quantization_tables[0], encoder_engine->header_info->m_quantization_tables[1]);
|
||||
|
||||
uint8_t sample_method_idx = 0;
|
||||
@ -227,7 +227,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
uint32_t dma_hb = enc_hb_tbl[best_hb_idx][sample_method_idx];
|
||||
uint32_t dma_vb = encoder_engine->mcuy;
|
||||
|
||||
ESP_GOTO_ON_FALSE((encoder_engine->header_info->header_len % cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA)) == 0, ESP_ERR_INVALID_STATE, err, TAG, "The header is not cache line aligned, please check");
|
||||
ESP_GOTO_ON_FALSE((encoder_engine->header_info->header_len % cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA)) == 0, ESP_ERR_INVALID_STATE, err2, TAG, "The header is not cache line aligned, please check");
|
||||
|
||||
// 1D direction
|
||||
memset(encoder_engine->rxlink, 0, sizeof(dma2d_descriptor_t));
|
||||
@ -248,24 +248,24 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
.on_job_picked = s_jpeg_enc_transaction_on_job_picked,
|
||||
};
|
||||
|
||||
ESP_GOTO_ON_ERROR(dma2d_enqueue(encoder_engine->dma2d_group_handle, &trans_desc, encoder_engine->trans_desc), err, TAG, "DMA2D enqueue failed");
|
||||
ESP_GOTO_ON_ERROR(dma2d_enqueue(encoder_engine->dma2d_group_handle, &trans_desc, encoder_engine->trans_desc), err2, TAG, "DMA2D enqueue failed");
|
||||
bool need_yield;
|
||||
while (1) {
|
||||
jpeg_enc_dma2d_evt_t s_rcv_event;
|
||||
BaseType_t ret_val = xQueueReceive(encoder_engine->evt_queue, &s_rcv_event, encoder_engine->timeout_tick);
|
||||
ESP_GOTO_ON_FALSE(ret_val == pdTRUE, ESP_ERR_TIMEOUT, err, TAG, "jpeg-dma2d handle jpeg decode timeout, please check image accuracy and `timeout_ms`");
|
||||
ESP_GOTO_ON_FALSE(ret_val == pdTRUE, ESP_ERR_TIMEOUT, err1, TAG, "jpeg-dma2d handle jpeg decode timeout, please check image accuracy and `timeout_ms`");
|
||||
|
||||
if (s_rcv_event.encoder_status != 0) {
|
||||
s_encoder_error_log_print(s_rcv_event.encoder_status);
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
goto err;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
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");
|
||||
ESP_GOTO_ON_ERROR(esp_cache_msync((void*)encoder_engine->rxlink, encoder_engine->dma_desc_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C), err1, 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");
|
||||
ESP_GOTO_ON_ERROR(esp_cache_msync((void*)(bit_stream + encoder_engine->header_info->header_len), _compressed_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C), err1, TAG, "sync memory to cache failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -279,8 +279,9 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
err1:
|
||||
dma2d_force_end(encoder_engine->trans_desc, &need_yield);
|
||||
err2:
|
||||
xSemaphoreGive(encoder_engine->codec_base->codec_mutex);
|
||||
if (encoder_engine->codec_base->pm_lock) {
|
||||
esp_pm_lock_release(encoder_engine->codec_base->pm_lock);
|
||||
|
Loading…
Reference in New Issue
Block a user