mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'fix/fix_jpeg_decode_info_v5.3' into 'release/v5.3'
fix(jpeg_decoder): Fix jpeg decoder get picture information (backport v5.3) See merge request espressif/esp-idf!35158
This commit is contained in:
@ -145,6 +145,7 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_
|
|||||||
uint8_t thischar = 0;
|
uint8_t thischar = 0;
|
||||||
uint8_t lastchar = 0;
|
uint8_t lastchar = 0;
|
||||||
uint8_t hivi = 0;
|
uint8_t hivi = 0;
|
||||||
|
uint8_t nf = 0;
|
||||||
|
|
||||||
while (header_info->buffer_left) {
|
while (header_info->buffer_left) {
|
||||||
lastchar = thischar;
|
lastchar = thischar;
|
||||||
@ -157,7 +158,8 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_
|
|||||||
height = jpeg_get_bytes(header_info, 2);
|
height = jpeg_get_bytes(header_info, 2);
|
||||||
width = jpeg_get_bytes(header_info, 2);
|
width = jpeg_get_bytes(header_info, 2);
|
||||||
|
|
||||||
jpeg_get_bytes(header_info, 1);
|
nf = jpeg_get_bytes(header_info, 1);
|
||||||
|
|
||||||
jpeg_get_bytes(header_info, 1);
|
jpeg_get_bytes(header_info, 1);
|
||||||
hivi = jpeg_get_bytes(header_info, 1);
|
hivi = jpeg_get_bytes(header_info, 1);
|
||||||
break;
|
break;
|
||||||
@ -172,19 +174,24 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_
|
|||||||
picture_info->height = height;
|
picture_info->height = height;
|
||||||
picture_info->width = width;
|
picture_info->width = width;
|
||||||
|
|
||||||
switch (hivi) {
|
if (nf == 3) {
|
||||||
case 0x11:
|
switch (hivi) {
|
||||||
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV444;
|
case 0x11:
|
||||||
break;
|
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV444;
|
||||||
case 0x21:
|
break;
|
||||||
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV422;
|
case 0x21:
|
||||||
break;
|
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV422;
|
||||||
case 0x22:
|
break;
|
||||||
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV420;
|
case 0x22:
|
||||||
break;
|
picture_info->sample_method = JPEG_DOWN_SAMPLING_YUV420;
|
||||||
default:
|
break;
|
||||||
ESP_LOGE(TAG, "Sampling factor cannot be recognized");
|
default:
|
||||||
return ESP_ERR_INVALID_STATE;
|
ESP_LOGE(TAG, "Sampling factor cannot be recognized");
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nf == 1) {
|
||||||
|
picture_info->sample_method = JPEG_DOWN_SAMPLING_GRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(header_info);
|
free(header_info);
|
||||||
|
@ -235,7 +235,7 @@ esp_err_t emit_com_marker(jpeg_enc_header_info_t *header_info)
|
|||||||
compensate_size += cache_align;
|
compensate_size += cache_align;
|
||||||
}
|
}
|
||||||
emit_marker(header_info, JPEG_M_COM & 0xff);
|
emit_marker(header_info, JPEG_M_COM & 0xff);
|
||||||
emit_word(header_info, compensate_size);
|
emit_word(header_info, compensate_size + 2);
|
||||||
for (int i = 0; i < compensate_size; i++) {
|
for (int i = 0; i < compensate_size; i++) {
|
||||||
emit_byte(header_info, 0);
|
emit_byte(header_info, 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user