summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormayeut <mayeut@users.noreply.github.com>2015-09-08 22:33:07 +0200
committermayeut <mayeut@users.noreply.github.com>2015-09-08 22:33:07 +0200
commit66d890bf225a4edc49658803b4aa6a65031479e4 (patch)
treea52c7bb60ab709ff4e7deff1e1b159bea5ddec30 /src/lib
parent0a4ac0852afe7a43e52c48dc33bae126171f5f1e (diff)
parente71247bb90085155559fafaf088d4e573add7156 (diff)
Merge remote-tracking branch 'uclouvain/master' into coc-qcc
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/CMakeLists.txt4
-rw-r--r--src/lib/openjp2/j2k.c8
-rw-r--r--src/lib/openjp2/jp2.c171
-rw-r--r--src/lib/openjp2/opj_intmath.h20
-rw-r--r--src/lib/openjp2/tcd.c8
-rw-r--r--src/lib/openjp3d/CMakeLists.txt4
-rw-r--r--src/lib/openjpip/CMakeLists.txt4
-rw-r--r--src/lib/openjpwl/CMakeLists.txt4
-rw-r--r--src/lib/openmj2/CMakeLists.txt4
9 files changed, 149 insertions, 78 deletions
diff --git a/src/lib/openjp2/CMakeLists.txt b/src/lib/openjp2/CMakeLists.txt
index 4a865e5d..3129bf53 100644
--- a/src/lib/openjp2/CMakeLists.txt
+++ b/src/lib/openjp2/CMakeLists.txt
@@ -85,7 +85,9 @@ if(UNIX)
target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
endif()
set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
# Install library
install(TARGETS ${OPENJPEG_LIBRARY_NAME}
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 301bdfe6..128a62e0 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -5614,8 +5614,7 @@ static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k,
assert(p_stream != 00);
l_tcp =&(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
- l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
+
l_mco_size = 5 + l_tcp->m_nb_mcc_records;
if (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
@@ -5630,6 +5629,8 @@ static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k,
p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size;
}
+ l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
opj_write_bytes(l_current_data,J2K_MS_MCO,2); /* MCO */
l_current_data += 2;
@@ -5641,10 +5642,9 @@ static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k,
++l_current_data;
l_mcc_record = l_tcp->m_mcc_records;
- for (i=0;i<l_tcp->m_nb_mcc_records;++i) {
+ for (i=0;i<l_tcp->m_nb_mcc_records;++i) {
opj_write_bytes(l_current_data,l_mcc_record->m_index,1);/* Imco -> use the mcc indicated by 1*/
++l_current_data;
-
++l_mcc_record;
}
diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c
index 96599a70..af692d59 100644
--- a/src/lib/openjp2/jp2.c
+++ b/src/lib/openjp2/jp2.c
@@ -849,6 +849,8 @@ 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 index %d (>= %d).\n", info[i].cn, nr_channels);
return OPJ_FALSE;
}
+ if (info[i].asoc == 65535U) continue;
+
if (info[i].asoc > 0 && (OPJ_UINT32)(info[i].asoc - 1) >= nr_channels) {
opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", info[i].asoc - 1, nr_channels);
return OPJ_FALSE;
@@ -1313,15 +1315,15 @@ static OPJ_BOOL opj_jp2_read_cdef( opj_jp2_t * jp2,
}
cdef_info = (opj_jp2_cdef_info_t*) opj_malloc(l_value * sizeof(opj_jp2_cdef_info_t));
- if (!cdef_info)
- return OPJ_FALSE;
+ if (!cdef_info)
+ return OPJ_FALSE;
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
- if(!jp2->color.jp2_cdef)
- {
- opj_free(cdef_info);
- return OPJ_FALSE;
- }
+ if(!jp2->color.jp2_cdef)
+ {
+ opj_free(cdef_info);
+ return OPJ_FALSE;
+ }
jp2->color.jp2_cdef->info = cdef_info;
jp2->color.jp2_cdef->n = (OPJ_UINT16) l_value;
@@ -1383,14 +1385,59 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
opj_event_msg(p_manager, EVT_ERROR, "Bad COLR header box (bad size: %d)\n", p_colr_header_size);
return OPJ_FALSE;
}
- if (p_colr_header_size > 7) {
+ if ((p_colr_header_size > 7) && (jp2->enumcs != 14)) { /* handled below for CIELab) */
/* testcase Altona_Technical_v20_x4.pdf */
opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (bad size: %d)\n", p_colr_header_size);
}
opj_read_bytes(p_colr_header_data,&jp2->enumcs ,4); /* EnumCS */
-
- jp2->color.jp2_has_colr = 1;
+
+ p_colr_header_data += 4;
+
+ if(jp2->enumcs == 14)/* CIELab */
+ {
+ OPJ_UINT32 *cielab;
+ OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
+
+ cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
+ cielab[0] = 14; /* enumcs */
+
+ /* default values */
+ rl = ra = rb = ol = oa = ob = 0;
+ il = 0x00443530; /* D50 */
+ cielab[1] = 0x44454600;/* DEF */
+
+ if(p_colr_header_size == 35)
+ {
+ opj_read_bytes(p_colr_header_data, &rl, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &ol, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &ra, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &oa, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &rb, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &ob, 4);
+ p_colr_header_data += 4;
+ opj_read_bytes(p_colr_header_data, &il, 4);
+ p_colr_header_data += 4;
+
+ cielab[1] = 0;
+ }
+ else if(p_colr_header_size != 7)
+ {
+ opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (CIELab, bad size: %d)\n", p_colr_header_size);
+ }
+ cielab[2] = rl; cielab[4] = ra; cielab[6] = rb;
+ cielab[3] = ol; cielab[5] = oa; cielab[7] = ob;
+ cielab[8] = il;
+
+ jp2->color.icc_profile_buf = (OPJ_BYTE*)cielab;
+ jp2->color.icc_profile_len = 0;
+ }
+ jp2->color.jp2_has_colr = 1;
}
else if (jp2->meth == 2) {
/* ICC profile */
@@ -1399,11 +1446,11 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
jp2->color.icc_profile_len = (OPJ_UINT32)icc_len;
jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_calloc(1,(size_t)icc_len);
- if (!jp2->color.icc_profile_buf)
- {
- jp2->color.icc_profile_len = 0;
- return OPJ_FALSE;
- }
+ if (!jp2->color.icc_profile_buf)
+ {
+ jp2->color.icc_profile_len = 0;
+ return OPJ_FALSE;
+ }
for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value)
{
@@ -1412,16 +1459,16 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
jp2->color.icc_profile_buf[it_icc_value] = (OPJ_BYTE) l_value;
}
- jp2->color.jp2_has_colr = 1;
+ jp2->color.jp2_has_colr = 1;
}
else if (jp2->meth > 2)
- {
- /* ISO/IEC 15444-1:2004 (E), Table I.9 Legal METH values:
- conforming JP2 reader shall ignore the entire Colour Specification box.*/
- opj_event_msg(p_manager, EVT_INFO, "COLR BOX meth value is not a regular value (%d), "
- "so we will ignore the entire Colour Specification box. \n", jp2->meth);
- }
- return OPJ_TRUE;
+ {
+ /* ISO/IEC 15444-1:2004 (E), Table I.9 Legal METH values:
+ conforming JP2 reader shall ignore the entire Colour Specification box.*/
+ opj_event_msg(p_manager, EVT_INFO, "COLR BOX meth value is not a regular value (%d), "
+ "so we will ignore the entire Colour Specification box. \n", jp2->meth);
+ }
+ return OPJ_TRUE;
}
OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
@@ -1438,42 +1485,44 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
return OPJ_FALSE;
}
- if (!jp2->ignore_pclr_cmap_cdef){
- if (!opj_jp2_check_color(p_image, &(jp2->color), p_manager)) {
- return OPJ_FALSE;
- }
-
- /* Set Image Color Space */
- if (jp2->enumcs == 16)
- p_image->color_space = OPJ_CLRSPC_SRGB;
- else if (jp2->enumcs == 17)
- p_image->color_space = OPJ_CLRSPC_GRAY;
- else if (jp2->enumcs == 18)
- p_image->color_space = OPJ_CLRSPC_SYCC;
- else if (jp2->enumcs == 24)
- p_image->color_space = OPJ_CLRSPC_EYCC;
- else
- p_image->color_space = OPJ_CLRSPC_UNKNOWN;
-
- if(jp2->color.jp2_pclr) {
- /* Part 1, I.5.3.4: Either both or none : */
- if( !jp2->color.jp2_pclr->cmap)
- opj_jp2_free_pclr(&(jp2->color));
- else
- opj_jp2_apply_pclr(p_image, &(jp2->color));
- }
-
- /* Apply the color space if needed */
- if(jp2->color.jp2_cdef) {
- opj_jp2_apply_cdef(p_image, &(jp2->color), p_manager);
- }
-
- if(jp2->color.icc_profile_buf) {
- p_image->icc_profile_buf = jp2->color.icc_profile_buf;
- p_image->icc_profile_len = jp2->color.icc_profile_len;
- jp2->color.icc_profile_buf = NULL;
- }
- }
+ if (!jp2->ignore_pclr_cmap_cdef){
+ if (!opj_jp2_check_color(p_image, &(jp2->color), p_manager)) {
+ return OPJ_FALSE;
+ }
+
+ /* Set Image Color Space */
+ if (jp2->enumcs == 16)
+ p_image->color_space = OPJ_CLRSPC_SRGB;
+ else if (jp2->enumcs == 17)
+ p_image->color_space = OPJ_CLRSPC_GRAY;
+ else if (jp2->enumcs == 18)
+ p_image->color_space = OPJ_CLRSPC_SYCC;
+ else if (jp2->enumcs == 24)
+ p_image->color_space = OPJ_CLRSPC_EYCC;
+ else if (jp2->enumcs == 12)
+ p_image->color_space = OPJ_CLRSPC_CMYK;
+ else
+ p_image->color_space = OPJ_CLRSPC_UNKNOWN;
+
+ if(jp2->color.jp2_pclr) {
+ /* Part 1, I.5.3.4: Either both or none : */
+ if( !jp2->color.jp2_pclr->cmap)
+ opj_jp2_free_pclr(&(jp2->color));
+ else
+ opj_jp2_apply_pclr(p_image, &(jp2->color));
+ }
+
+ /* Apply the color space if needed */
+ if(jp2->color.jp2_cdef) {
+ opj_jp2_apply_cdef(p_image, &(jp2->color), p_manager);
+ }
+
+ if(jp2->color.icc_profile_buf) {
+ p_image->icc_profile_buf = jp2->color.icc_profile_buf;
+ p_image->icc_profile_len = jp2->color.icc_profile_len;
+ jp2->color.icc_profile_buf = NULL;
+ }
+ }
return OPJ_TRUE;
}
@@ -2824,6 +2873,10 @@ OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2,
p_image->color_space = OPJ_CLRSPC_GRAY;
else if (p_jp2->enumcs == 18)
p_image->color_space = OPJ_CLRSPC_SYCC;
+ else if (p_jp2->enumcs == 24)
+ p_image->color_space = OPJ_CLRSPC_EYCC;
+ else if (p_jp2->enumcs == 12)
+ p_image->color_space = OPJ_CLRSPC_CMYK;
else
p_image->color_space = OPJ_CLRSPC_UNKNOWN;
diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h
index f39f6843..3f7934c4 100644
--- a/src/lib/openjp2/opj_intmath.h
+++ b/src/lib/openjp2/opj_intmath.h
@@ -135,7 +135,15 @@ Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
- return (OPJ_INT32)((a + (OPJ_INT64)(1 << b) - 1) >> b);
+ return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
+}
+
+/**
+ Divide a 64bits integer by a power of 2 and round upwards
+ @return Returns a divided by 2^b
+ */
+static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) {
+ return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
}
/**
@@ -143,7 +151,7 @@ static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
@return Returns a divided by 2^b
*/
static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) {
- return (OPJ_UINT32)((a + (OPJ_UINT64)(1U << b) - 1U) >> b);
+ return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b);
}
/**
@@ -184,8 +192,8 @@ Multiply two fixed-precision rational numbers.
@return Returns a * b
*/
static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+ OPJ_INT64 temp = __emul(a, b);
#else
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
#endif
@@ -196,8 +204,8 @@ static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
}
static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+ OPJ_INT64 temp = __emul(a, b);
#else
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
#endif
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c
index 973ef1e7..8f1c9410 100644
--- a/src/lib/openjp2/tcd.c
+++ b/src/lib/openjp2/tcd.c
@@ -862,10 +862,10 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
/* y0b = 1 if bandno = 2 or 3 */
l_y0b = (OPJ_INT32)((l_band->bandno)>>1);
/* l_band border (global) */
- l_band->x0 = opj_int_ceildivpow2(l_tilec->x0 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1));
- l_band->y0 = opj_int_ceildivpow2(l_tilec->y0 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1));
- l_band->x1 = opj_int_ceildivpow2(l_tilec->x1 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1));
- l_band->y1 = opj_int_ceildivpow2(l_tilec->y1 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1));
+ l_band->x0 = opj_int64_ceildivpow2(l_tilec->x0 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+ l_band->y0 = opj_int64_ceildivpow2(l_tilec->y0 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+ l_band->x1 = opj_int64_ceildivpow2(l_tilec->x1 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+ l_band->y1 = opj_int64_ceildivpow2(l_tilec->y1 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
}
/** avoid an if with storing function pointer */
diff --git a/src/lib/openjp3d/CMakeLists.txt b/src/lib/openjp3d/CMakeLists.txt
index df7c9be2..0bbafea3 100644
--- a/src/lib/openjp3d/CMakeLists.txt
+++ b/src/lib/openjp3d/CMakeLists.txt
@@ -27,7 +27,9 @@ if(UNIX)
target_link_libraries(${OPENJP3D_LIBRARY_NAME} m)
endif()
set_target_properties(${OPENJP3D_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-target_compile_options(${OPENJP3D_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ target_compile_options(${OPENJP3D_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
# Install library
install(TARGETS ${OPENJP3D_LIBRARY_NAME}
diff --git a/src/lib/openjpip/CMakeLists.txt b/src/lib/openjpip/CMakeLists.txt
index 28e8259d..858a1095 100644
--- a/src/lib/openjpip/CMakeLists.txt
+++ b/src/lib/openjpip/CMakeLists.txt
@@ -61,7 +61,9 @@ endif()
add_library(openjpip ${OPENJPIP_SRCS} ${LOCAL_SRCS})
set_target_properties(openjpip
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-target_compile_options(openjpip PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ target_compile_options(openjpip PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
target_link_libraries(openjpip ${OPENJPEG_LIBRARY_NAME})
if(WIN32)
# add Winsock on windows+mingw
diff --git a/src/lib/openjpwl/CMakeLists.txt b/src/lib/openjpwl/CMakeLists.txt
index 00773db1..9e2ace75 100644
--- a/src/lib/openjpwl/CMakeLists.txt
+++ b/src/lib/openjpwl/CMakeLists.txt
@@ -51,7 +51,9 @@ if(UNIX)
endif()
set_target_properties(openjpwl
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-target_compile_options(openjpwl PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ target_compile_options(openjpwl PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
# Install library
install(TARGETS openjpwl
diff --git a/src/lib/openmj2/CMakeLists.txt b/src/lib/openmj2/CMakeLists.txt
index 0656b252..dbb7e7ce 100644
--- a/src/lib/openmj2/CMakeLists.txt
+++ b/src/lib/openmj2/CMakeLists.txt
@@ -46,7 +46,9 @@ if(UNIX)
target_link_libraries(${OPENMJ2_LIBRARY_NAME} m)
endif()
set_target_properties(${OPENMJ2_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-target_compile_options(${OPENMJ2_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ target_compile_options(${OPENMJ2_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
# Install library
install(TARGETS ${OPENMJ2_LIBRARY_NAME}