From 9b8238a6e2811852ce8ef5964129f9efa16c9d34 Mon Sep 17 00:00:00 2001 From: Eugene Zemtsov Date: Tue, 10 Sep 2024 19:07:53 -0700 Subject: [PATCH 1/2] Convert PredefinedColorSpace to VideoColorSpace When describing VideoFrame conversion to RGB PredefinedColorSpace can't be used as a VideoFrame.colorSpace and it needs to be converted to the appropriate type ( VideoColorSpace ) --- index.src.html | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/index.src.html b/index.src.html index 8ccf7e03..904ed516 100644 --- a/index.src.html +++ b/index.src.html @@ -155,18 +155,25 @@ alpha channel is present. : sRGB Color Space -:: 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` + +: Display P3 Color Space +:: 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` : REC709 Color Space -:: 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` : Codec Saturation :: The state of an underlying codec implementation where the number of active @@ -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]]}}. @@ -4205,6 +4212,14 @@ [=combined buffer layout/allocationSize=]. 9. Return |combinedLayout|. +: Convert PredefinedColorSpace to VideoColorSpace (with |colorSpace|) + :: 1. This algorithm MUST be called only if |colorSpace| + is equal to one of {{srgb}}, {{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=] + : Convert to RGB frame (with |frame|, |format| and |colorSpace|) :: 1. This algorithm MUST be called only if |format| is equal to one of {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}}. @@ -4221,11 +4236,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 Convert + PredefinedColorSpace to VideoColorSpace 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|. From 737c7a277691931b85f55cdb56074623054f5719 Mon Sep 17 00:00:00 2001 From: Eugene Zemtsov Date: Wed, 11 Sep 2024 15:52:59 -0700 Subject: [PATCH 2/2] change assert type Co-authored-by: Jeffrey Yasskin --- index.src.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.src.html b/index.src.html index 904ed516..9f729ac8 100644 --- a/index.src.html +++ b/index.src.html @@ -4213,8 +4213,7 @@ 9. Return |combinedLayout|. : Convert PredefinedColorSpace to VideoColorSpace (with |colorSpace|) - :: 1. This algorithm MUST be called only if |colorSpace| - is equal to one of {{srgb}}, {{display-p3}}. + :: 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