From 34fa37bbb4d690843b1d51c311c1f240a5d0570e Mon Sep 17 00:00:00 2001 From: Jeremy Sawicki Date: Thu, 2 Mar 2017 21:40:40 -0800 Subject: [PATCH] stb_image: JPEG: Accept any component IDs --- stb_image.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/stb_image.h b/stb_image.h index 3940f38..0b5989b 100644 --- a/stb_image.h +++ b/stb_image.h @@ -3004,13 +3004,8 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) for (i=0; i < s->img_n; ++i) { static unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); - if (z->img_comp[i].id != i+1) // JFIF requires - if (z->img_comp[i].id != i) { // some version of jpegtran outputs non-JFIF-compliant files! - // somethings output this (see http://fileformats.archiveteam.org/wiki/JPEG#Color_format) - if (z->img_comp[i].id != rgb[i]) - return stbi__err("bad component ID","Corrupt JPEG"); - ++z->rgb; - } + if (z->img_comp[i].id == rgb[i]) + ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG");