Skip to content

Commit 78ed3da

Browse files
committed
imageviewer: Use jpeg progressive decoder only for progressive jpeg
As new decoder has no optimizations for small memory targets Change-Id: I7d4c06bdfc22d76883e2eb16cbd97ed4b3824161
1 parent 0f4d029 commit 78ed3da

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

apps/plugins/imageviewer/image_decoder.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525

2626
static const char *decoder_names[MAX_IMAGE_TYPES] = {
2727
"bmp",
28-
"jpegp", // Use jpeg for old decoder, jpegp for new
28+
"jpeg", // Default decoder for jpeg: Use jpeg for old decoder, jpegp for new
2929
"png",
3030
#ifdef HAVE_LCD_COLOR
3131
"ppm",
3232
#endif
33-
"gif"
33+
"gif",
34+
"jpegp",
3435
};
3536

3637
/* Check file type by magic number or file extension

apps/plugins/imageviewer/image_decoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum image_type {
3333
IMAGE_PPM,
3434
#endif
3535
IMAGE_GIF,
36+
IMAGE_JPEG_PROGRESSIVE,
3637
MAX_IMAGE_TYPES
3738
};
3839

apps/plugins/imageviewer/imageviewer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,8 @@ static int load_and_show(char* filename, struct image_info *info)
855855
}
856856
if (image_type != status) /* type of image is changed, load decoder. */
857857
{
858+
reload_decoder:;
859+
858860
struct loader_info loader_info = {
859861
status, &iv_api, decoder_buf, decoder_buf_size,
860862
};
@@ -881,6 +883,13 @@ static int load_and_show(char* filename, struct image_info *info)
881883
else
882884
status = imgdec->load_image(filename, info, buf, &remaining);
883885

886+
if (status == PLUGIN_JPEG_PROGRESSIVE)
887+
{
888+
release_decoder();
889+
status = IMAGE_JPEG_PROGRESSIVE;
890+
goto reload_decoder;
891+
}
892+
884893
if (status == PLUGIN_OUTOFMEM)
885894
{
886895
#ifdef USE_PLUG_BUF

apps/plugins/imageviewer/imageviewer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum {
5555
PLUGIN_OTHER = 0x200,
5656
PLUGIN_ABORT,
5757
PLUGIN_OUTOFMEM,
58+
PLUGIN_JPEG_PROGRESSIVE,
5859

5960
ZOOM_IN,
6061
ZOOM_OUT,

apps/plugins/imageviewer/jpeg/jpeg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ static int load_image(char *filename, struct image_info *info,
170170

171171
if (status < 0 || (status & (DQT | SOF0)) != (DQT | SOF0))
172172
{ /* bad format or minimum components not contained */
173-
rb->splashf(HZ, "unsupported %d", status);
174-
return PLUGIN_ERROR;
173+
//rb->splashf(HZ, "unsupported %d", status);
174+
return PLUGIN_JPEG_PROGRESSIVE;
175175
}
176176

177177
if (!(status & DHT)) /* if no Huffman table present: */

0 commit comments

Comments
 (0)