Commit 042c5d1
committed
[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 efc4d3d commit 042c5d1
3 files changed
Lines changed: 89 additions & 5 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 | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
936 | | - | |
| 936 | + | |
937 | 937 | | |
938 | 938 | | |
939 | | - | |
940 | | - | |
| 939 | + | |
| 940 | + | |
941 | 941 | | |
942 | 942 | | |
943 | 943 | | |
| |||
947 | 947 | | |
948 | 948 | | |
949 | 949 | | |
950 | | - | |
| 950 | + | |
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
954 | | - | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
955 | 958 | | |
956 | 959 | | |
957 | 960 | | |
| |||
0 commit comments