Commit 158900c
[MSE] Decoding errors when appending segment with B-frames and previous segment ends with an I-frame
https://bugs.webkit.org/show_bug.cgi?id=272521
Reviewed by Xabier Rodriguez-Calvar.
When a segment containing B-frames is appended, WebKit has logic to erase frames from the previous segment
and avoid decoding glitches (219507@main). However, the current logic falls short in one edge case: if
the previous segment ends with an I-frame in the overlap region to be erased.
If the demuxer honors ISOBMFF edit lists, then the first I-frame from an incoming segment with B-frames
can be placed earlier in decoding order than the last (I-)frame from the previous segment
(potentially with different resolution), and that last I-frame doesn't get erased, and will be pushed for
decoding. This confuses the decoder and the following P/B frames will fail to decode or decode incorrectly
with artifacts due to missing/incorrect reference frame.
This patch fixes this edge case by allowing I-frames to be erased from the track buffer only if they
are presented earlier than the incoming I-frame. We remove frames from the track buffer until we find an
I-frame that is presented later than the incoming I-frame. This handles the case when we get multiple I-frames
in the overlapping area, as exercised in the layout test.
Credit to Vivek Arumugam <vivek_arumugam@comcast.com> for initially finding the bug and investigating this.
This patch builds on top of a patch he proposed. See #1301.
* LayoutTests/media/media-source/media-source-samples-out-of-order-erase-sync-frames-expected.txt: Added.
* LayoutTests/media/media-source/media-source-samples-out-of-order-erase-sync-frames.html: Added.
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::processMediaSample):
Canonical link: https://commits.webkit.org/277532@main1 parent 52ff406 commit 158900c
3 files changed
Lines changed: 88 additions & 4 deletions
File tree
- LayoutTests/media/media-source
- Source/WebCore/platform/graphics
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
959 | | - | |
| 959 | + | |
960 | 960 | | |
961 | 961 | | |
962 | | - | |
963 | | - | |
| 962 | + | |
| 963 | + | |
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
| |||
970 | 970 | | |
971 | 971 | | |
972 | 972 | | |
973 | | - | |
| 973 | + | |
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
977 | 980 | | |
978 | 981 | | |
979 | 982 | | |
| |||
0 commit comments