Pārlūkot izejas kodu

tweaks to previous merge

Sean Barrett 8 gadi atpakaļ
vecāks
revīzija
6d60610348
1 mainītis faili ar 5 papildinājumiem un 6 dzēšanām
  1. 5 6
      stb_image.h

+ 5 - 6
stb_image.h

@@ -1693,7 +1693,7 @@ typedef struct
    int            succ_low;
    int            succ_low;
    int            eob_run;
    int            eob_run;
    int            jfif;
    int            jfif;
-   int            app14;
+   int            app14_color_transform; // Adobe APP14 tag
    int            rgb;
    int            rgb;
 
 
    int scan_n, order[4];
    int scan_n, order[4];
@@ -2862,9 +2862,8 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
             if (stbi__get8(z->s) != tag[i])
             if (stbi__get8(z->s) != tag[i])
                ok = 0;
                ok = 0;
          L -= 5;
          L -= 5;
-         if (ok) {
+         if (ok)
             z->jfif = 1;
             z->jfif = 1;
-         }
       } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment
       } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment
          static const unsigned char tag[6] = {'A','d','o','b','e','\0'};
          static const unsigned char tag[6] = {'A','d','o','b','e','\0'};
          int ok = 1;
          int ok = 1;
@@ -2877,7 +2876,7 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
             stbi__get8(z->s); // version
             stbi__get8(z->s); // version
             stbi__get16be(z->s); // flags0
             stbi__get16be(z->s); // flags0
             stbi__get16be(z->s); // flags1
             stbi__get16be(z->s); // flags1
-            z->app14 = stbi__get8(z->s); // color transform
+            z->app14_color_transform = stbi__get8(z->s); // color transform
             L -= 6;
             L -= 6;
          }
          }
       }
       }
@@ -3047,7 +3046,7 @@ static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)
 {
 {
    int m;
    int m;
    z->jfif = 0;
    z->jfif = 0;
-   z->app14 = -1;
+   z->app14_color_transform = -1; // valid values are 0,1,2
    z->marker = STBI__MARKER_none; // initialize cached marker to empty
    z->marker = STBI__MARKER_none; // initialize cached marker to empty
    m = stbi__get_marker(z);
    m = stbi__get_marker(z);
    if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG");
    if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG");
@@ -3531,7 +3530,7 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp
    // determine actual number of components to generate
    // determine actual number of components to generate
    n = req_comp ? req_comp : z->s->img_n;
    n = req_comp ? req_comp : z->s->img_n;
 
 
-   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14 == 0 && !z->jfif));
+   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));
 
 
    if (z->s->img_n == 3 && n < 3 && !is_rgb)
    if (z->s->img_n == 3 && n < 3 && !is_rgb)
       decode_n = 1;
       decode_n = 1;