Skip to content

Commit

Permalink
fix(Subtitles): Prevent rounding errors when filtering duplicated cues (
Browse files Browse the repository at this point in the history
#8018)

Related to #6773
  • Loading branch information
tykus160 authored Feb 5, 2025
1 parent ece88d6 commit 24283e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/text/cue.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,12 @@ shaka.text.Cue = class {
// performance optimization. We can avoid the more expensive recursive
// checks if the top-level properties don't match.
// See: https://github.com/shaka-project/shaka-player/issues/3018
if (cue1.startTime != cue2.startTime || cue1.endTime != cue2.endTime ||
cue1.payload != cue2.payload) {
if (cue1.payload != cue2.payload) {
return false;
}
const isDiffNegligible = (a, b) => Math.abs(a - b) < 0.001;
if (!isDiffNegligible(cue1.startTime, cue2.startTime) ||
!isDiffNegligible(cue1.endTime, cue2.endTime)) {
return false;
}
for (const k in cue1) {
Expand Down

0 comments on commit 24283e6

Please sign in to comment.