Skip to content
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

Fix glitches that sometimes happen near the scene changes. #3707

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

tyan0
Copy link
Contributor

@tyan0 tyan0 commented Dec 6, 2023

Since the first time I used the openh264 decoder, I have encountered glitches that sometimes happen near the scene changes. I looked into this problem and found two causes.

  1. Lack of necessary code which sets m_sReoderingStatus.iLastWrittenPOC.
  2. Overwrite frame buffer occasionally happens at GOP change.

This issue happens frequently enough to frustrate me. I wonder why the other users have not pointed this problem out till today.

This pull request provides two commits corresponding to each problem.

In CWelsDecoder::ReorderPicturesInDisplay(), iLastWrittenPOC was
not set in unbuffered-reordering case. Due to this problem, it
sometimes reordered the frames incorrectly. This patch fixes the
issue.
When bNewSeqBegin got true, iRefCount was forcibly reset even if the
buffer was still used for reordering. Due to this problem, the buffer
in use was sometimes overwritten with newly decoded frame. This commit
is for fixing that problem.
@tyan0
Copy link
Contributor Author

tyan0 commented Dec 7, 2023

If it is better to provide sample video file with the glitch, I am ready to do that.

@tyan0
Copy link
Contributor Author

tyan0 commented Dec 8, 2023

Please reproduce the glitch (2) using the sample video file:
https://tyan0.yr32.net/openh264/glitch_at_GOP_change.mp4

The glitch will occur at about 12 sec. point from the begining.

@tyan0 tyan0 changed the title Glitches that sometimes happen near the scene changes. Fix glitches that sometimes happen near the scene changes. Dec 9, 2023
@BenzhengZhang
Copy link
Collaborator

@tyan0 CI failed.

@tyan0
Copy link
Contributor Author

tyan0 commented Dec 12, 2023

Thanks for checking. I have fixed that problem. Could you please rerun CI?

@tyan0 tyan0 force-pushed the master branch 4 times, most recently from f82abc0 to c947a4c Compare December 13, 2023 17:06
@tyan0 tyan0 marked this pull request as draft December 14, 2023 06:42
@tyan0 tyan0 marked this pull request as ready for review December 14, 2023 06:42
@tyan0 tyan0 marked this pull request as draft December 17, 2023 03:21
@tyan0 tyan0 marked this pull request as ready for review December 17, 2023 03:22
@tyan0 tyan0 marked this pull request as draft December 17, 2023 05:20
@tyan0 tyan0 marked this pull request as ready for review December 17, 2023 06:00
@tyan0 tyan0 marked this pull request as draft December 17, 2023 12:30
@tyan0 tyan0 marked this pull request as ready for review December 17, 2023 12:33
@tyan0
Copy link
Contributor Author

tyan0 commented Dec 17, 2023

I revised the pull request several times. Now I am almost sure that this is the final change. Please review. Thanks.

@tyan0
Copy link
Contributor Author

tyan0 commented Dec 18, 2023

I found another problem of the current openh264 code regarding scene change.

  1. When more than 2 frame sequences exist in the reordering buffer, the reordering does not work correctly.

This causes when multiple scene canges happen in a very short time. I would like to add new commit for that problem.

@tyan0 tyan0 marked this pull request as draft December 18, 2023 00:04
@tyan0 tyan0 marked this pull request as ready for review December 19, 2023 01:00
@tyan0
Copy link
Contributor Author

tyan0 commented Dec 19, 2023

Done. Please review.

Previously, when more than 2 frame sequences exist in the reordering
buffer, the reordering does not work correctly. This is because the
management based on bLastGOP flag does not work in this case.
Instead, this patch introduces frame sequence number (iSeqNum) to
distingish frames belonging to each sequence and drops bLastGOP flag.
@tyan0
Copy link
Contributor Author

tyan0 commented Dec 19, 2023

Fix typo in commit message.

@BenzhengZhang
Copy link
Collaborator

Thanks for the fix @tyan0

@BenzhengZhang BenzhengZhang merged commit 4f01c15 into cisco:master Jan 19, 2024
8 checks passed
@tyan0
Copy link
Contributor Author

tyan0 commented Jan 19, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants