mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(jpeg): Modify jpeg deocde/encode error handling logic, fix if one picture wrong, all picture wrong issue
This commit is contained in:
parent
06cc3419d8
commit
c620a2fa39
@ -242,15 +242,14 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
|
||||
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 `timeout_ms` ");
|
||||
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` ");
|
||||
|
||||
// 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);
|
||||
dma2d_force_end(decoder_engine->trans_desc, &need_yield);
|
||||
xSemaphoreGive(decoder_engine->codec_base->codec_mutex);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (jpeg_dma2d_event.dma_evt & JPEG_DMA2D_RX_EOF) {
|
||||
@ -260,11 +259,18 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
|
||||
}
|
||||
}
|
||||
|
||||
err:
|
||||
xSemaphoreGive(decoder_engine->codec_base->codec_mutex);
|
||||
if (decoder_engine->codec_base->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_release(decoder_engine->codec_base->pm_lock), TAG, "release pm_lock failed");
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
dma2d_force_end(decoder_engine->trans_desc, &need_yield);
|
||||
xSemaphoreGive(decoder_engine->codec_base->codec_mutex);
|
||||
if (decoder_engine->codec_base->pm_lock) {
|
||||
esp_pm_lock_release(decoder_engine->codec_base->pm_lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -249,11 +249,11 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
};
|
||||
|
||||
ESP_GOTO_ON_ERROR(dma2d_enqueue(encoder_engine->dma2d_group_handle, &trans_desc, encoder_engine->trans_desc), err, 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 `timeout_ms`");
|
||||
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`");
|
||||
|
||||
if (s_rcv_event.encoder_status != 0) {
|
||||
s_encoder_error_log_print(s_rcv_event.encoder_status);
|
||||
@ -273,11 +273,18 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
compressed_size += encoder_engine->header_info->header_len;
|
||||
*out_size = compressed_size;
|
||||
|
||||
err:
|
||||
xSemaphoreGive(encoder_engine->codec_base->codec_mutex);
|
||||
if (encoder_engine->codec_base->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_release(encoder_engine->codec_base->pm_lock), TAG, "release pm_lock failed");
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
dma2d_force_end(encoder_engine->trans_desc, &need_yield);
|
||||
xSemaphoreGive(encoder_engine->codec_base->codec_mutex);
|
||||
if (encoder_engine->codec_base->pm_lock) {
|
||||
esp_pm_lock_release(encoder_engine->codec_base->pm_lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user