team-charls/charls

The expectedLength in JpegLsEncodeStream means?

SteveTsg opened this issue · 4 comments

I wish to add a function to encoderaw use JpegLsEncodeStream,but I dont understand the parameter expectedLength A little help please

Hi @SteveTsg,

Your Question is not clear to me. Could you provide a code example?

Note: JpegLsEncodeStream is a legacy function and on the list to be removed.

void TestEncodeFromStream(const char* file, const int offset, const int width, const int height, const int bpp, const int componentCount, const interleave_mode ilv, const size_t expectedLength)

Thank you @vbaderks
I write a function, try to encode raw by JpegLsEncodeStream in line 346 in test/main.cpp. But I could not understand the line347

Assert::IsTrue(bytesWritten == expectedLength);
why should I give a expectedLength first? Thanks again

JpegLsEncodeStream is a legacy function and on the list to be removed.

So we will get a new function to encode raw in the future? Or adjust the structure to make code clear?

TestEncodeFromStream is a unit test function, expectedLength is used to test that the created encoded output has the correct size. In normal code there is no need for it.

JpegLsEncodeStream operates on a C++ stream interface, it will be replaced by a callback function pointer. The recommendation is to just read "raw" bytes into a buffer and call the modern C++ public classes. See examples in:
https://github.com/team-charls/charls/wiki/How-to-use-the-API

Got it!Thanks a lot