• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/third_party/libopenjpeg20/j2k.c b/third_party/libopenjpeg20/j2k.c
2index c5f9dd53e..1869833f7 100644
3--- a/third_party/libopenjpeg20/j2k.c
4+++ b/third_party/libopenjpeg20/j2k.c
5@@ -2311,10 +2311,8 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
6     }
7
8     /* Compute the number of tiles */
9-    l_cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->x1 - l_cp->tx0),
10-                                           (OPJ_INT32)l_cp->tdx);
11-    l_cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->y1 - l_cp->ty0),
12-                                           (OPJ_INT32)l_cp->tdy);
13+    l_cp->tw = opj_uint_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
14+    l_cp->th = opj_uint_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
15
16     /* Check that the number of tiles is valid */
17     if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
18@@ -2331,12 +2329,10 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
19             (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
20         p_j2k->m_specific_param.m_decoder.m_start_tile_y =
21             (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
22-        p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv((
23-                    OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0),
24-                (OPJ_INT32)l_cp->tdx);
25-        p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv((
26-                    OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0),
27-                (OPJ_INT32)l_cp->tdy);
28+        p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_uint_ceildiv(
29+            p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0, l_cp->tdx);
30+        p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_uint_ceildiv(
31+            p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0, l_cp->tdy);
32     } else {
33         p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
34         p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
35@@ -6922,10 +6918,8 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
36     */
37
38     if (parameters->tile_size_on) {
39-        cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp->tx0),
40-                                             (OPJ_INT32)cp->tdx);
41-        cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0),
42-                                             (OPJ_INT32)cp->tdy);
43+        cp->tw = opj_uint_ceildiv(image->x1 - cp->tx0, cp->tdx);
44+        cp->th = opj_uint_ceildiv(image->y1 - cp->ty0, cp->tdy);
45     } else {
46         cp->tdx = image->x1 - cp->tx0;
47         cp->tdy = image->y1 - cp->ty0;
48@@ -9237,10 +9231,8 @@ OPJ_BOOL opj_j2k_set_decode_area(opj_j2k_t *p_j2k,
49     for (it_comp = 0; it_comp < p_image->numcomps; ++it_comp) {
50         OPJ_INT32 l_h, l_w;
51
52-        l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0,
53-                         (OPJ_INT32)l_img_comp->dx);
54-        l_img_comp->y0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->y0,
55-                         (OPJ_INT32)l_img_comp->dy);
56+        l_img_comp->x0 = opj_uint_ceildiv(p_image->x0, l_img_comp->dx);
57+        l_img_comp->y0 = opj_uint_ceildiv(p_image->y0, l_img_comp->dy);
58         l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
59         l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
60
61@@ -10848,10 +10840,8 @@ OPJ_BOOL opj_j2k_get_tile(opj_j2k_t *p_j2k,
62
63         l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor;
64
65-        l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0,
66-                         (OPJ_INT32)l_img_comp->dx);
67-        l_img_comp->y0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->y0,
68-                         (OPJ_INT32)l_img_comp->dy);
69+        l_img_comp->x0 = opj_uint_ceildiv(p_image->x0, l_img_comp->dx);
70+        l_img_comp->y0 = opj_uint_ceildiv(p_image->y0, l_img_comp->dy);
71         l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
72         l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
73
74@@ -11161,10 +11151,8 @@ static void opj_get_tile_dimensions(opj_image_t * l_image,
75
76     *l_width  = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
77     *l_height = (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0);
78-    *l_offset_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->x0,
79-                  (OPJ_INT32)l_img_comp->dx);
80-    *l_offset_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->y0,
81-                  (OPJ_INT32)l_img_comp->dy);
82+    *l_offset_x = opj_uint_ceildiv(l_image->x0, l_img_comp->dx);
83+    *l_offset_y = opj_uint_ceildiv(l_image->y0, l_img_comp->dy);
84     *l_image_width = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->x1 -
85                      (OPJ_INT32)l_image->x0, (OPJ_INT32)l_img_comp->dx);
86     *l_stride = *l_image_width - *l_width;
87