-
Notifications
You must be signed in to change notification settings - Fork 0
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
Avoid floating point arithmetic when calculating time replacement #1
Conversation
The current code essentially does this timeReplacement = (startTime / timescale + ...) * timescale When timescale is large enough (e.g. 10 MHz in order to support MS Smooth Streaming as well), "startTime / timescale * timescale" may not always be exactly "startTime" because of floating point precision, which could produce incorrect segment URLs. Keep startTime unchanged in the timeline just to avoid the multiply/divide dance.
@@ -269,8 +269,12 @@ shaka.dash.MpdUtils.createTimeline = function( | |||
|
|||
for (var j = 0; j <= repeat; ++j) { | |||
var endTime = startTime + d; | |||
timeline.push( | |||
{start: (startTime / timescale), end: (endTime / timescale)}); | |||
item = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add var item = {
in here, rebuild Shaka player with your code and it works fine. I test without your code, the issue appears again. Thanks @duynguyen-ew . How can we propose your change to apply in Shaka player repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the var
part is important. Otherwise you'll be creating a global variable.
I think this looks nice, except that there is a potential issue with floating point accuracy from the presentationTimeOffset as well (we use zero, but for multiperiod, we may need other values). To get the code accepted, the best is to
I can help out with creating the issue. It might help since I've relationship with the main developer since before. |
I looked a bit more at the file |
Thanks @TobbeEdgeware . @PhamCongDuc I'll leave it to you to handle the rest with help from @TobbeEdgeware. You should also make sure that it does fix the problems for TVB or we're just wasting time fixing something else. |
I've made a shaka player issue shaka-project#690 and we'll wait for response on whether they are open to pull request. If they are positive, we may need to improve the fix to include presentationTimeOffset and possibly tests. I'll be back to you @duynguyen-ew in that case. @PhamCongDuc On the TVB side, it would be good if you use your own patched version for the moment. In any case, it will take some time until this is included in a shaka-player release. |
Thanks @duynguyen-ew , @TobbeEdgeware . I ran Skaka auto tests, nothing failed |
We got an answer to google#690 that they are positive to a patch. I think one should check that all of "startTime", "endTime", and "presentationTimeOffset" are handled exactly, and not just "startTime". Will you make one from Vietnam (with an github account Edgeware email address)? |
Yes. I'm doing that (checking presentationTimeOffset) and will check endTime. I sent you a message on Slack. |
Closing as #2 covers it too |
The current code essentially does this
When timescale is large enough (e.g. 10 MHz in order to support MS Smooth Streaming as well), "startTime / timescale * timescale" may not always be exactly "startTime" because of floating point precision, which could produce incorrect segment URLs.
Keep startTime unchanged in the timeline just to avoid the multiply/divide dance.
@TobbeEdgeware and @PhamCongDuc this is SHIELD-1235. The code is not exactly pretty, but I want to make sure I get the logic right before worrying about where to save "unscaledStart"