Skip to content

Commit 80f011b

Browse files
committed
Add orientation metadata to VideoDecoderConfig, update algorithms
As proposed on the issue and discussed in WG, this does the following: - Adds rotation/flip fields to VideoDecoderConfig. - Updates the "Create a VideoFrame" algorithm used by the video and image decoders to accept these fields. - Updates the video and image decoding algorithms to provide these fields during decoding. Bug: #351
1 parent b9a8e34 commit 80f011b

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

index.src.html

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,13 @@
922922
5. If {{VideoDecoderConfig/colorSpace}} [=map/exists=] in the
923923
{{VideoDecoder/[[active decoder config]]}}, assign its value to
924924
|colorSpace|.
925-
6. Let |frame| be the result of running the [=Create a VideoFrame=]
925+
6. Assign the values of {{VideoDecoderConfig/rotation}} and
926+
{{VideoDecoderConfig/flip}} to |rotation| and |flip| respectively.
927+
7. Let |frame| be the result of running the [=Create a VideoFrame=]
926928
algorithm with |output|, |timestamp|, |duration|,
927-
|displayAspectWidth|, |displayAspectHeight|, and |colorSpace|.
928-
7. Invoke {{VideoDecoder/[[output callback]]}} with |frame|.
929+
|displayAspectWidth|, |displayAspectHeight|, |colorSpace|,
930+
|rotation|, and |flip|.
931+
8. Invoke {{VideoDecoder/[[output callback]]}} with |frame|.
929932
</dd>
930933
<dt><dfn>Reset VideoDecoder</dfn> (with |exception|)</dt>
931934
<dd>
@@ -1970,6 +1973,8 @@
19701973
VideoColorSpaceInit colorSpace;
19711974
HardwareAcceleration hardwareAcceleration = "no-preference";
19721975
boolean optimizeForLatency;
1976+
double rotation = 0;
1977+
boolean flip = false;
19731978
};
19741979
</xmp>
19751980

@@ -2059,6 +2064,14 @@
20592064
bitstreams require a minimum number of inputs before any output can be
20602065
produced.
20612066
</dd>
2067+
<dt><dfn dict-member for=VideoDecoderConfig>rotation</dfn></dt>
2068+
<dd>
2069+
Sets the {{VideoFrame/rotation}} attribute on decoded frames.
2070+
</dd>
2071+
<dt><dfn dict-member for=VideoDecoderConfig>flip</dfn></dt>
2072+
<dd>
2073+
Sets the {{VideoFrame/flip}} attribute on decoded frames.
2074+
</dd>
20622075
</dl>
20632076

20642077

@@ -3910,7 +3923,7 @@
39103923
with {{VideoFrame/[[metadata]]}}.
39113924

39123925
### Algorithms ###{#videoframe-algorithms}
3913-
: <dfn>Create a VideoFrame</dfn> (with |output|, |timestamp|, |duration|, |displayAspectWidth|, |displayAspectHeight|, and |colorSpace|)
3926+
: <dfn>Create a VideoFrame</dfn> (with |output|, |timestamp|, |duration|, |displayAspectWidth|, |displayAspectHeight|, |colorSpace|, |rotation|, and |flip|)
39143927
:: 1. Let |frame| be a new {{VideoFrame}}, constructed as follows:
39153928
1. Assign `false` to {{platform object/[[Detached]]}}.
39163929
2. Let |resource| be the [=media resource=] described by |output|.
@@ -3940,6 +3953,8 @@
39403953
11. Assign {{VideoFrame/[[color space]]}} with the result of running the
39413954
[=VideoFrame/Pick Color Space=] algorithm, with |colorSpace| and
39423955
{{VideoFrame/[[format]]}}.
3956+
12. Assign {{VideoFrame/rotation}} and {{VideoFrame/flip}} to |rotation|
3957+
and |flip| respectively.
39433958
2. Return |frame|.
39443959

39453960

@@ -5742,9 +5757,11 @@
57425757
3. If a |timestamp| can otherwise be trivially generated from
57435758
metadata without further decoding, assign that to |timestamp|.
57445759
4. Otherwise, assign `0` to |timestamp|.
5745-
4. Assign {{ImageDecodeResult/image}} with the result of running the
5746-
[=Create a VideoFrame=] algorithm with |output|, |timestamp|, and
5747-
|duration|.
5760+
4. If {{ImageDecoder/[[encoded data]]}} contains orientation metadata
5761+
describe it as |rotation| and |flip|.
5762+
5. Assign {{ImageDecodeResult/image}} with the result of running the
5763+
[=Create a VideoFrame=] algorithm with |output|, |timestamp|,
5764+
|duration|, |rotation|, and |flip|.
57485765
12. Run the [=ImageDecoder/Resolve Decode=] algorithm with |promise| and
57495766
|decodeResult|.
57505767

@@ -5808,11 +5825,13 @@
58085825
3. If a |timestamp| can otherwise be trivially generated from
58095826
metadata without further decoding, assign that to |timestamp|.
58105827
4. Otherwise, assign `0` to |timestamp|.
5811-
17. Assign {{ImageDecodeResult/image}} with the result of running the
5812-
[=Create a VideoFrame=] algorithm with |output|, |timestamp|, and
5813-
|duration|.
5814-
18. Remove |promise| from {{ImageDecoder/[[pending decode promises]]}}.
5815-
19. Resolve |promise| with |decodeResult|.
5828+
17. If {{ImageDecoder/[[encoded data]]}} contains orientation metadata
5829+
describe it as |rotation| and |flip|.
5830+
18. Assign {{ImageDecodeResult/image}} with the result of running the
5831+
[=Create a VideoFrame=] algorithm with |output|, |timestamp|,
5832+
|duration|, |rotation|, and |flip|.
5833+
19. Remove |promise| from {{ImageDecoder/[[pending decode promises]]}}.
5834+
20. Resolve |promise| with |decodeResult|.
58165835

58175836
: <dfn for=ImageDecoder>Resolve Decode</dfn> (with |promise| and |result|)
58185837
:: 1. [=Queue a task=] to perform these steps:

0 commit comments

Comments
 (0)