summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorBoris Gjenero <boris.gjenero@gmail.com>2016-01-06 00:46:42 -0500
committerGerrit Rockbox <gerrit@rockbox.org>2016-04-01 19:29:41 +0200
commit26697d08912feecd3c0c924773d518d1720f0640 (patch)
treef68906327c04fad29344f1ae30ec2c622b32c970 /apps/plugins
parent25fc7f1860f31ae31f14f17449fae8105d21f628 (diff)
Fix FS#12981 JPEG decoding problem when entropy data starts with FF
This changes JPEG fill and invalid byte handling to be like mozjpeg, and bases entropy data start on SOS marker location. Thanks to Stefan Waldmann and Dean Tersigni for reporting. Change-Id: I3c79cc6ac8d714fdc75c12b57ba427d611c99519 Chaange-Id: Ibc7c17d38d5be63642bdaf6adfd6acc2a6cf4450
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/imageviewer/jpeg/jpeg_decoder.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/plugins/imageviewer/jpeg/jpeg_decoder.c b/apps/plugins/imageviewer/jpeg/jpeg_decoder.c
index 0adff53788..342b59c6a4 100644
--- a/apps/plugins/imageviewer/jpeg/jpeg_decoder.c
+++ b/apps/plugins/imageviewer/jpeg/jpeg_decoder.c
@@ -507,29 +507,27 @@ static void idct8x8(unsigned char* p_byte, int* inptr, int* quantptr, int skip_l
/* Preprocess the JPEG JFIF file */
int process_markers(unsigned char* p_src, long size, struct jpeg* p_jpeg)
{
- unsigned char* p_bytes = p_src;
+ unsigned char* p_end = p_src + size;
int marker_size; /* variable length of marker segment */
int i, j, n;
int ret = 0; /* returned flags */
- p_jpeg->p_entropy_end = p_src + size;
+ p_jpeg->p_entropy_end = p_end;
- while (p_src < p_bytes + size)
+ while (p_src < p_end)
{
if (*p_src++ != 0xFF) /* no marker? */
{
- p_src--; /* it's image data, put it back */
- p_jpeg->p_entropy_data = p_src;
- break; /* exit marker processing */
+ continue; /* discard */
}
switch (*p_src++)
{
- case 0xFF: /* Fill byte */
- ret |= FILL_FF;
- case 0x00: /* Zero stuffed byte - entropy data */
- p_src--; /* put it back */
+ case 0xFF: /* Previous FF was fill byte */
+ p_src--; /* This FF could be start of a marker */
continue;
+ case 0x00: /* Zero stuffed byte - discard */
+ break;
case 0xC0: /* SOF Huff - Baseline DCT */
{
@@ -657,6 +655,8 @@ int process_markers(unsigned char* p_src, long size, struct jpeg* p_jpeg)
p_jpeg->scanheader[i].AC_select = *p_src++ & 0x0F;
}
p_src += 3; /* skip spectral information */
+ p_jpeg->p_entropy_data = p_src;
+ p_end = p_src; /* exit while loop */
}
break;