summaryrefslogtreecommitdiff
path: root/third_party/libopenjpeg20/0005-jp2_apply_pclr.patch
blob: c852bd057d362b9a0243039390610bc9896d6d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff --git a/third_party/libopenjpeg20/jp2.c b/third_party/libopenjpeg20/jp2.c
index 882f1b649..3ace09654 100644
--- a/third_party/libopenjpeg20/jp2.c
+++ b/third_party/libopenjpeg20/jp2.c
@@ -969,7 +969,7 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
                 opj_event_msg(p_manager, EVT_ERROR,
                               "Invalid component/palette index for direct mapping %d.\n", pcol);
                 is_sane = OPJ_FALSE;
-            } else if (pcol_usage[pcol] && cmap[i].mtyp == 1) {
+            } else if (pcol_usage[pcol] && cmap[i].mtyp != 0) {
                 opj_event_msg(p_manager, EVT_ERROR, "Component %d is mapped twice.\n", pcol);
                 is_sane = OPJ_FALSE;
             } else if (cmap[i].mtyp == 0 && cmap[i].pcol != 0) {
@@ -1064,8 +1064,8 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
             assert(pcol == 0);
             new_comps[i] = old_comps[cmp];
         } else {
-            assert(i == pcol);
-            new_comps[pcol] = old_comps[cmp];
+            assert( i == pcol ); // probably wrong?
+            new_comps[i] = old_comps[cmp];
         }
 
         /* Palette mapping: */
@@ -1093,19 +1093,19 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
         pcol = cmap[i].pcol;
         src = old_comps[cmp].data;
         assert(src); /* verified above */
-        max = new_comps[pcol].w * new_comps[pcol].h;
+        max = new_comps[i].w * new_comps[i].h;
 
         /* Direct use: */
         if (cmap[i].mtyp == 0) {
-            assert(cmp == 0);
+            assert( cmp == 0 ); // probably wrong.
             dst = new_comps[i].data;
             assert(dst);
             for (j = 0; j < max; ++j) {
                 dst[j] = src[j];
             }
         } else {
-            assert(i == pcol);
-            dst = new_comps[pcol].data;
+            assert( i == pcol ); // probably wrong?
+            dst = new_comps[i].data;
             assert(dst);
             for (j = 0; j < max; ++j) {
                 /* The index */