• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Jpeg2000 and Mac OSX

Started by mos, 31 May 2009, 16:46:25

Previous topic - Next topic

mos

I have tried to porting JPEG2000 under Mac OSX.

From the package http://www.openjpeg.org/openjpeg_v1_3_osx.zip I have extract two file

libopenjpeg.dylib,
libopenjpeg.a

and put these on follow directory

(Imaging Root)\Source\Extras\Extensions\J2KObjects

with others library. Then I have modified the file (Imaging Root)\Source\Extras\Extensions\OpenJpeg.pas
to load the static library (see attached OpenJpeg.pas).

But when execute the program in attached project, I obtain an exception error, see screenshot.


Can you help me?


Thanks and goodbye

Galfar

OpenJpeg static library that comes with Imaging is not based directly on OpenJpeg 1.3.0 code. Layout of some records is different so that's probably why you get mem access error. OpenJpeg in Imaging is patched with CDEF patch: http://groups.google.com/group/openjpeg/browse_thread/thread/1cb7807b2053592e/8e1069783f108aa6

If you could recompile this static library I'll send you the modified OpenJpeg code.

mos

Thanks for your answer, I have compiled OpenJpeg with CDEF patch under my OSX.

I have encountered two problem, the first is relative to malloc.h resolved with a symbolic link
ln -s /usr/include/malloc/malloc.h /usr/include/malloc.h

and the second is relative to _memalign resolved modifying the opj_malloc.h as

#else /* Not WIN32 */
   #if defined(__sun)
      #define HAVE_MEMALIGN
   #elif defined(__GNUC__)
      #ifndef __APPLE__
         #define HAVE_MEMALIGN
         #include <malloc.h>
      #endif
   /* Linux x86_64 and OSX always align allocations to 16 bytes */
   #elif !defined(__amd64__) && !defined(__APPLE__)   
      /* FIXME: Yes, this is a big assumption */
      #define HAVE_POSIX_MEMALIGN
   #endif
#endif


In the attached file there's the new libopenjpeg.a that work fine under Mac OSX (i386).


Goodbye


Galfar

4 June 2009, 01:33:19 #3 Last Edit: 4 June 2009, 01:54:26 by Galfar
Great work, thanks.
I'll add your modifications to Imaging's repository.

Have you used the default makefile supplied with OpenJpeg to build the static lib? (there's a bug in OpenJpeg when saving images with alpha described in the thread I posted - so I'll need to experiment with GCC options)

mos

Yes, I have used the makefile included in the source of OpenJpeg, in my OSX I use GCC version 4.0.1 build 5465.

Now I'm do some test with JPEG lossless because I have a problem with an image, this problem is not present under Linux and Windows.


Galfar

Any news about that lossless JPEG problem?

I found out I have to compile OpenJpeg with -O0 option for GCC in Mac OSX to get rid of that alpha bug (-O1 works on some other platforms).

mos

11 June 2009, 11:31:37 #6 Last Edit: 11 June 2009, 11:33:54 by mos
My project test work on 4 DICOM files, on this files the image data begin with a offset of 1680, so it's necessary to skip DICOM header.

The attached project work well for 3 files:

8-bit J2K Lossy Gray.dcm
8-bit J2K Lossless Gray.dcm
8-bit JPEG Lossy Gray.dcm

but failed with this:

8-bit JPEG Lossless Gray.dcm 

I obtain this exception:
"Project raised exception class 'EImagingError" with message:
JPEG Error: 61 (Unsupported JPEG process: SOF type $%02x)"

The problem is present under Windows, Linux and Mac OSX.

In debugging I found that the exception is generated by follow code in imjdmarker.pas@2221:

...
      M_SOF3,                     { Lossless, Huffman }
      M_SOF5,                     { Differential sequential, Huffman }
      M_SOF6,                     { Differential progressive, Huffman }
      M_SOF7,                     { Differential lossless, Huffman }
      M_JPG,                      { Reserved for JPEG extensions }
      M_SOF11,                    { Lossless, arithmetic }
      M_SOF13,                    { Differential sequential, arithmetic }
      M_SOF14,                    { Differential progressive, arithmetic }
      M_SOF15:                    { Differential lossless, arithmetic }
        ERREXIT1(j_common_ptr(cinfo), JERR_SOF_UNSUPPORTED, cinfo^.unread_marker);   
...

where cinfo^.unread_marker = M_SOF3 (195) so I think that the decompress algorithm cannot manipulate Lossless Huffman compression?

Galfar

Quote from: mos on 11 June 2009, 11:31:37
...
where cinfo^.unread_marker = M_SOF3 (195) so I think that the decompress algorithm cannot manipulate Lossless Huffman compression?


I did some googling and looks like lossless compression was patched to JpegLib after its Pascal translation so there is no support for it in PasJpeg. However, ImagingJpeg unit could be extended to allow selecting of another Jpeg library (maybe link to some recent JpegLib dynamic library, maybe IJL but that's Win32 only, ...).


Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk