-
Notifications
You must be signed in to change notification settings - Fork 454
Separate chunk decoding and image decoding & inflation #206
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
base: master
Are you sure you want to change the base?
Conversation
Makes 2 new functions, public lodepng_decode_chunks and static inflateIdat and reimplements decodeGeneric by calling them. This lets applications get info about the file before deciding how they want to inflate the data.
for cICP and eXIf chunk support.
for renaming of mDCv to mDCV and cLLi to cLLI.
ba3f0a1 to
cf91269
Compare
|
@lvandeve are you likely to merge this? If there is no chance, tell me as there is then no point in spending more time resolving conflicts from updates to master. |
|
This would be useful for me. +1 |
|
Did you run the unit test on your changes? It is crashing with a double free. |
* Freeing already freed memory due to calling inflateIdat even when lodepng_decode_chunks has set error state. * Crash due to zlib decompressor zlib decompressor checking incoming size and, if > 2, accessing the data pointer even if its null. Fixed by initializing the size to 0 too.
cf91269 to
51e3ce7
Compare
I had not. When I submitted the PR I expected there would be CI to do so. After I realized there was not, I was distracted by other things. Thanks for reported the problem. I've fixed the problems (there were tow both resulting from deliberately broken PNG files) in the commits I've just pushed. In order to debug these problems I needed an Xcode project. The fastest way for me to make one was to set up a CMake build. I've submitted that along with a CI workflow in PR #212. |
|
Your changes leak memory now. Please run: This will show you the places where you are allocating memory that is not being freed. |
51e3ce7 to
4c69ef7
Compare
|
I fixed the leaks. Thanks for the heads-up.
Given that, I am surprised there is even a Brew package. I used Xcode's Instruments to find the location of the two leaks. That was only 10% of the investigation though. Since the leaks happened only once in a run of |
4c69ef7 to
186cd78
Compare
|
I just pushed a fix for a warning from MSVC about a "use of a potentially uninitialized variable". The warning was bogus but I can see why the compiler thought it might be a problem.. Would be nice to have PR #212 merged so I can rebase this to include it leading to the workflow being run and such warnings being spotted here. |
These changes make it possible for the user to first decode all of the chunks, to learn all the details of the image in the file, then decompress, and possibly convert, the image data to the desired format.
My use case is creating KTX containers for GPU textures where, typically, we want to read the image as is, i.e what the hidden
decodeGenericfunction does. In the API prior to this change we had toWith this change:
lodepng_decode_chunks.lodepng_finish_decodeto decode the image into the desired format.The multi-format image file input library I use has the model of providing all the information about the image data to the application which then decides on decoding and conversion. I know of other libraries, e.g. OpenImageIO, which use the same model. This change makes use in such a library much easier.
Change Details:
decodeGenericfunction into the public lodepng_decode_chunks and static inflateIdat.1uconstants to1ull.The warning fixes were made before I updated the code to LodePNG version 20241228. It is possible the disables are no longer needed. IIRC the 20241228 version has an alternate fix for the last warning: casts instead of my
1ull. I changed my fixes to use the casts but I think1ullis better.