Allow DC coefficient differences beyond 16 bits and validate the reconstructed value - #268
Merged
Conversation
…nstructed value Signed-off-by: KP Choi <kp5.choi@samsung.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #254.
DC coefficients are in
[-32768, 32767], so the difference between two neighboring blocks can legally reach 65535. RFC 9924 places the range constraint on the reconstructed coefficient, not on the difference, and the encoder writes such differences without any bound. The decoder rejected them, so it failed to decode conforming streams produced by its own encoder — 12-bit at QP 0-4, and any bit depth with a custom quantization matrix.oapvd_vlc_dc_coef(): raise theabs_dc_difflimit from 32767 to 65535, and apply the sign withoapv_set_sign()instead of the misleadingly namedoapv_set_sign16()(both operate onint, so this is a rename, not a behavior change).dec_block(): compute the predicted DC inintand validate it againstMIN_TX_VAL/MAX_TX_VALbefore storing to thes16coefficient buffer. This is where the range constraint belongs, and it also closes a pre-existing overflow: the old code summed twointvalues into ans16with no check, so a value up to 65534 could wrap silently.