Skip to content

Commit

Permalink
Merge pull request #835 from Djuffin/color
Browse files Browse the repository at this point in the history
Convert PredefinedColorSpace to VideoColorSpace
  • Loading branch information
Djuffin authored Oct 4, 2024
2 parents 2c47490 + 737c7a2 commit 4bea332
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions index.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,25 @@
alpha channel is present.

: <dfn>sRGB Color Space</dfn>
:: A {{VideoColorSpaceInit}} containing «[
"primaries" → {{VideoColorPrimaries/bt709}},
"transfer" → {{VideoTransferCharacteristics/iec61966-2-1}},
"matrix" → {{VideoMatrixCoefficients/rgb}},
"fullRange" → `true`]».
:: A {{VideoColorSpace}} object, initialized as follows:
1. {{VideoColorSpace/[[primaries]]}} is set to {{VideoColorPrimaries/bt709}},
2. {{VideoColorSpace/[[transfer]]}} is set to {{VideoTransferCharacteristics/iec61966-2-1}},
3. {{VideoColorSpace/[[matrix]]}} is set to {{VideoMatrixCoefficients/rgb}},
4. {{VideoColorSpace/[[full range]]}} is set to `true`

: <dfn>Display P3 Color Space</dfn>
:: A {{VideoColorSpace}} object, initialized as follows:
1. {{VideoColorSpace/[[primaries]]}} is set to {{VideoColorPrimaries/smpte432}},
2. {{VideoColorSpace/[[transfer]]}} is set to {{VideoTransferCharacteristics/iec61966-2-1}},
3. {{VideoColorSpace/[[matrix]]}} is set to {{VideoMatrixCoefficients/rgb}},
4. {{VideoColorSpace/[[full range]]}} is set to `true`

: <dfn>REC709 Color Space</dfn>
:: A {{VideoColorSpaceInit}} containing «[
"primaries" → {{VideoColorPrimaries/bt709}},
"transfer" → {{VideoTransferCharacteristics/bt709}},
"matrix" → {{VideoMatrixCoefficients/bt709}},
"fullRange" → `false`]».
:: A {{VideoColorSpace}} object, initialized as follows:
1. {{VideoColorSpace/[[primaries]]}} is set to {{VideoColorPrimaries/bt709}},
2. {{VideoColorSpace/[[transfer]]}} is set to {{VideoTransferCharacteristics/bt709}},
3. {{VideoColorSpace/[[matrix]]}} is set to {{VideoMatrixCoefficients/bt709}},
4. {{VideoColorSpace/[[full range]]}} is set to `false`

: <dfn lt="saturated">Codec Saturation</dfn>
:: The state of an underlying codec implementation where the number of active
Expand Down Expand Up @@ -3696,7 +3703,7 @@
:: The presentation timestamp, given in microseconds. For decode,
timestamp is copied from the {{EncodedVideoChunk}} corresponding
to this {{VideoFrame}}. For encode, timestamp is copied to the
{{EncodedVideoChunk}}s corresponding to this {{VideoFrame}}.
{{EncodedVideoChunk}}s corresponding to this {{VideoFrame}}.

The {{VideoFrame/timestamp}} getter steps are to return
{{VideoFrame/[[timestamp]]}}.
Expand Down Expand Up @@ -4205,6 +4212,13 @@
[=combined buffer layout/allocationSize=].
9. Return |combinedLayout|.

: <dfn>Convert PredefinedColorSpace to VideoColorSpace</dfn> (with |colorSpace|)
:: 1. Assert: |colorSpace| is equal to one of {{srgb}} or {{display-p3}}.
2. If |colorSpace| is equal to {{srgb}} return a new instance of the
[=sRGB Color Space=]
3. If |colorSpace| is equal to {{display-p3}} return a new instance of the
[=Display P3 Color Space=]

: <dfn for=VideoFrame>Convert to RGB frame</dfn> (with |frame|, |format| and |colorSpace|)
:: 1. This algorithm <em class="rfc2119">MUST</em> be called only if |format|
is equal to one of {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}}.
Expand All @@ -4221,11 +4235,14 @@
6. Assign |frame|'s {{VideoFrame/[[duration]]}} and |frame|'s
{{VideoFrame/[[timestamp]]}} to {{VideoFrame/[[duration]]}} and
{{VideoFrame/[[timestamp]]}} respectively.
7. Assign |colorSpace| to {{VideoFrame/[[color space]]}}.
7. Assign the result of running the <a>Convert
PredefinedColorSpace to VideoColorSpace</a> algorithm with
|colorSpace| to {{VideoFrame/[[color space]]}}.
8. Let |resource| be a new [=media resource=] containing the result of
conversion of [=media resource=] referenced by |frame|'s
{{VideoFrame/[[resource reference]]}} into a color space and pixel
format specified by |colorSpace| and |format| respectively.
format specified by {{VideoFrame/[[color space]]}} and
{{VideoFrame/[[format]]}} respectively.
9. Assign the reference to |resource| to {{VideoFrame/[[resource reference]]}}
3. Return |convertedFrame|.

Expand Down

0 comments on commit 4bea332

Please sign in to comment.