Skip to content

Commit 23700a8

Browse files
authored
Merge pull request #437 from w3c/videoframe_timestamp_fixes
Make VideoFrame.timestamp non-nullable.
2 parents 938df12 + 15183a6 commit 23700a8

File tree

1 file changed

+48
-23
lines changed

1 file changed

+48
-23
lines changed

index.src.html

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,7 @@
31793179
readonly attribute unsigned long displayWidth;
31803180
readonly attribute unsigned long displayHeight;
31813181
readonly attribute unsigned long long? duration; // microseconds
3182-
readonly attribute long long? timestamp; // microseconds
3182+
readonly attribute long long timestamp; // microseconds
31833183
readonly attribute VideoColorSpace colorSpace;
31843184

31853185
unsigned long allocationSize(
@@ -3503,6 +3503,13 @@
35033503
The {{VideoFrame/timestamp}} getter steps are to return
35043504
{{VideoFrame/[[timestamp]]}}.
35053505

3506+
NOTE: Authors are encouraged to provide a meaningful timestamp unless it is
3507+
implicitly provided by the {{CanvasImageSource}} at construction.
3508+
Interfaces that consume {{VideoFrame}}s can rely on this value for
3509+
timing decisions. For example, {{VideoEncoder}} can use
3510+
{{VideoFrame/timestamp}} values to guide rate control (see
3511+
{{VideoEncoderConfig/framerate}}).
3512+
35063513
: <dfn attribute for=VideoFrame>duration</dfn>
35073514
:: The presentation duration, given in microseconds. The duration is copied
35083515
from the {{EncodedVideoChunk}} corresponding to this VideoFrame.
@@ -3739,13 +3746,13 @@
37393746
algorithm with |init|, |frame|, |defaultVisibleRect|,
37403747
|defaultDisplayWidth|, and |defaultDisplayHeight|.
37413748
9. If {{VideoFrameInit/duration}} [=map/exists=] in |init|, assign it to
3742-
|frame|.{{VideoFrame/duration}}. Otherwise, assign
3749+
|frame|'s {{VideoFrame/[[duration]]}}. Otherwise, assign
37433750
|otherFrame|.{{VideoFrame/duration}} to
3744-
|frame|.{{VideoFrame/duration}}.
3751+
|frame|'s {{VideoFrame/[[duration]]}}.
37453752
10. If {{VideoFrameInit/timestamp}} [=map/exists=] in |init|, assign it to
3746-
|frame|.{{VideoFrame/timestamp}}. Otherwise, assign
3747-
|otherFrame|.{{VideoFrame/timestamp}} to
3748-
|frame|.{{VideoFrame/timestamp}}.
3753+
|frame|'s {{VideoFrame/[[timestamp]]}}. Otherwise, assign
3754+
|otherFrame|'s {{VideoFrame/timestamp}} to
3755+
|frame|'s {{VideoFrame/[[timestamp]]}}.
37493756
11. Assign |format| to |frame|.{{VideoFrame/[[format]]}}.
37503757

37513758
: <dfn for=VideoFrame>Initialize Frame With Resource and Size</dfn> (with
@@ -3769,9 +3776,9 @@
37693776
algorithm with |init|, |frame|, |defaultVisibleRect|, |width|, and
37703777
|height|.
37713778
11. Assign `init`.{{VideoFrameInit/duration}} to
3772-
|frame|.{{VideoFrame/duration}}.
3779+
|frame|'s {{VideoFrame/[[duration]]}}.
37733780
12. Assign `init`.{{VideoFrameInit/timestamp}} to
3774-
|frame|.{{VideoFrame/timestamp}}.
3781+
|frame|'s {{VideoFrame/[[timestamp]]}}.
37753782
13. If |resource| has a known {{VideoColorSpace}}, assign its value to
37763783
{{VideoFrame/[[color space]]}}.
37773784
14. Otherwise, assign a new {{VideoColorSpace}}, constructed with an empty
@@ -4987,11 +4994,20 @@
49874994
11. Let |decodeResult| be a new {{ImageDecodeResult}} initialized as
49884995
follows:
49894996
1. Assign 'true' to {{ImageDecodeResult/complete}}.
4990-
2. Let |timestamp| and |duration| be the presentation timestamp and
4991-
duration for |output| as described by |encodedFrame|. If
4992-
|encodedFrame| does not describe a timestamp or
4993-
duration, assign `null` to the corresponding variable.
4994-
3. Assign {{ImageDecodeResult/image}} with the result of running the
4997+
2. Let |duration| be the presentation duration for |output| as
4998+
described by |encodedFrame|. If |encodedFrame| does not have a
4999+
duration, assign `null` to |duration|.
5000+
3. Let |timestamp| be the presentation timestamp for |output| as
5001+
described by |encodedFrame|. If |encodedFrame| does not have a
5002+
timestamp:
5003+
1. If |encodedFrame| is a still image assign `0` to |timestamp|.
5004+
2. If |encodedFrame| is a constant rate animated image and
5005+
|duration| is not `null`, assign `|frameIndex| * |duration|` to
5006+
|timestamp|.
5007+
3. If a |timestamp| can otherwise be trivially generated from
5008+
metadata without further decoding, assign that to |timestamp|.
5009+
4. Otherwise, assign `0` to |timestamp|.
5010+
4. Assign {{ImageDecodeResult/image}} with the result of running the
49955011
[=Create a VideoFrame=] algorithm with |output|, |timestamp|, and
49965012
|duration|.
49975013
12. Run the [=ImageDecoder/Resolve Decode=] algorithm with |promise| and
@@ -5044,15 +5060,24 @@
50445060
for |output|.
50455061
3. Add a new entry to {{ImageDecoder/[[progressive frame
50465062
generations]]}} with key |frameIndex| and value |frameGeneration|.
5047-
15. Let |timestamp| and |duration| be the presentation timestamp and
5048-
duration for |output| as described by |encodedFrame|. If
5049-
|encodedFrame| does not describe a timestamp or
5050-
duration, assign `null` to the corresponding variable.
5051-
16. Assign {{ImageDecodeResult/image}} with the result of running the
5052-
[=Create a VideoFrame=] algorithm with |output|, |timestamp|, and
5053-
|duration|.
5054-
17. Remove |promise| from {{ImageDecoder/[[pending decode promises]]}}.
5055-
18. Resolve |promise| with |decodeResult|.
5063+
15. Let |duration| be the presentation duration for |output| as
5064+
described by |encodedFrame|. If |encodedFrame| does not describe a
5065+
duration, assign `null` to |duration|.
5066+
16. Let |timestamp| be the presentation timestamp for |output| as
5067+
described by |encodedFrame|. If |encodedFrame| does not have a
5068+
timestamp:
5069+
1. If |encodedFrame| is a still image assign `0` to |timestamp|.
5070+
2. If |encodedFrame| is a constant rate animated image and
5071+
|duration| is not `null`, assign `|frameIndex| * |duration|` to
5072+
|timestamp|.
5073+
3. If a |timestamp| can otherwise be trivially generated from
5074+
metadata without further decoding, assign that to |timestamp|.
5075+
4. Otherwise, assign `0` to |timestamp|.
5076+
17. Assign {{ImageDecodeResult/image}} with the result of running the
5077+
[=Create a VideoFrame=] algorithm with |output|, |timestamp|, and
5078+
|duration|.
5079+
18. Remove |promise| from {{ImageDecoder/[[pending decode promises]]}}.
5080+
19. Resolve |promise| with |decodeResult|.
50565081

50575082
: <dfn for=ImageDecoder>Resolve Decode</dfn> (with |promise| and |result|)
50585083
:: 1. [=Queue a task=] to perform these steps:
@@ -5138,7 +5163,7 @@
51385163
6. Return `true`.
51395164

51405165
A <dfn>valid image MIME type</dfn> is a string that is a [=valid MIME type
5141-
string=] and for which the `type`, per Section 3.1.1.1 of [[RFC9110]], is
5166+
string=] and for which the `type`, per Section 8.3.1 of [[RFC9110]], is
51425167
`image`.
51435168

51445169
: <dfn dict-member for=ImageDecoderInit>type</dfn>

0 commit comments

Comments
 (0)