w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.

Home Page:https://w3c.github.io/webcodecs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rounding direction for `AudioData.duration`

padenot opened this issue · comments

See https://w3c.github.io/webcodecs/#ref-for-dom-audiodata-duration%E2%91%A1

Does this round or floor or ceil? If I follow Chromium's code correctly, it simply casts the double to an integer, resulting in a generally floored value. I think this is fine (it's bound to be losing precision anyway), but maybe we should spec it.

This is a fair point; we went with an integer time representation because that was the most straightforward to guarantee round-tripping timestamps to whatever storage format an implementation is using. It's an oddball format, so we had better be making the most of it.

I agree that it probably doesn't matter which way we go, both flooring and rounding should be straightforward for implementations to compute exactly.

I have a slight preference for round since it is a bit more accurate, but truncation may be what people expect?