Enhance the support of endianess with cmake and inside the code (credit to Winfried)
authorMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 21 Sep 2011 10:01:54 +0000 (10:01 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 21 Sep 2011 10:01:54 +0000 (10:01 +0000)
CHANGES
CMakeLists.txt
applications/codec/convert.c
applications/codec/image_to_j2k.c
applications/codec/j2k_dump.c
applications/codec/j2k_to_image.c
libopenjpeg/cio.h
opj_configh.cmake.in

diff --git a/CHANGES b/CHANGES
index 031b2270de1a1e48a4143bc0fae0ebcb7115da8f..13040582799eb600807a13e40d63e9389cf6a6ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+September 21, 2011
++ [mickael] Enhance the support of endianess with cmake and inside the code (credit to Winfried) 
+
 September 20, 2011
 * [mickael] WIP: fixed build issues with MJ2 option ON
 * [mickael] WIP: fixed build issues with JPWL option ON
index 1af3a073352dd3af0980c759f0db1a77e1751f8b..bc048b2e2bfb63d0d3d21c27773c6f7c0ed088cb 100644 (file)
@@ -39,12 +39,13 @@ SET(OPENJPEG_LIBRARY_PROPERTIES
   SOVERSION "${OPENJPEG_VERSION_MAJOR}"
 )
 
-
+# --------------------------------------------------------------------------
 # Path to additional CMake modules
 SET(CMAKE_MODULE_PATH
     ${CMAKE_SOURCE_DIR}/CMake
     ${CMAKE_MODULE_PATH})
 
+# --------------------------------------------------------------------------
 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
 # warnings
 IF(WIN32)
@@ -108,6 +109,7 @@ ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
 
 #-----------------------------------------------------------------------------
 # Test for some required system information.
+# For example this macro test the endianness (CMAKE_WORDS_BIGENDIAN)
 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
 
 #-----------------------------------------------------------------------------
index fae8b1311fa7172af23115c415c160aa06d2edf6..d9510b14d00c061c0d33238a14efd186a8ff93e6 100644 (file)
@@ -94,7 +94,7 @@ struct tga_header
 
 static unsigned short get_ushort(unsigned short val) {
 
-#ifdef ORDER_BIGENDIAN
+#ifdef OPJ_BIG_ENDIAN
     return( ((val & 0xff) << 8) + (val >> 8) );
 #else
     return( val );
index 4ab7445b3089e460d3352b8e7d387901ec7bf308..feb9ce891ef323b781c10d5d02664762f903cb6f 100644 (file)
@@ -29,6 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include "opj_config.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -49,7 +50,6 @@
 #define _strnicmp strncasecmp
 #endif /* _WIN32 */
 
-#include "opj_config.h"
 #include "openjpeg.h"
 #include "opj_getopt.h"
 #include "convert.h"
index b33d24cffc4dad45ca796662b74b2cd644967adc..4ee93e8a6a13a4e5a32fc9722d49ef6cdaa1f962 100644 (file)
@@ -24,6 +24,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include "opj_config.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -44,7 +45,6 @@
 #define _strnicmp strncasecmp
 #endif /* _WIN32 */
 
-#include "opj_config.h"
 #include "openjpeg.h"
 #include "j2k.h"
 #include "jp2.h"
index 85bca04ccb8e65d0d66652359ce047372c463248..a20ac69b9b087711bb80a51e3a12aef00d051b41 100644 (file)
@@ -29,6 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include "opj_config.h"
 
 #include <stdio.h>
 #include <string.h>
index ed95d5cd746b805629a9525ba577d34bdef74bd5..d98aa8610d8704cbedbce014f9ec83bf4b841476 100644 (file)
@@ -89,27 +89,19 @@ void cio_skip(opj_cio_t *cio, int n);
 /* ----------------------------------------------------------------------- */
 
 #if defined(OPJ_BIG_ENDIAN)
-       #if !defined(OPJ_LITTLE_ENDIAN)
-                       #define opj_write_bytes         opj_write_bytes_BE
-                       #define opj_read_bytes          opj_read_bytes_BE
-                       #define opj_write_double        opj_write_double_BE
-                       #define opj_read_double         opj_read_double_BE
-                       #define opj_write_float         opj_write_float_BE
-                       #define opj_read_float          opj_read_float_BE
-       #else
-                       #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
-       #endif
+       #define opj_write_bytes         opj_write_bytes_BE
+       #define opj_read_bytes          opj_read_bytes_BE
+       #define opj_write_double        opj_write_double_BE
+       #define opj_read_double         opj_read_double_BE
+       #define opj_write_float         opj_write_float_BE
+       #define opj_read_float          opj_read_float_BE
 #else
-       #if defined(OPJ_LITTLE_ENDIAN)
-                       #define opj_write_bytes         opj_write_bytes_LE
-                       #define opj_read_bytes          opj_read_bytes_LE
-                       #define opj_write_double        opj_write_double_LE
-                       #define opj_read_double         opj_read_double_LE
-                       #define opj_write_float         opj_write_float_LE
-                       #define opj_read_float          opj_read_float_LE
-       #else
-               #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not none."
-       #endif
+       #define opj_write_bytes         opj_write_bytes_LE
+       #define opj_read_bytes          opj_read_bytes_LE
+       #define opj_write_double        opj_write_double_LE
+       #define opj_read_double         opj_read_double_LE
+       #define opj_write_float         opj_write_float_LE
+       #define opj_read_float          opj_read_float_LE
 #endif
 
 
index 6da59ddde7e9c39271dca268647dd70eeaf92f5f..55977fa8220bf405643f4f40bcdbbaa4962ead14 100644 (file)
@@ -20,9 +20,4 @@
 #cmakedefine HAVE_LCMS1_H @HAVE_LCMS1_H@
 #cmakedefine HAVE_LCMS2_H @HAVE_LCMS2_H@
 
-#cmakedefine CMAKE_WORDS_BIGENDIAN
-#ifdef CMAKE_WORDS_BIGENDIAN
-        #define OPJ_BIG_ENDIAN 
-#else
-        #define OPJ_LITTLE_ENDIAN 
-#endif
+#cmakedefine OPJ_BIG_ENDIAN @CMAKE_WORDS_BIGENDIAN@
\ No newline at end of file