openjpeg icon indicating copy to clipboard operation
openjpeg copied to clipboard

Buffer-based streams.

Open thinkoid opened this issue 5 years ago • 3 comments

This existed previously as #583 and stayed here for a number of years. If there is still interest in it, here it is, in one commit.

I left the management of the buffer memory to the user instead of hooking it up in the logic of opj_stream_destroy. Make sure you dispose of the memory the library allocates during compression.

thinkoid avatar Sep 09 '19 16:09 thinkoid

I don't think the opj_buffer_info structure should be exposed in openjpeg.h, in particular because the use of the cur pointer is purely an implementation detail of openjpeg. And for the sake of const correctness, we should probably distinguish the input and output cases

So the API should rather be

OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_input_stream_from_buffer (const void*, size_t);

OPJ_API opj_stream_t* OPJ_CALLCONV
opj_stream_create_output_stream_from_buffer (void*, size_t);

Some testing of this implementation might be welcome as well. The CI also complains about code formatting

rouault avatar Nov 17 '19 02:11 rouault

Any plan to get this PR merged into master?

nickdademo avatar Jul 24 '20 02:07 nickdademo

Is there any chance to have this change merged ? We're using openjpeg in pdf.js (the Firefox' pdf viewer) and I had to add a slightly modified version of this patch: https://github.com/mozilla/pdf.js.openjpeg

calixteman avatar Apr 16 '24 12:04 calixteman