-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.3.0 API #10
Conversation
The file pointer needs to be reset before initializing the stream. Before this fix, compiling with `DEBUG=1` would lead to a crash on any attempt to transcode files.
With the v0.3.0 API changes, we seem to be hitting the limits of how many directly allocated `ByteBuffer`s one can work with in a single JVM. This moves the largest file first in the test sequence so we can deal with allocation issues sooner.
They eat up memory and make everything sad...
@melissalinkert should have a look at see what she thinks of the new API. Is there a particular reason the ByteBuffer tests were disabled in dcf512a, @jballanc? |
Yes, One option would be to change the API specifically for I asked @melissalinkert if support for |
Assert.assertEquals(md5, md5(destination)); | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a TestNG annotation here and comment as disabled for now or adjust the test cases to re-use a ByteBuffer if it's a memory issue we're running into.
@@ -3,6 +3,19 @@ | |||
|
|||
<suite name="ome.jxrlib"> | |||
|
|||
<test name="FL_3channel_noZ_compression_lossless"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason this was moved up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the largest of the test files, so moving it was moved up in the hope that (combined with the buffer reallocation workaround in e29028c) running it first would avoid the issues with ByteBuffer
s. (This worked on my machine, but apparently not on Travis.)
I can't see a reason not to just make it work by adjusting the test cases. We know the size of the required buffers as well based on the test case fixture data being passed in and we can pre-allocate, pass in and/or reuse the buffer as required by setting the TestNG scope. |
We could certainly re-jigger the tests to avoid excessive Or, rather, it's not necessary to use |
They're not really a work around but rather an alternative. The first thing I would try to allocate the buffers ahead of time in the test case itself and utilise TestNG scoping to ensure that they are not destroyed. |
This commit includes the Doxygen configuration, a `make` target to generate docs, and documentation for most of the classes.
This commit includes documentation comments for `ImageEncoder`, `ImageMetadata`, `Resolution`, and `Stream`.
For whatever reason it seems that passing object references causes crashes when using Java `ByteBuffer`s to pass image data. Reverting this back to pass pointers.
This reverts commit e29028c.
This reverts commit fe6b4dd.
This reverts commit dcf512a.
4c4c0c2
to
317c511
Compare
Two things, @jballanc:
|
Java API looks good in general. I could see it being useful to have something like Otherwise, I think it would be good to do a little more bounds checking in the |
This is the first step of refactoring the C++ and Java APIs so that they are more consistent. On the C++ side, input buffers are always `unsigned char` and instead of multiple overloads, optional offsets are represented as optional parameters. This does necessitate rearranging parameter order on some methods, so all methods were re-arranged so that offsets and lengths appear at the end of the parameter list. On the Java side, instead of relying on the built-in SWIG mechanisms for passing NIO Buffers and `byte[]` across the JNI bridge, we have copied the definitions into our `JXR.i` definitions and changed the `byte[]` implementation to pass across as `unsigned char *`. This allows us to use the same C++ methods for both, though due to limitations with SWIG auto-generation, we need to use the `%rename` directive to prevent definitions from replacing each other. This results in a new set of more descriptive method names.
This change brings the header doc comments back in line with the actual parameter lists for DecodeContext's methods that were changed in the last commit.
With this set of changes, we should have the final version of the API that we want for AbstractDecode, including congruent methods to decode either `byte[]`s or `ByteBuffer`s with an offset and length.
These methods gave the API just a bit *too much* surface area. For now, if a user needs a `byte[]` from the decoded image, they can use the methods that return `byte[]` and if they need to write into an array at an offset they can use the methods that write to `ByteBuffer`s. (Really, we just don't have sufficient testing around passing `byte[]`s across the SWIG/JNI bridge as out parameters.)
With the finished `AbstractDecode`/`Decode` API, we no longer need mappings to the lower-level C++ APIs. Not to mention that, due to issues with pointer lifetimes, we cannot guarantee their use from Java is safe.
Closing as discussed in the context of upcoming work on #32. |
Updated API for v0.3.0 that allows for efficient single-call decode of byte arrays or files to either a pre-allocated
ByteBuffer
or returned as a byte array.