mirror of https://github.com/nothings/stb.git
stb_image: JPEG: Accept any component IDs
This commit is contained in:
parent
59a5a155b4
commit
34fa37bbb4
|
@ -3004,13 +3004,8 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan)
|
||||||
for (i=0; i < s->img_n; ++i) {
|
for (i=0; i < s->img_n; ++i) {
|
||||||
static unsigned char rgb[3] = { 'R', 'G', 'B' };
|
static unsigned char rgb[3] = { 'R', 'G', 'B' };
|
||||||
z->img_comp[i].id = stbi__get8(s);
|
z->img_comp[i].id = stbi__get8(s);
|
||||||
if (z->img_comp[i].id != i+1) // JFIF requires
|
if (z->img_comp[i].id == rgb[i])
|
||||||
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;
|
++z->rgb;
|
||||||
}
|
|
||||||
q = stbi__get8(s);
|
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].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");
|
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");
|
||||||
|
|
Loading…
Reference in New Issue