Repository navigation
|
First of all, thank you for this codec implementation: we are using it on imaging data with very good results. I wanted to ask, is there a method provided here to determine the size for a "big enough buffer" to encode an image? It would be very helpful to only preallocate one large buffer once and then write the encoded bytes on it (we call this library from garbage collected languages, i.e., Python and Julia, so allocating data once from the host language seems safer). ContextWe aim to call this library on in-memory data (specifically, Python or Julia), using the guidelines from #164, in particular writing directly on a preallocated buffer via the technique explained in #164 (comment) deriving a class from Ideally, we would like to preallocate all the output data at once directly from Python / Julia, and follow this strategy:
However, we couldn't find an upper bound for the encoded size of the image. |
Replies: 1 comment 1 reply
|
Hi Pietro, I am happy to hear that you find the code useful. I think the you want to know the absolute maximum upper size of the compressed file, assuming lossless compression. where The factor The only issue with this arrangement is that the allocated memory will be large, but if you are happy with this, you can use this approach. At some point in the future, we will introduce rate-control, where you can set the maximum size of the compressed image, but with rate-control, image encoding will be slower than without it. Hope this helps. Let me know if you have further question. Kind regards, |
Hi Pietro,
I am happy to hear that you find the code useful.
Sorry for the late reply.
I think the you want to know the absolute maximum upper size of the compressed file, assuming lossless compression.$X$ components. The total size, in bytes, would be
Let's say that the file has
where$W_1$ is the width of the first component, $H_1$ is the height of the first component and $b_1$ is the bit depth of the first component (bit depth includes the sign bit, as is normally done in this context).
The factor$\alpha$ depends on the type of…