[mingw-openjpeg: 2/10] Initial import (#537897).
Kalev Lember
kalev at fedoraproject.org
Wed Mar 7 16:13:43 UTC 2012
commit 31502be46f137fa512fecec795038831a2f58d5c
Author: Adam Goode <agoode at fedoraproject.org>
Date: Mon Dec 7 00:28:53 2009 +0000
Initial import (#537897).
.cvsignore | 1 +
import.log | 1 +
mingw32-openjpeg.spec | 129 ++++++++++++++
openjpeg-1.3-libm.patch | 66 +++++++
openjpeg-1.3-mingw32-cmake.patch | 23 +++
openjpeg-1.3-reverse-bogus-aligned-malloc.patch | 21 +++
openjpeg-1.3-tcd_init_encode-alloc-fix.patch | 14 ++
openjpeg-20070717svn-codec-libtiff.patch | 12 ++
openjpeg-20070717svn-mqc-optimize.patch | 31 ++++
openjpeg-20070719svn-mqc-more-optimize.patch | 100 +++++++++++
...070719svn-t1-t1_dec_sigpass_step-optimize.patch | 28 +++
...eg-20070719svn-t1-x86_64-flags-branchless.patch | 29 +++
openjpeg-20070821svn-t1-flags-stride.patch | 182 ++++++++++++++++++++
openjpeg-20070821svn-t1-remove-macro.patch | 171 ++++++++++++++++++
openjpeg-20070821svn-t1-updateflags-x86_64.patch | 84 +++++++++
openjpeg-svn468-mj2-noscroll.patch | 42 +++++
openjpeg-svn470-t1-flags-mmx.patch | 145 ++++++++++++++++
openjpeg-svn480-cmake.patch | 45 +++++
openjpeg-svn480-use-stdbool.patch | 12 ++
sources | 1 +
20 files changed, 1137 insertions(+), 0 deletions(-)
---
diff --git a/.cvsignore b/.cvsignore
index e69de29..f8b4a78 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -0,0 +1 @@
+openjpeg_v1_3.tar.gz
diff --git a/import.log b/import.log
new file mode 100644
index 0000000..282eeff
--- /dev/null
+++ b/import.log
@@ -0,0 +1 @@
+mingw32-openjpeg-1_3-5_fc13:HEAD:mingw32-openjpeg-1.3-5.fc13.src.rpm:1260145704
diff --git a/mingw32-openjpeg.spec b/mingw32-openjpeg.spec
new file mode 100644
index 0000000..f5531d6
--- /dev/null
+++ b/mingw32-openjpeg.spec
@@ -0,0 +1,129 @@
+%global __strip %{_mingw32_strip}
+%global __objdump %{_mingw32_objdump}
+%global _use_internal_dependency_generator 0
+%global __find_requires %{_mingw32_findrequires}
+%global __find_provides %{_mingw32_findprovides}
+%define __debug_install_post %{_mingw32_debug_install_post}
+
+# reset patch fuzz, rebasing patches will require delicate surgery -- Rex
+%global _default_patch_fuzz 2
+
+Name: mingw32-openjpeg
+Version: 1.3
+Release: 5%{?dist}
+Summary: MinGW Windows openjpeg library
+
+Group: Development/Libraries
+License: BSD
+URL: http://www.openjpeg.org/
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+
+BuildRequires: cmake
+
+BuildRequires: mingw32-filesystem >= 52
+BuildRequires: mingw32-gcc
+BuildRequires: mingw32-binutils
+BuildRequires: mingw32-libtiff
+
+Source0: http://www.openjpeg.org/openjpeg_v1_3.tar.gz
+
+# Patches from native Fedora package:
+Patch1: openjpeg-20070717svn-codec-libtiff.patch
+Patch4: openjpeg-svn480-cmake.patch
+Patch5: openjpeg-svn480-use-stdbool.patch
+Patch6: openjpeg-1.3-tcd_init_encode-alloc-fix.patch
+Patch7: openjpeg-1.3-reverse-bogus-aligned-malloc.patch
+Patch44: openjpeg-svn468-mj2-noscroll.patch
+Patch21: openjpeg-20070717svn-mqc-optimize.patch
+Patch22: openjpeg-20070821svn-t1-remove-macro.patch
+Patch23: openjpeg-20070719svn-t1-x86_64-flags-branchless.patch
+Patch24: openjpeg-20070719svn-t1-t1_dec_sigpass_step-optimize.patch
+Patch25: openjpeg-20070821svn-t1-flags-stride.patch
+Patch26: openjpeg-20070821svn-t1-updateflags-x86_64.patch
+Patch27: openjpeg-svn470-t1-flags-mmx.patch
+Patch28: openjpeg-20070719svn-mqc-more-optimize.patch
+
+# libopenjpeg has undefined references, http://bugzilla.redhat.com/467661
+Patch50: openjpeg-1.3-libm.patch
+
+# Patches for MinGW:
+Patch1000: openjpeg-1.3-mingw32-cmake.patch
+
+
+%description
+%{_mingw32_description}
+
+
+%{_mingw32_debug_package}
+
+
+%prep
+%setup -q -n OpenJPEG_v1_3
+# Make sure we use system libraries
+rm -rf libs
+%patch1 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch44 -p1
+%patch22 -p1
+%patch23 -p1
+%patch25 -p1
+%patch26 -p1
+%patch27 -p1
+%patch24 -p1
+%patch21 -p1
+%patch28 -p1
+%patch50 -p1 -b .libm
+
+%patch1000 -p1
+
+# Fix permissions
+chmod a-x ChangeLog license.txt
+
+
+%build
+mkdir build
+pushd build
+export MINGW32_CFLAGS="%{_mingw32_cflags} -DWIN32"
+%{_mingw32_cmake} ..
+make %{?_smp_mflags}
+popd
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+pushd build
+make install DESTDIR=$RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
+mv $RPM_BUILD_ROOT%{_mingw32_libdir}/libopenjpeg.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
+popd
+
+# HACK: until pkg-config support lands, temporarily provide
+# openjpeg.h header in legacy location
+ln -s openjpeg/openjpeg.h $RPM_BUILD_ROOT%{_mingw32_includedir}/openjpeg.h
+
+
+%check
+# mostly pointless without test images, but it's a start -- Rex
+make test -C build
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root,-)
+%doc license.txt
+%{_mingw32_includedir}/openjpeg.h
+%{_mingw32_includedir}/openjpeg
+%{_mingw32_bindir}/libopenjpeg.dll
+%{_mingw32_libdir}/libopenjpeg.dll.a
+
+
+%changelog
+* Mon Nov 16 2009 Adam Goode <adam at spicenitz.org> - 1.3-5
+- Initial release, tracking Fedora native openjpeg-1.3-5
diff --git a/openjpeg-1.3-libm.patch b/openjpeg-1.3-libm.patch
new file mode 100644
index 0000000..0579f04
--- /dev/null
+++ b/openjpeg-1.3-libm.patch
@@ -0,0 +1,66 @@
+diff -up OpenJPEG_v1_3/codec/CMakeLists.txt.libm OpenJPEG_v1_3/codec/CMakeLists.txt
+--- OpenJPEG_v1_3/codec/CMakeLists.txt.libm 2007-11-27 06:38:52.000000000 -0600
++++ OpenJPEG_v1_3/codec/CMakeLists.txt 2009-06-19 09:20:59.473980422 -0500
+@@ -46,10 +46,6 @@ FOREACH(exe j2k_to_image image_to_j2k)
+ ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
+ # calling those exe without option will make them fail always:
+ SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
+- # On unix you need to link to the math library:
+- IF(UNIX)
+- TARGET_LINK_LIBRARIES(${exe} m)
+- ENDIF(UNIX)
+ # Install exe
+ INSTALL_TARGETS(/bin/ ${exe})
+ ENDFOREACH(exe)
+diff -up OpenJPEG_v1_3/libopenjpeg/CMakeLists.txt.libm OpenJPEG_v1_3/libopenjpeg/CMakeLists.txt
+--- OpenJPEG_v1_3/libopenjpeg/CMakeLists.txt.libm 2009-06-19 09:18:44.021229314 -0500
++++ OpenJPEG_v1_3/libopenjpeg/CMakeLists.txt 2009-06-19 09:18:44.074248015 -0500
+@@ -35,6 +35,11 @@ ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${O
+ SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME} PROPERTIES
+ ${OPENJPEG_LIBRARY_PROPERTIES})
+
++IF(UNIX)
++ TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} m)
++ TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} LINK_INTERFACE_LIBRARIES)
++ENDIF(UNIX)
++
+ # Install library
+ INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -up OpenJPEG_v1_3/mj2/CMakeLists.txt.libm OpenJPEG_v1_3/mj2/CMakeLists.txt
+--- OpenJPEG_v1_3/mj2/CMakeLists.txt.libm 2007-09-12 04:04:03.000000000 -0500
++++ OpenJPEG_v1_3/mj2/CMakeLists.txt 2009-06-19 09:18:44.074248015 -0500
+@@ -10,33 +10,21 @@ ADD_EXECUTABLE(frames_to_mj2
+ compat/getopt.c
+ mj2_convert.c mj2.c )
+ TARGET_LINK_LIBRARIES(frames_to_mj2 ${OPJ_PREFIX}openjpeg)
+-IF(UNIX)
+- TARGET_LINK_LIBRARIES(frames_to_mj2 m)
+-ENDIF(UNIX)
+
+ ADD_EXECUTABLE(mj2_to_frames
+ mj2_to_frames.c
+ compat/getopt.c mj2_convert.c mj2.c )
+ TARGET_LINK_LIBRARIES(mj2_to_frames ${OPJ_PREFIX}openjpeg)
+-IF(UNIX)
+- TARGET_LINK_LIBRARIES(mj2_to_frames m)
+-ENDIF(UNIX)
+
+ ADD_EXECUTABLE(extract_j2k_from_mj2
+ extract_j2k_from_mj2.c
+ mj2.c )
+ TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${OPJ_PREFIX}openjpeg)
+-IF(UNIX)
+- TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 m)
+-ENDIF(UNIX)
+
+ ADD_EXECUTABLE(wrap_j2k_in_mj2
+ wrap_j2k_in_mj2.c
+ mj2.c )
+ TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${OPJ_PREFIX}openjpeg)
+-IF(UNIX)
+- TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 m)
+-ENDIF(UNIX)
+
+ INSTALL(TARGETS frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
+ DESTINATION bin)
diff --git a/openjpeg-1.3-mingw32-cmake.patch b/openjpeg-1.3-mingw32-cmake.patch
new file mode 100644
index 0000000..65e53a6
--- /dev/null
+++ b/openjpeg-1.3-mingw32-cmake.patch
@@ -0,0 +1,23 @@
+diff -ur OpenJPEG_v1_3~/CMakeLists.txt OpenJPEG_v1_3/CMakeLists.txt
+--- OpenJPEG_v1_3~/CMakeLists.txt 2009-06-03 09:40:53.000000000 -0400
++++ OpenJPEG_v1_3/CMakeLists.txt 2009-06-03 09:41:28.000000000 -0400
+@@ -67,19 +67,10 @@
+ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
+ SUBDIRS(
+ libopenjpeg
+- mj2
+ # cmake 2.4.5 has poor java support
+ #j2kviewer/src
+ )
+
+-IF(NOT UNIX)
+-SUBDIRS(
+- jpwl
+- jp3d
+- indexer_JPIP
+- )
+-ENDIF(NOT UNIX)
+-
+ #-----------------------------------------------------------------------------
+ # Build example only if requested
+ IF(BUILD_EXAMPLES)
diff --git a/openjpeg-1.3-reverse-bogus-aligned-malloc.patch b/openjpeg-1.3-reverse-bogus-aligned-malloc.patch
new file mode 100644
index 0000000..80269cf
--- /dev/null
+++ b/openjpeg-1.3-reverse-bogus-aligned-malloc.patch
@@ -0,0 +1,21 @@
+--- OpenJPEG_v1_3/libopenjpeg/opj_malloc.h 2007-12-21 04:19:01.000000000 -0600
++++ trunk/libopenjpeg/opj_malloc.h 2007-10-18 07:26:11.000000000 -0500
+@@ -75,9 +75,6 @@
+ #else /* Not WIN32 */
+ #if defined(__sun)
+ #define HAVE_MEMALIGN
+- #elif defined(__GNUC__)
+- #define HAVE_MEMALIGN
+- #include <malloc.h>
+ /* Linux x86_64 and OSX always align allocations to 16 bytes */
+ #elif !defined(__amd64__) && !defined(__APPLE__)
+ /* FIXME: Yes, this is a big assumption */
+@@ -85,8 +82,6 @@
+ #endif
+ #endif
+
+-
+-
+ #define opj_aligned_malloc(size) malloc(size)
+ #define opj_aligned_free(m) free(m)
+
diff --git a/openjpeg-1.3-tcd_init_encode-alloc-fix.patch b/openjpeg-1.3-tcd_init_encode-alloc-fix.patch
new file mode 100644
index 0000000..f6d7624
--- /dev/null
+++ b/openjpeg-1.3-tcd_init_encode-alloc-fix.patch
@@ -0,0 +1,14 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/tcd.c OpenJPEG.patched/libopenjpeg/tcd.c
+--- OpenJPEG.orig/libopenjpeg/tcd.c 2007-12-19 06:28:40.000000000 -0600
++++ OpenJPEG.patched/libopenjpeg/tcd.c 2007-12-27 21:58:57.000000000 -0600
+@@ -584,7 +584,9 @@
+ cblk->y0 = int_max(cblkystart, prc->y0);
+ cblk->x1 = int_min(cblkxend, prc->x1);
+ cblk->y1 = int_min(cblkyend, prc->y1);
+- cblk->data = (unsigned char*) opj_calloc(8192, sizeof(unsigned char));
++ cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
++ /* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
++ cblk->data += 2;
+ cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
+ cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
+ }
diff --git a/openjpeg-20070717svn-codec-libtiff.patch b/openjpeg-20070717svn-codec-libtiff.patch
new file mode 100644
index 0000000..7bf80df
--- /dev/null
+++ b/openjpeg-20070717svn-codec-libtiff.patch
@@ -0,0 +1,12 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/codec/convert.c OpenJPEG.patched/codec/convert.c
+--- OpenJPEG.orig/codec/convert.c 2007-07-17 11:19:41.000000000 -0500
++++ OpenJPEG.patched/codec/convert.c 2007-07-17 19:40:02.000000000 -0500
+@@ -33,7 +33,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include "openjpeg.h"
+-#include "../libs/libtiff/tiffio.h"
++#include "tiffio.h"
+ #include "convert.h"
+
+ /*
diff --git a/openjpeg-20070717svn-mqc-optimize.patch b/openjpeg-20070717svn-mqc-optimize.patch
new file mode 100644
index 0000000..cf25347
--- /dev/null
+++ b/openjpeg-20070717svn-mqc-optimize.patch
@@ -0,0 +1,31 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/mqc.c OpenJPEG.patched/libopenjpeg/mqc.c
+--- OpenJPEG.orig/libopenjpeg/mqc.c 2007-07-17 20:07:22.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/mqc.c 2007-07-17 20:07:44.000000000 -0500
+@@ -507,20 +507,20 @@
+
+ int mqc_decode(opj_mqc_t *mqc) {
+ int d;
+- mqc->a -= (*mqc->curctx)->qeval;
+- if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
++ unsigned int qeval = (*mqc->curctx)->qeval;
++ mqc->a -= qeval;
++ qeval <<= 16;
++ if (mqc->c < qeval) {
+ d = mqc_lpsexchange(mqc);
+- mqc_renormd(mqc);
+ } else {
+- mqc->c -= (*mqc->curctx)->qeval << 16;
++ mqc->c -= qeval;
+ if ((mqc->a & 0x8000) == 0) {
+ d = mqc_mpsexchange(mqc);
+- mqc_renormd(mqc);
+ } else {
+- d = (*mqc->curctx)->mps;
++ return (*mqc->curctx)->mps;
+ }
+ }
+-
++ mqc_renormd(mqc);
+ return d;
+ }
+
diff --git a/openjpeg-20070719svn-mqc-more-optimize.patch b/openjpeg-20070719svn-mqc-more-optimize.patch
new file mode 100644
index 0000000..cfb5c16
--- /dev/null
+++ b/openjpeg-20070719svn-mqc-more-optimize.patch
@@ -0,0 +1,100 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/mqc.c OpenJPEG.patched/libopenjpeg/mqc.c
+--- OpenJPEG.orig/libopenjpeg/mqc.c 2007-08-06 16:16:00.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/mqc.c 2007-08-06 19:07:28.000000000 -0500
+@@ -68,13 +68,13 @@
+ @param mqc MQC handle
+ @return
+ */
+-static int mqc_mpsexchange(opj_mqc_t *mqc);
++//static int mqc_mpsexchange(opj_mqc_t *mqc);
+ /**
+ FIXME: documentation ???
+ @param mqc MQC handle
+ @return
+ */
+-static int mqc_lpsexchange(opj_mqc_t *mqc);
++//static int mqc_lpsexchange(opj_mqc_t *mqc);
+ /**
+ Input a byte
+ @param mqc MQC handle
+@@ -271,33 +271,22 @@
+ }
+ }
+
++/*
+ static int mqc_mpsexchange(opj_mqc_t *mqc) {
+- int d;
+- if (mqc->a < (*mqc->curctx)->qeval) {
+- d = 1 - (*mqc->curctx)->mps;
+- *mqc->curctx = (*mqc->curctx)->nlps;
+- } else {
+- d = (*mqc->curctx)->mps;
+- *mqc->curctx = (*mqc->curctx)->nmps;
+- }
+-
+- return d;
++ int d = (*mqc->curctx)->mps;
++ int tmp = (mqc->a < (*mqc->curctx)->qeval);
++ *mqc->curctx = tmp ? (*mqc->curctx)->nlps : (*mqc->curctx)->nmps;
++ return tmp ^ d;
+ }
+
+ static int mqc_lpsexchange(opj_mqc_t *mqc) {
+- int d;
+- if (mqc->a < (*mqc->curctx)->qeval) {
+- mqc->a = (*mqc->curctx)->qeval;
+- d = (*mqc->curctx)->mps;
+- *mqc->curctx = (*mqc->curctx)->nmps;
+- } else {
+- mqc->a = (*mqc->curctx)->qeval;
+- d = 1 - (*mqc->curctx)->mps;
+- *mqc->curctx = (*mqc->curctx)->nlps;
+- }
+-
+- return d;
++ int d = (*mqc->curctx)->mps;
++ int tmp = !(mqc->a < (*mqc->curctx)->qeval);
++ mqc->a = (*mqc->curctx)->qeval;
++ *mqc->curctx = tmp ? (*mqc->curctx)->nlps : (*mqc->curctx)->nmps;
++ return tmp ^ d;
+ }
++*/
+
+ static void mqc_bytein(opj_mqc_t *mqc) {
+ if (mqc->bp != mqc->end) {
+@@ -506,22 +495,27 @@
+ }
+
+ int mqc_decode(opj_mqc_t *mqc) {
+- int d;
+ unsigned int qeval = (*mqc->curctx)->qeval;
+ mqc->a -= qeval;
++ bool tmp = (mqc->a < qeval);
+ qeval <<= 16;
+- if (mqc->c < qeval) {
+- d = mqc_lpsexchange(mqc);
+- } else {
++ if (mqc->c >= qeval) {
+ mqc->c -= qeval;
+- if ((mqc->a & 0x8000) == 0) {
+- d = mqc_mpsexchange(mqc);
+- } else {
++ if (mqc->a & 0x8000) {
+ return (*mqc->curctx)->mps;
+ }
++ }else{
++ tmp = !tmp;
++ mqc->a = (*mqc->curctx)->qeval;
+ }
++
++ opj_mqc_state_t* nmps = (*mqc->curctx)->nmps;
++ opj_mqc_state_t* nlps = (*mqc->curctx)->nlps;
++ int mps = (*mqc->curctx)->mps ^ tmp;
++ *mqc->curctx = tmp ? nlps : nmps;
++
+ mqc_renormd(mqc);
+- return d;
++ return mps;
+ }
+
+ void mqc_resetstates(opj_mqc_t *mqc) {
diff --git a/openjpeg-20070719svn-t1-t1_dec_sigpass_step-optimize.patch b/openjpeg-20070719svn-t1-t1_dec_sigpass_step-optimize.patch
new file mode 100644
index 0000000..49b6a31
--- /dev/null
+++ b/openjpeg-20070719svn-t1-t1_dec_sigpass_step-optimize.patch
@@ -0,0 +1,28 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-08-09 19:26:57.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-08-09 19:44:25.000000000 -0500
+@@ -40,7 +40,7 @@
+ /*@{*/
+
+ static INLINE char t1_getctxno_zc(int f, int orient);
+-static char t1_getctxno_sc(int f);
++static INLINE char t1_getctxno_sc(int f);
+ static INLINE int t1_getctxno_mag(int f);
+ static char t1_getspb(int f);
+ static short t1_getnmsedec_sig(int x, int bitpos);
+@@ -334,6 +334,7 @@
+
+ flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+ if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
++ *flagsp |= T1_VISIT;
+ if (type == T1_TYPE_RAW) {
+ if (raw_decode(raw)) {
+ v = raw_decode(raw); /* ESSAI */
+@@ -349,7 +350,6 @@
+ t1_updateflags(flagsp, v, t1->flags_stride);
+ }
+ }
+- *flagsp |= T1_VISIT;
+ }
+ } /* VSC and BYPASS by Antonin */
+
diff --git a/openjpeg-20070719svn-t1-x86_64-flags-branchless.patch b/openjpeg-20070719svn-t1-x86_64-flags-branchless.patch
new file mode 100644
index 0000000..cedfc10
--- /dev/null
+++ b/openjpeg-20070719svn-t1-x86_64-flags-branchless.patch
@@ -0,0 +1,29 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-08-06 14:07:59.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-08-06 15:54:31.000000000 -0500
+@@ -669,6 +669,17 @@
+ for (k = 0; k < t1->h; k += 4) {
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
++#ifdef __amd64__
++ int64 tmp = *((int64*)&t1->flags[(k+1) + (i+1)*t1->flags_stride]);
++ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
++ tmp &= ~((int64)(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S)<<48);
++ }
++ tmp &= (int64)(T1_SIG | T1_VISIT | T1_SIG_OTH)
++ | ((int64)(T1_SIG | T1_VISIT | T1_SIG_OTH)<<16)
++ | ((int64)(T1_SIG | T1_VISIT | T1_SIG_OTH)<<32)
++ | ((int64)(T1_SIG | T1_VISIT | T1_SIG_OTH)<<48);
++ agg = !tmp;
++#else
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+ agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+ || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+@@ -681,6 +692,7 @@
+ || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+ || t1->flags[(k+4) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ }
++#endif
+ } else {
+ agg = 0;
+ }
diff --git a/openjpeg-20070821svn-t1-flags-stride.patch b/openjpeg-20070821svn-t1-flags-stride.patch
new file mode 100644
index 0000000..af16758
--- /dev/null
+++ b/openjpeg-20070821svn-t1-flags-stride.patch
@@ -0,0 +1,182 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-08-23 05:48:09.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-08-23 05:50:29.000000000 -0500
+@@ -312,7 +312,7 @@
+ } else {
+ mqc_encode(mqc, v ^ t1_getspb(flag));
+ }
+- t1_updateflags(flagsp, v, t1->flags_stride);
++ t1_updateflags(flagsp, v, (t1->h+2));
+ }
+ *flagsp |= T1_VISIT;
+ }
+@@ -339,7 +339,7 @@
+ if (raw_decode(raw)) {
+ v = raw_decode(raw); /* ESSAI */
+ *datap = v ? -oneplushalf : oneplushalf;
+- t1_updateflags(flagsp, v, t1->flags_stride);
++ t1_updateflags(flagsp, v, (t1->h+2));
+ }
+ } else {
+ mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
+@@ -347,7 +347,7 @@
+ mqc_setcurctx(mqc, t1_getctxno_sc(flag));
+ v = mqc_decode(mqc) ^ t1_getspb(flag);
+ *datap = v ? -oneplushalf : oneplushalf;
+- t1_updateflags(flagsp, v, t1->flags_stride);
++ t1_updateflags(flagsp, v, (t1->h+2));
+ }
+ }
+ }
+@@ -370,7 +370,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_sigpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ bpno,
+@@ -400,7 +400,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_sigpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ oneplushalf,
+@@ -483,7 +483,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_refpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ bpno,
+ one,
+@@ -512,7 +512,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_refpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ poshalf,
+ neghalf,
+@@ -552,7 +552,7 @@
+ mqc_setcurctx(mqc, t1_getctxno_sc(flag));
+ v = *datap < 0 ? 1 : 0;
+ mqc_encode(mqc, v ^ t1_getspb(flag));
+- t1_updateflags(flagsp, v, t1->flags_stride);
++ t1_updateflags(flagsp, v, (t1->h+2));
+ }
+ }
+ *flagsp &= ~T1_VISIT;
+@@ -582,7 +582,7 @@
+ mqc_setcurctx(mqc, t1_getctxno_sc(flag));
+ v = mqc_decode(mqc) ^ t1_getspb(flag);
+ *datap = v ? -oneplushalf : oneplushalf;
+- t1_updateflags(flagsp, v, t1->flags_stride);
++ t1_updateflags(flagsp, v, (t1->h+2));
+ }
+ }
+ *flagsp &= ~T1_VISIT;
+@@ -605,16 +605,16 @@
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+- agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || (t1->flags[(k+4) + (i+1)*t1->flags_stride]
++ agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || (t1->flags[(k+4) + (i+1)*(t1->h+2)]
+ & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ } else {
+- agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+4) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+4) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ }
+ } else {
+ agg = 0;
+@@ -639,7 +639,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_clnpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ bpno,
+@@ -670,7 +670,7 @@
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
+ #ifdef __amd64__
+- int64 tmp = *((int64*)&t1->flags[(k+1) + (i+1)*t1->flags_stride]);
++ int64 tmp = *((int64*)&t1->flags[(k+1) + (i+1)*(t1->h+2)]);
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+ tmp &= ~((int64)(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S)<<48);
+ }
+@@ -681,16 +681,16 @@
+ agg = !tmp;
+ #else
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+- agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || (t1->flags[(k+4) + (i+1)*t1->flags_stride]
++ agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || (t1->flags[(k+4) + (i+1)*(t1->h+2)]
+ & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ } else {
+- agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+4) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+4) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ }
+ #endif
+ } else {
+@@ -711,7 +711,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_clnpass_step(
+ t1,
+- &t1->flags[(j+1) + (i+1)*t1->flags_stride],
++ &t1->flags[(j+1) + (i+1)*(t1->h+2)],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ oneplushalf,
+@@ -779,8 +779,7 @@
+ }
+ memset(t1->data,0,datasize * sizeof(int));
+
+- t1->flags_stride=h+2;
+- flagssize=t1->flags_stride * (w+2);
++ flagssize=(h+2) * (w+2);
+
+ if(flagssize > t1->flagssize){
+ opj_aligned_free(t1->flags);
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.h OpenJPEG.patched/libopenjpeg/t1.h
+--- OpenJPEG.orig/libopenjpeg/t1.h 2007-08-23 05:48:09.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.h 2007-08-23 05:48:37.000000000 -0500
+@@ -105,7 +105,6 @@
+ int h;
+ int datasize;
+ int flagssize;
+- int flags_stride;
+ } opj_t1_t;
+
+ /** @name Exported functions */
diff --git a/openjpeg-20070821svn-t1-remove-macro.patch b/openjpeg-20070821svn-t1-remove-macro.patch
new file mode 100644
index 0000000..680931f
--- /dev/null
+++ b/openjpeg-20070821svn-t1-remove-macro.patch
@@ -0,0 +1,171 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-08-23 05:43:10.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-08-23 05:46:31.000000000 -0500
+@@ -259,27 +259,24 @@
+ }
+
+ static void t1_updateflags(flag_t *flagsp, int s, int stride) {
+- flag_t *np = flagsp - stride;
+- flag_t *sp = flagsp + stride;
+-
+ static const flag_t mod[] = {
+- T1_SIG_S, T1_SIG_S|T1_SGN_S,
+ T1_SIG_E, T1_SIG_E|T1_SGN_E,
+- T1_SIG_W, T1_SIG_W|T1_SGN_W,
+- T1_SIG_N, T1_SIG_N|T1_SGN_N
++ T1_SIG_S, T1_SIG_S|T1_SGN_S,
++ T1_SIG_N, T1_SIG_N|T1_SGN_N,
++ T1_SIG_W, T1_SIG_W|T1_SGN_W
+ };
+
+- np[-1] |= T1_SIG_SE;
+- np[0] |= mod[s];
+- np[1] |= T1_SIG_SW;
++ flagsp[-1 - stride] |= T1_SIG_SE;
++ flagsp[ 0 - stride] |= mod[s];
++ flagsp[ 1 - stride] |= T1_SIG_NE;
+
+ flagsp[-1] |= mod[s+2];
+- flagsp[0] |= T1_SIG;
+- flagsp[1] |= mod[s+4];
++ flagsp[ 0] |= T1_SIG;
++ flagsp[ 1] |= mod[s+4];
+
+- sp[-1] |= T1_SIG_NE;
+- sp[0] |= mod[s+6];
+- sp[1] |= T1_SIG_NW;
++ flagsp[-1 + stride] |= T1_SIG_SW;
++ flagsp[ 0 + stride] |= mod[s+6];
++ flagsp[ 1 + stride] |= T1_SIG_NW;
+ }
+
+ static void t1_enc_sigpass_step(
+@@ -373,7 +370,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_sigpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ bpno,
+@@ -403,7 +400,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_sigpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ oneplushalf,
+@@ -486,7 +483,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_refpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ bpno,
+ one,
+@@ -515,7 +512,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_refpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ poshalf,
+ neghalf,
+@@ -608,16 +605,16 @@
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+- agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || (MACRO_t1_flags(1 + k + 3,1 + i)
+- & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || (t1->flags[(k+4) + (i+1)*t1->flags_stride]
++ & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ } else {
+- agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+4) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ }
+ } else {
+ agg = 0;
+@@ -642,7 +639,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_enc_clnpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ bpno,
+@@ -673,16 +670,16 @@
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+- agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || (MACRO_t1_flags(1 + k + 3,1 + i)
+- & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || (t1->flags[(k+4) + (i+1)*t1->flags_stride]
++ & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ } else {
+- agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg = !(t1->flags[(k+1) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+2) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+3) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
++ || t1->flags[(k+4) + (i+1)*t1->flags_stride] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+ }
+ } else {
+ agg = 0;
+@@ -702,7 +699,7 @@
+ vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+ t1_dec_clnpass_step(
+ t1,
+- &t1->flags[((j+1) * t1->flags_stride) + i + 1],
++ &t1->flags[(j+1) + (i+1)*t1->flags_stride],
+ &t1->data[(j * t1->w) + i],
+ orient,
+ oneplushalf,
+@@ -770,8 +767,8 @@
+ }
+ memset(t1->data,0,datasize * sizeof(int));
+
+- t1->flags_stride=w+2;
+- flagssize=t1->flags_stride * (h+2);
++ t1->flags_stride=h+2;
++ flagssize=t1->flags_stride * (w+2);
+
+ if(flagssize > t1->flagssize){
+ opj_aligned_free(t1->flags);
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.h OpenJPEG.patched/libopenjpeg/t1.h
+--- OpenJPEG.orig/libopenjpeg/t1.h 2007-05-22 08:14:13.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.h 2007-08-23 05:44:00.000000000 -0500
+@@ -108,8 +108,6 @@
+ int flags_stride;
+ } opj_t1_t;
+
+-#define MACRO_t1_flags(x,y) t1->flags[((x)*(t1->flags_stride))+(y)]
+-
+ /** @name Exported functions */
+ /*@{*/
+ /* ----------------------------------------------------------------------- */
diff --git a/openjpeg-20070821svn-t1-updateflags-x86_64.patch b/openjpeg-20070821svn-t1-updateflags-x86_64.patch
new file mode 100644
index 0000000..6bc8daf
--- /dev/null
+++ b/openjpeg-20070821svn-t1-updateflags-x86_64.patch
@@ -0,0 +1,84 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-08-23 05:53:17.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-08-23 05:56:33.000000000 -0500
+@@ -45,7 +45,11 @@
+ static char t1_getspb(int f);
+ static short t1_getnmsedec_sig(int x, int bitpos);
+ static short t1_getnmsedec_ref(int x, int bitpos);
++#ifdef __amd64__
++static INLINE void t1_updateflags(flag_t *flagsp, int s, int stride);
++#else
+ static void t1_updateflags(flag_t *flagsp, int s, int stride);
++#endif
+ /**
+ Encode significant pass
+ */
+@@ -258,6 +262,38 @@
+ return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
+ }
+
++#ifdef __amd64__
++
++/* On 64 bit platforms we can set three flags at a time. (SWAR) */
++/* FIXME: Assumes little endian? */
++
++#define VEC(x,y,z) (int64)(x)|((int64)(y)<<16)|((int64)(z)<<32)
++
++static void t1_updateflags(flag_t *flagsp, int s, int stride) {
++ static const int64 mod[] = {
++ VEC(T1_SIG_SE, T1_SIG_E, T1_SIG_NE),
++ VEC(T1_SIG_SE, T1_SIG_E|T1_SGN_E, T1_SIG_NE),
++ VEC(T1_SIG_S, T1_SIG, T1_SIG_N),
++ VEC(T1_SIG_S|T1_SGN_S, T1_SIG, T1_SIG_N|T1_SGN_N),
++ VEC(T1_SIG_SW, T1_SIG_W, T1_SIG_NW),
++ VEC(T1_SIG_SW, T1_SIG_W|T1_SGN_W, T1_SIG_NW)
++ };
++
++ int64 tmp1 = *(int64*)((void*)&flagsp[-1 - stride]);
++ int64 tmp2 = *(int64*)((void*)&flagsp[-1 ]);
++ int64 tmp3 = *(int64*)((void*)&flagsp[-1 + stride]);
++
++ tmp1 |= mod[s];
++ tmp2 |= mod[s+2];
++ tmp3 |= mod[s+4];
++
++ *(int64*)((void*)&flagsp[-1 - stride]) = tmp1;
++ *(int64*)((void*)&flagsp[-1 ]) = tmp2;
++ *(int64*)((void*)&flagsp[-1 + stride]) = tmp3;
++}
++
++#else
++
+ static void t1_updateflags(flag_t *flagsp, int s, int stride) {
+ static const flag_t mod[] = {
+ T1_SIG_E, T1_SIG_E|T1_SGN_E,
+@@ -279,6 +315,8 @@
+ flagsp[ 1 + stride] |= T1_SIG_NW;
+ }
+
++#endif
++
+ static void t1_enc_sigpass_step(
+ opj_t1_t *t1,
+ flag_t *flagsp,
+@@ -670,6 +708,8 @@
+ for (i = 0; i < t1->w; ++i) {
+ if (k + 3 < t1->h) {
+ #ifdef __amd64__
++ /* 64 bit SWAR */
++ /* FIXME: Assumes little endian? */
+ int64 tmp = *((int64*)&t1->flags[(k+1) + (i+1)*(t1->h+2)]);
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+ tmp &= ~((int64)(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S)<<48);
+@@ -780,6 +820,11 @@
+ memset(t1->data,0,datasize * sizeof(int));
+
+ flagssize=(h+2) * (w+2);
++#ifdef __amd64__
++ /* 64 bit SIMD/SWAR in t1_updateflags requires one short of headroom
++ because three shorts = 48 bits. */
++ ++flagssize;
++#endif
+
+ if(flagssize > t1->flagssize){
+ opj_aligned_free(t1->flags);
diff --git a/openjpeg-svn468-mj2-noscroll.patch b/openjpeg-svn468-mj2-noscroll.patch
new file mode 100644
index 0000000..23ecd36
--- /dev/null
+++ b/openjpeg-svn468-mj2-noscroll.patch
@@ -0,0 +1,42 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.patched/mj2/frames_to_mj2.c OpenJPEG.foo/mj2/frames_to_mj2.c
+--- OpenJPEG.patched/mj2/frames_to_mj2.c 2007-10-18 07:26:11.000000000 -0500
++++ OpenJPEG.foo/mj2/frames_to_mj2.c 2007-11-03 22:48:45.000000000 -0500
+@@ -758,7 +758,7 @@
+ fwrite(buf, 1, len+8, mj2file);
+ offset += len+8;
+ elapsed_time = opj_clock()-init_time;
+- fprintf(stderr, "Frame number %d/%d encoded in %.2f mseconds\n", sampleno + 1, numframes, elapsed_time*1000);
++ fprintf(stderr, "Frame number %d/%d encoded in %.2f mseconds \r", sampleno + 1, numframes, elapsed_time*1000);
+ total_time += elapsed_time;
+
+ }
+@@ -787,7 +787,7 @@
+ fwrite(buf,cio_tell(cio),1,mj2file);
+ free(buf);
+
+- fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n", total_time, numframes, (float)numframes/total_time);
++ fprintf(stdout,"\nTotal encoding time: %.2f s for %d frames (%.1f fps)\n", total_time, numframes, (float)numframes/total_time);
+
+ // Ending program
+
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.patched/mj2/mj2_to_frames.c OpenJPEG.foo/mj2/mj2_to_frames.c
+--- OpenJPEG.patched/mj2/mj2_to_frames.c 2007-10-18 07:26:11.000000000 -0500
++++ OpenJPEG.foo/mj2/mj2_to_frames.c 2007-11-03 22:48:45.000000000 -0500
+@@ -204,7 +204,7 @@
+ /* free image data structure */
+ opj_image_destroy(img);
+ elapsed_time = opj_clock()-init_time;
+- fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
++ fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds \r", snum + 1, numframes, elapsed_time*1000);
+ total_time += elapsed_time;
+
+ }
+@@ -218,7 +218,7 @@
+ }
+ free(dinfo);
+
+- fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
++ fprintf(stdout, "\n%d frame(s) correctly decompressed\n", snum);
+ fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
+
+ return 0;
diff --git a/openjpeg-svn470-t1-flags-mmx.patch b/openjpeg-svn470-t1-flags-mmx.patch
new file mode 100644
index 0000000..00ae183
--- /dev/null
+++ b/openjpeg-svn470-t1-flags-mmx.patch
@@ -0,0 +1,145 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/t1.c OpenJPEG.patched/libopenjpeg/t1.c
+--- OpenJPEG.orig/libopenjpeg/t1.c 2007-11-13 13:52:05.000000000 -0600
++++ OpenJPEG.patched/libopenjpeg/t1.c 2007-11-14 01:09:40.000000000 -0600
+@@ -33,6 +33,17 @@
+ #include "opj_includes.h"
+ #include "t1_luts.h"
+
++/* Don't use MMX on amd64 */
++/* Note that merely including mmintrin.h, even if we don't use it, changes the code gcc */
++/* outputs on amd64, and it is measurably slower. A bug in gcc? */
++#ifdef __amd64__
++#undef __MMX__
++#endif
++
++#ifdef __MMX__
++#include <mmintrin.h>
++#endif
++
+ /** @defgroup T1 T1 - Implementation of the tier-1 coding */
+ /*@{*/
+
+@@ -45,7 +56,7 @@
+ static char t1_getspb(int f);
+ static short t1_getnmsedec_sig(int x, int bitpos);
+ static short t1_getnmsedec_ref(int x, int bitpos);
+-#ifdef __amd64__
++#if defined(__amd64__) || defined(__MMX__)
+ static INLINE void t1_updateflags(flag_t *flagsp, int s, int stride);
+ #else
+ static void t1_updateflags(flag_t *flagsp, int s, int stride);
+@@ -293,6 +304,32 @@
+ }
+
+ #else
++#ifdef __MMX__
++
++static void t1_updateflags(flag_t *flagsp, int s, int stride) {
++ static const __v4hi mod[] = {
++ {T1_SIG_SE, T1_SIG_E, T1_SIG_NE, 0},
++ {T1_SIG_SE, T1_SIG_E|T1_SGN_E, T1_SIG_NE, 0},
++ {T1_SIG_S, T1_SIG, T1_SIG_N, 0},
++ {T1_SIG_S|T1_SGN_S, T1_SIG, T1_SIG_N|T1_SGN_N, 0},
++ {T1_SIG_SW, T1_SIG_W, T1_SIG_NW, 0},
++ {T1_SIG_SW, T1_SIG_W|T1_SGN_W, T1_SIG_NW, 0}
++ };
++
++ __m64 tmp1 = *(__m64*)((void*)&flagsp[-1 - stride]);
++ __m64 tmp2 = *(__m64*)((void*)&flagsp[-1 ]);
++ __m64 tmp3 = *(__m64*)((void*)&flagsp[-1 + stride]);
++
++ tmp1 = _mm_or_si64(tmp1, mod[s]);
++ tmp2 = _mm_or_si64(tmp2, mod[s+2]);
++ tmp3 = _mm_or_si64(tmp3, mod[s+4]);
++
++ *(__m64*)((void*)&flagsp[-1 - stride]) = tmp1;
++ *(__m64*)((void*)&flagsp[-1 ]) = tmp2;
++ *(__m64*)((void*)&flagsp[-1 + stride]) = tmp3;
++}
++
++#else
+
+ static void t1_updateflags(flag_t *flagsp, int s, int stride) {
+ static const flag_t mod[] = {
+@@ -316,6 +353,7 @@
+ }
+
+ #endif
++#endif
+
+ static void t1_enc_sigpass_step(
+ opj_t1_t *t1,
+@@ -720,18 +758,14 @@
+ | ((int64)(T1_SIG | T1_VISIT | T1_SIG_OTH)<<48);
+ agg = !tmp;
+ #else
++ int* flagsp = (int*)&t1->flags[(k+1) + (i+1)*(t1->h+2)];
++ agg = flagsp[1];
+ if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+- agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || (t1->flags[(k+4) + (i+1)*(t1->h+2)]
+- & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+- } else {
+- agg = !(t1->flags[(k+1) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+2) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+3) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+- || t1->flags[(k+4) + (i+1)*(t1->h+2)] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
++ agg &= ~((T1_SIG_S|T1_SIG_SE|T1_SIG_SW|T1_SGN_S)<<16);
+ }
++ agg |= flagsp[0];
++ agg &= (T1_SIG|T1_VISIT|T1_SIG_OTH)|(T1_SIG|T1_VISIT|T1_SIG_OTH)<<16;
++ agg = !agg;
+ #endif
+ } else {
+ agg = 0;
+@@ -820,7 +854,7 @@
+ memset(t1->data,0,datasize * sizeof(int));
+
+ flagssize=(h+2) * (w+2);
+-#ifdef __amd64__
++#if defined(__amd64__) || defined(__MMX__)
+ /* 64 bit SIMD/SWAR in t1_updateflags requires one short of headroom
+ because three shorts = 48 bits. */
+ ++flagssize;
+@@ -886,6 +920,9 @@
+ int correction = 3;
+ type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
+
++#if !defined(__amd64__) && defined(__MMX__)
++ _mm_empty();
++#endif
+ switch (passtype) {
+ case 0:
+ t1_enc_sigpass(t1, bpno, orient, &nmsedec, type, cblksty);
+@@ -900,6 +937,9 @@
+ mqc_segmark_enc(mqc);
+ break;
+ }
++#if !defined(__amd64__) && defined(__MMX__)
++ _mm_empty();
++#endif
+
+ /* fixed_quality */
+ cumwmsedec += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps);
+@@ -1004,6 +1044,9 @@
+ mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
+ mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
+
++#if !defined(__amd64__) && defined(__MMX__)
++ _mm_empty();
++#endif
+ for (segno = 0; segno < cblk->numsegs; ++segno) {
+ opj_tcd_seg_t *seg = &cblk->segs[segno];
+
+@@ -1044,6 +1087,9 @@
+ }
+ }
+ }
++#if !defined(__amd64__) && defined(__MMX__)
++ _mm_empty();
++#endif
+ }
+
+ /* ----------------------------------------------------------------------- */
diff --git a/openjpeg-svn480-cmake.patch b/openjpeg-svn480-cmake.patch
new file mode 100644
index 0000000..086d846
--- /dev/null
+++ b/openjpeg-svn480-cmake.patch
@@ -0,0 +1,45 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/CMakeLists.txt OpenJPEG.patched/CMakeLists.txt
+--- OpenJPEG.orig/CMakeLists.txt 2007-09-25 09:54:49.000000000 -0500
++++ OpenJPEG.patched/CMakeLists.txt 2007-09-26 00:34:22.000000000 -0500
+@@ -24,6 +24,7 @@
+
+ #-----------------------------------------------------------------------------
+ # OPENJPEG version number, useful for packaging and doxygen doc:
++SET(OPENJPEG_SOVERSION 2)
+ SET(OPENJPEG_VERSION_MAJOR 1)
+ SET(OPENJPEG_VERSION_MINOR 2)
+ SET(OPENJPEG_VERSION_BUILD 0)
+@@ -33,8 +34,8 @@
+ # This setting of SOVERSION assumes that any API change
+ # will increment either the minor or major version number of openjpeg
+ SET(OPENJPEG_LIBRARY_PROPERTIES
+- VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
+- SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
++ VERSION "${OPENJPEG_SOVERSION}.${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
++ SOVERSION ${OPENJPEG_SOVERSION}
+ )
+
+
+@@ -116,6 +117,10 @@
+ $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
+ )
+
++IF(NOT CMAKE_INSTALL_LIBDIR)
++SET(CMAKE_INSTALL_LIBDIR lib)
++ENDIF(NOT CMAKE_INSTALL_LIBDIR)
++
+ #-----------------------------------------------------------------------------
+ # Compiler specific flags:
+ IF(CMAKE_COMPILER_IS_GNUCC)
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/CMakeLists.txt OpenJPEG.patched/libopenjpeg/CMakeLists.txt
+--- OpenJPEG.orig/libopenjpeg/CMakeLists.txt 2007-09-25 09:54:49.000000000 -0500
++++ OpenJPEG.patched/libopenjpeg/CMakeLists.txt 2007-09-26 00:31:12.000000000 -0500
+@@ -37,7 +37,7 @@
+
+ # Install library
+ INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
+- DESTINATION lib)
++ DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+ # Install includes files
+ INSTALL(FILES openjpeg.h
diff --git a/openjpeg-svn480-use-stdbool.patch b/openjpeg-svn480-use-stdbool.patch
new file mode 100644
index 0000000..ff2cb2b
--- /dev/null
+++ b/openjpeg-svn480-use-stdbool.patch
@@ -0,0 +1,12 @@
+diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/openjpeg.h OpenJPEG.patched/libopenjpeg/openjpeg.h
+--- OpenJPEG.orig/libopenjpeg/openjpeg.h 2007-11-14 05:34:48.000000000 -0600
++++ OpenJPEG.patched/libopenjpeg/openjpeg.h 2007-11-16 20:41:53.000000000 -0600
+@@ -61,7 +61,7 @@
+ #endif /* !OPJ_STATIC || !WIN32 */
+
+ #ifndef __cplusplus
+-#if defined(HAVE_STDBOOL_H)
++#if 1
+ /*
+ The C language implementation does correctly provide the standard header
+ file "stdbool.h".
diff --git a/sources b/sources
index e69de29..ac23086 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+f9a3ccfa91ac34b589e9bf7577ce8ff9 openjpeg_v1_3.tar.gz
More information about the scm-commits
mailing list