Draft: Fix for handling total_pixels #4135
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Handling of the number of pixels in
ModularEncodefunctions is strange: being applied to a sequence of stream images like inModularFrameEncoder::ComputeTreeor to an individual image like in other cases, it overestimates the number of pixels processed due to special treatment of*total_pixels == 0case.If initially
total_pixels = 0then we have after the functiontotal_pixels = 2 * (number of pixels in the image)increased by this part andGatherTreeData, in any other case we havetotal_pixels += (number of pixels in the image)increased byGatherTreeData(modulo edge cases).It looks like that the intention was to not allow zero in the number of pixels as it crashes
LearnTreefunction. However, it can be done in a more straightforward way without pixel number overestimation.In my testing the proposed change also leads to a slightly better compression, of the order of$6\times10^{-3}$ %. However, some of the tests are failing due to increase of the file size, so I mark this as draft before I can find out the cause.
Pull Request Checklist
./ci.sh lintfor automatic code formatting.