Repository navigation
decoder: Clear the mismatch control flag in MPEG-1 inverse quantization - #39
Merged
Merged
Conversation
The I, P and B picture reconstruction selects the IDCT with pf_idct_recon[idx * 2 + i4_last_value_one]. impeg2d_vld_inv_quant_mpeg2() sets i4_last_value_one for every block, but impeg2d_vld_inv_quant_mpeg1() never touches it, and neither IVD_CMD_CTL_RESET nor the MPEG-1 initialization clears it. After an MPEG-2 stream whose last block left it at 1, an MPEG-1 stream decoded after a reset was reconstructed with the mismatch control IDCT, and its pictures differed from those of a new decoder. MPEG-1 has no mismatch control, so set the flag to 0 in impeg2d_vld_inv_quant_mpeg1().
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
harishdm
approved these changes
Nov 20, 2026
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.
The I, P and B picture reconstruction selects the IDCT with
pf_idct_recon[idx * 2 + i4_last_value_one].impeg2d_vld_inv_quant_mpeg2()setsi4_last_value_onefor every block (mismatch control), butimpeg2d_vld_inv_quant_mpeg1()never touches it, and neitherIVD_CMD_CTL_RESETnor the MPEG-1 initialization clears it. A new decoder has it at 0.So when the last block of an MPEG-2 stream leaves it at 1, an MPEG-1 stream decoded after a reset is reconstructed with the mismatch control IDCT: in our test, 5 of the 8 output pictures of an MPEG-1 stream differed from those of a new decoder.
MPEG-1 has no mismatch control, so this change sets the flag to 0 in
impeg2d_vld_inv_quant_mpeg1().Tested on
main(275c536) with clang 21 and AddressSanitizer: after an interlaced MPEG-2 stream and a reset, the MPEG-1 stream now decodes to the same pictures as on a new decoder. The program and the streams are in this gist: https://gist.github.com/GeekQAQ/733c6bb6a114008b275e9246a6d2329d The default CMake build (Release, gcc and clang) has no new warnings, andmpeg2decgives byte-identical output before and after the change on 16 short test streams with 1 core, and with 4 cores except for a stream that starts with a B picture, whose 4-core output already varies from run to run onmain(a separate issue, sent as its own PR).