Open gcode-importer opened 9 years ago
Issue 404 - JNI not found
Reported by belkop43@students.rowan.edu
on 2014-09-22 12:18:24
These patches do not work.
-------------------------------------------------------------
cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_VIEWER:bool=off -DBUILD_JAVA:bool=on
-DBUILD_JPIP_SERVER:bool=off -DBUILD_SHARED_LIBS:bool=on -DBUILD_MJ2:bool=on -DBUILD_JP3D:bool=off
-DBUILD_JPWL:bool=off -DBUILD_JPIP:bool=off -DCMAKE_INSTALL_PREFIX=/usr/local/JAVA_TEST
..
/home/szukw000/OPENJPEG/TRUNK/openjpeg-2.x-trunk-r2885-1/src/bin/jp2/convert.h:62:5:
error: unknown type name 'OPJ_BOOL'
OPJ_BOOL rawSigned;
^
make[2]: *** [wrapping/java/openjp2/CMakeFiles/openjpegjni.dir/JavaOpenJPEGDecoder.c.o]
Error 1
make[1]: *** [wrapping/java/openjp2/CMakeFiles/openjpegjni.dir/all] Error 2
make: *** [all] Error 2
-------------------------------------------------------------
The 'openjp2' library does not know 'opj_stream_create_file_stream_v4()'.
This is a function invented by Aaron Boxer for his
openjpeg-java_imageio resp. RadStackJava
archives. I suppose these patches are 'copies' of the respective
'wrapping/java/openjp2' files of these archives:
-------------------------------------------------------------
decodeInfo.stream = opj_stream_create_file_stream_v4(p_file_info,OPJ_J2K_STREAM_CHUNK_SIZE,1);
./wrapping/java/openjp2/OpenJPEGJavaDecoder.c
return opj_stream_create_file_stream_v4(p_file_info, p_size, p_is_read_stream);
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v4 (
./src/lib/openjp2/openjpeg.c
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v4 (opj_file_info_t*
p_file_info,
./src/lib/openjp2/openjpeg.h
-------------------------------------------------------------
And the 'wrapping/java/openjp2/CMakeLists.txt' file contains:
-------------------------------------------------------------
# FIXME (need to use old API):
if(BUILD_MJ2)
target_link_libraries(openjpegjni openmj2)
endif()
-------------------------------------------------------------
But 'src/lib/openjp2/openjpeg.h' does know OPJ_BOOL, OPJ_OFF_T,
OPJ_SIZE_T, OPJ_CODEC_J2K, etc.
Only 'src/lib/openmj2/openjpeg.h' does know them.
winfried
Reported by szukw000 on 2014-09-22 22:14:27
Sorry, paste error. Correction:
Only 'src/lib/openjp2/openjpeg.h' does know OPJ_BOOL, OPJ_OFF_T,
OPJ_SIZE_T, OPJ_CODEC_J2K, etc.
But 'src/lib/openmj2/openjpeg.h' does NOT know them.
winfried
Reported by szukw000 on 2014-09-23 09:31:27
Hello Winfried,
I went back and looked at the trunk and had the same errors.
The MJ2 is broken there, not by something in this patch.
The "Fix Me" in the 'wrapping/java/openjp2/CMakeLists.txt' is also in the trunk.
Pat
Reported by belkop43@students.rowan.edu
on 2014-09-24 12:56:52
The MJ2 library is not broken. The patch is 'broken'.
In the following lines JAVA means 'src/lib/openjp2' from
https://github.com/CodecCentral/openjpeg/tree/java_imageio
openjpeg-java_imageio.zip
Please show me the file where the following is found
either in
'openjpeg-2.x-trunk-r2885/src/lib/openjp2'
or
'openjpeg-2.x-trunk-r2885/src/lib/openmj2':
JAVA/openjpeg.h:
=========================
typedef struct opj_buffer_info
{
OPJ_BYTE *buf;
OPJ_BYTE *cur;
OPJ_SIZE_T len;
} opj_buffer_info_t;
OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_buffer_stream(opj_buffer_info_t* p_source_buffer,
OPJ_BOOL p_is_read_stream);
typedef struct opj_segmented_file_info
{
char infile[OPJ_PATH_LEN];
FILE* p_file;
OPJ_SIZE_T dataLength;
OPJ_SIZE_T dataRead;
int numSegmentsMinusOne;
OPJ_OFF_T* p_segmentPositionsList;
OPJ_SIZE_T* p_segmentLengths;
OPJ_OFF_T curPos;
int curSegment;
} opj_file_info_t;
OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_default_file_stream_v4 (opj_file_info_t* p_file_info,
OPJ_BOOL p_is_read_stream);
OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_file_stream_v4 (opj_file_info_t* p_file_info,
OPJ_SIZE_T p_buffer_size,
OPJ_BOOL p_is_read_stream);
OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_segmented_file_stream(opj_file_info_t* p_source_file,
OPJ_BOOL p_is_read_stream);
JAVA/openjpeg.c:
=========================
static void
opj_increment_segment(opj_file_info_t * p_file_info);
static OPJ_SIZE_T
opj_read_from_segmented_file (void * p_buffer,
OPJ_SIZE_T p_nb_bytes, opj_file_info_t * p_file_info);
static OPJ_SIZE_T
opj_get_data_length_from_segmented_file (opj_file_info_t * p_file_info);
static OPJ_BOOL
opj_init_segmented_file_info (opj_file_info_t * p_file_info);
static OPJ_OFF_T
opj_skip_from_segmented_file (OPJ_OFF_T p_nb_bytes,
opj_file_info_t * p_file_info);
static OPJ_BOOL
opj_seek_from_segmented_file (OPJ_OFF_T p_nb_bytes,
opj_file_info_t* p_file_info);
static OPJ_SIZE_T
opj_read_from_file (void * p_buffer, OPJ_SIZE_T p_nb_bytes,
opj_file_info_t* p_file_info);
^^^^^^^^^^^^^^^^^
static OPJ_SIZE_T
opj_get_data_length_from_file (opj_file_info_t * p_file_info);
^^^^^^^^^^^^^^^^^
static OPJ_SIZE_T
opj_write_from_file (void * p_buffer, OPJ_SIZE_T p_nb_bytes,
opj_file_info_t * p_file_info);
^^^^^^^^^^^^^^^^^
static OPJ_OFF_T
opj_skip_from_file (OPJ_OFF_T p_nb_bytes,
opj_file_info_t * p_user_data);
^^^^^^^^^^^^^^^^^
static OPJ_BOOL
opj_seek_from_file (OPJ_OFF_T p_nb_bytes,
opj_file_info_t * p_user_data);
^^^^^^^^^^^^^^^^^
>The "Fix Me" in the 'wrapping/java/openjp2/CMakeLists.txt' is also in the trunk.
Yes. Because using the MJ2 library was necessary to use the code in
'wrapping/java/openjp2/': this code is openjpeg-v1 code; and the MJ2
code too is openjpeg-v1 code.
winfried
Reported by szukw000 on 2014-09-25 10:46:58
Pat,
I have written a very simple adaption of
'wrapper/java/openjp2'
for 'openjpeg-2.x-trunk-r2887'.
Simple means: all openjpeg-v1 code is replaced with code
from openjpeg-v2.
The code needs polish.
It compiles on LINUX. Can you test it?
Do you need the
create_index_into_byte_array()
function?
Please read the comment above the definition.
winfried
Reported by szukw000 on 2014-09-29 17:21:32
Winfried,
Thanks for providing a more updated version of the wrapper code that uses the jp2 library.
I got your code to compile, but I was unable to create the openjpegjni library. That's
alright though, I was able to build it shortly after with some edits to the CMake file
found in the wrapping/java/openjp2 directory.
Soon I will be releasing another version of the patch. I will provide the option of
using a byte stream for the decoder. Note: I made some changes to your OpenJPEGJavaDecoder
class to make the byte stream option work. I am not sure if I will make any edits to
the encoder code though.
Reported by emd5174@psu.edu
on 2014-10-02 13:31:17
Here is 'wrapping-trunk-r2887.tgz', the
'wrapping/java/openjp2'
directory for 'openjpeg-2.x-trunk-r2882'.
In openjpeg-v1, JavaOpenJPEGDecoder.c:
===============================================
'-i' is an option and used.
'-o' is an option and used.
'-O' is an option and used.
'-ImgDir' is an option and used in load_images() that is unused.
'-OutFor' is an option REQUIRED only together with '-ImgDir'.
In openjpeg-v1, JavaOpenJPEG.c: // i.e. JavaOpenJPEGEncoder.c
===============================================
'-i' is no option.
'-o' is an option and used.
'-ImgDir' is an option that is unused.
'-OutFor' is an option REQUIRED only together with '-ImgDir'.
'-x' is an option and used.
So in openjpeg-v2, JavaOpenJPEGDecoder.c:
===============================================
'-ImgDir' and '-OutFor' HAVE BEEN REMOVED.
And in openjpeg-v2, JavaOpenJPEGEncoder.c:
===============================================
'-ImgDir' and '-OutFor' HAVE BEEN REMOVED.
DO NOT FORGET: the top 'CMakeLists.txt' needs inclusion of
the following code (in line 191 of trunk-r2882):
if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif(UNIX)
Necessary for BUILD_THIRDPARTY (static libraries) and
BUILD_JAVA (dynamic library).
Systems used: LINUX 64-Bit and Win7 64-Bit, JAVA-8u20.
LINUX with 'gcc-4.8', Win7 with 'cl'.
winfried
Reported by szukw000 on 2014-10-03 00:48:24
Winfried,
The wrapping-trunk-r2887 version you just provided, will this be the official patch
of this issue or will you be continuing to add more?
Reported by emd5174@psu.edu
on 2014-10-03 12:33:36
Winfried,
I provided an update to your recent wrapping-trunk-r2887 version. I added the option
to use a byte stream (using the byte stream functions that Aaron Boxer was using but
still staying with the openjp2 libraries) to decode an image. I provided a 'changesanddeletions'
diff (Comparing your recent r2887 submission to mine submission).
To use the byte stream option for the OpenJPEGJavaDecoder, just call the OpenJPEGJavaDecoder's
setCompressedStream function and set the byte array of that j2k image file and then
call the decodeJ2KtoImage() function. It won't export to anything (as intended), but
it will return an array of J2K info to the image8, image16, image24 variables and you
can create a BufferedImage from that.
I only modified a few lines of code in the JavaOpenJPEGDecoder.c/h and JavaOpenJPEGEncoder.c/h
files and the OpenJPEGJavaDecoder.java file to allow the byte stream functions to work.
I was using Windows 7/MinGW to compile OpenJPEG. If there's any problems, let me know.
You might need to change the C JNI functions calls back to their original names (I
had an UnsatifiedLinkError from Java because I had to add an underscore in front of
the JNI C functions. I don't know if there is a workaround this for Windows systems).
-Eric
Reported by emd5174@psu.edu
on 2014-10-09 18:37:13
I am chopped off: my (provider) modem is broken. So only two short notes.
The wrapping directory is part of the offical library. But
opj_stream_create_buffer_stream()
is not found in the official library. It is only part of Aaron Boxers
archive (Cnf. comment #5).
Using a buffer stream you have to create a local function in your application.
E.g.:
static opj_stream_t* stream_create_buffer_stream(opj_buffer_info_t* buf_info,
OPJ_UINT32 p_size, OPJ_BOOL p_is_read_stream)
{
opj_stream_t* l_stream;
l_stream = opj_stream_create(p_size, p_is_read_stream);
if(! l_stream) return NULL;
opj_stream_set_user_data(l_stream, buf_info);
opj_stream_set_user_data_length(l_stream, buf_info->len);
opj_stream_set_read_function(l_stream,
(opj_stream_read_fn) read_from_buffer);
opj_stream_set_write_function(l_stream,
(opj_stream_write_fn) write_from_buffer);
opj_stream_set_skip_function(l_stream,
(opj_stream_skip_fn) skip_from_buffer);
opj_stream_set_seek_function(l_stream,
(opj_stream_seek_fn) seek_from_buffer);
return l_stream;
}
Now you can read_from_buffer etc.
This does not look correct:
+ /*
+
+ /* Allocate JAVA memory:
+ */
winfried
Reported by szukw000 on 2014-10-09 21:18:23
Thanks for looking into my patch submission. For the patch approval process, is it alright
if I used those functions* that weren't in the official libraries for the byte stream
implementation? I also corrected the comments in the code. I will post another diff
and zip file of the corrections in the near future.
Let me know if there's anything else I should do to get this issue resolved.
Thanks,
Eric
*:
opj_stream_t* OPJ_CALLCONV opj_stream_create_buffer_stream(opj_buffer_info_t* p_source_buffer,
OPJ_BOOL p_is_read_stream);
static OPJ_SIZE_T opj_read_from_buffer(void * p_buffer,
OPJ_SIZE_T p_nb_bytes, opj_buffer_info_t* p_source_buffer);
static OPJ_SIZE_T opj_write_from_buffer(void * p_buffer,
OPJ_SIZE_T p_nb_bytes, opj_buffer_info_t* p_source_buffer);
static OPJ_SIZE_T opj_skip_from_buffer(OPJ_SIZE_T p_nb_bytes,
opj_buffer_info_t * p_source_buffer);
static OPJ_BOOL opj_seek_from_buffer(OPJ_SIZE_T p_nb_bytes,
opj_buffer_info_t * p_source_buffer);
Reported by emd5174@psu.edu
on 2014-10-10 12:48:23
I thought I might add to make things clearer, is it alright to leave those mentioned
functions inside the JavaOpenJPEGDecoder.c/h files for the byte stream? I also added
the opj_buffer_info struct in the JavaOpenJPEGDecoder.h file that was used in Aaron
Boxer.
Reported by emd5174@psu.edu
on 2014-10-10 16:00:00
Here's an update to the byte stream implementation. There wasn't a lot of changes to
the code behavior for the byte stream (if any). All functions Aaron Boxer used for
the byte stream are fully implemented into the JavaOpenJPEGDecoder.h/c files. Cleaned
up some of the comments. Feel free to let me know if there's anything else I can do.
Reported by emd5174@psu.edu
on 2014-10-13 19:27:22
I was just checking in to see if there was an update for the patch. winfried and I have
done some patch updates to get this issue fixed, but I was hoping if anyone could check
in and give me an update on the patch progress.
Thanks,
Eric
Reported by emd5174@psu.edu
on 2014-10-22 13:47:05
Reported by detonin on 2014-10-22 23:04:20
Accepted
Thanks antonin for the update. I hope our patches makes this an easy implementation
for the trunk's wrapping code. My most recent patch (#14) just adds onto winfried's
patch with a simple compressed byte stream option for the JNI JavaDecoder.
Eric
Reported by emd5174@psu.edu
on 2014-10-27 18:15:18
Hello,
Just checking back to see if there was any patch updates for this issue.
I was hoping to know how long it might take to get this issue verified. I know it's
just the JNI bindings.
Thanks,
-Eric
Reported by emd5174@psu.edu
on 2014-11-12 21:44:44
I've reformatted the syntax so it would match up with what was in the trunk so the .patch
can make it easier to see what I've changed. I'v changed JavaOpenJPEGDecoder.c the
most, so it might be harder to see what I've changed. Also, I have made a github mirror
of OpenJPEG (https://github.com/emd5174/openjpeg/tree/jni). If you wish to do a comparison
of the most recent changes, https://github.com/emd5174/openjpeg/tree/jni).
-Eric
Reported by emd5174@psu.edu
on 2015-01-06 15:04:02
I've updated the github project, so the issue404.patch is now obsolete. To get the current
up to date patch https://github.com/emd5174/openjpeg/compare/jni (select the files
changed tab).
The only files that were changed from the master branch of OpenJPEG were /wrapping/java/openjp2/CMakeLists.txt
and /wrapping/java/openjp2/JavaOpenJPEGDecoder.c
and the /wrapping/java/openjp2/java-sources/org/openJpeg/OpenJPEGJavaDecoder.java class
(There are other files in that diff, but I added those extra files for my own uses.
OpenJPEG will not need them).
Reported by emd5174@psu.edu
on 2015-02-25 17:56:57
Also include /wrapping/java/openjp2/java_helpers.h in that diff.
Reported by emd5174@psu.edu
on 2015-02-25 18:07:52
Originally reported on Google Code with ID 404
Reported by
belkop43@students.rowan.edu
on 2014-09-22 12:17:54