media: Expose HEVC Main10 encode on macOS [chromium/src : main]

0 views
Skip to first unread message

Sida Zhu (Gerrit)

unread,
Aug 3, 2026, 9:50:52 AM (2 days ago) Aug 3
to Dale Curtis, Qiu, Jianlin, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
Attention needed from Dale Curtis and Qiu, Jianlin

Sida Zhu voted and added 5 comments

Votes added by Sida Zhu

Commit-Queue+1

5 comments

File content/test/data/gpu/webcodecs/encode-decode.html
Line 27, Patchset 4: const validateDecodedPixels =
Dale Curtis . resolved

Can we just make the validate pixels an arg to the test? Or always setup main10 in such a way that i can be validated?

Sida Zhu

Done

File content/test/data/gpu/webcodecs/webcodecs_common.js
Line 373, Patchset 4: if (codec && codec.startsWith('hvc1.2.') &&
Dale Curtis . resolved

I don't love this, it'd be better to make it a param to the test.

Sida Zhu

Done

File third_party/blink/renderer/modules/webcodecs/background_readback.cc
Line 229, Patchset 4: result_frame->set_hdr_metadata(txt_frame->hdr_metadata());
Dale Curtis . resolved

I don't think this will ever have hdr metadata, but seems harmless.

Sida Zhu

Acknowledged

File third_party/blink/renderer/modules/webcodecs/video_decoder_helper_test.cc
Line 19, Patchset 4:std::vector<uint8_t> ExtractHvcC(base::span<const uint8_t> mp4) {
Dale Curtis . resolved

Should be a parser for this in media/formats?

Sida Zhu

Done

File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
Line 1011, Patchset 4: frame->acquire_sync_token(), gfx::ColorSpace::CreateREC709(),
Qiu, Jianlin . resolved

Do not hard-code to REC709 here.

Sida Zhu

Done.

Open in Gerrit

Related details

Attention is currently required from:
  • Dale Curtis
  • Qiu, Jianlin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
Gerrit-Change-Number: 8163560
Gerrit-PatchSet: 7
Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
Gerrit-Attention: Qiu, Jianlin <jianl...@intel.com>
Gerrit-Attention: Dale Curtis <dalec...@chromium.org>
Gerrit-Comment-Date: Mon, 03 Aug 2026 13:50:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Qiu, Jianlin <jianl...@intel.com>
Comment-In-Reply-To: Dale Curtis <dalec...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Dale Curtis (Gerrit)

unread,
Aug 3, 2026, 4:56:17 PM (2 days ago) Aug 3
to Qiu, Jianlin, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
Attention needed from Qiu, Jianlin and Sida Zhu

Dale Curtis added 1 comment

File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
Line 626, Patchset 7 (Latest):gfx::ColorSpace GetReadbackYuvColorSpace(
Dale Curtis . unresolved

Does all this actually work? I'm not positive that the readback path supports all these color conversion. I'd only bet on 601, 709, and 2020.

Open in Gerrit

Related details

Attention is currently required from:
  • Qiu, Jianlin
  • Sida Zhu
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
    Gerrit-Change-Number: 8163560
    Gerrit-PatchSet: 7
    Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Attention: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Attention: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Comment-Date: Mon, 03 Aug 2026 20:56:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sida Zhu (Gerrit)

    unread,
    Aug 4, 2026, 5:34:57 AM (yesterday) Aug 4
    to Dale Curtis, Qiu, Jianlin, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
    Attention needed from Dale Curtis and Qiu, Jianlin

    Sida Zhu added 1 comment

    File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
    Line 626, Patchset 7:gfx::ColorSpace GetReadbackYuvColorSpace(
    Dale Curtis . unresolved

    Does all this actually work? I'm not positive that the readback path supports all these color conversion. I'd only bet on 601, 709, and 2020.

    Sida Zhu

    The lower copy path goes through `ColorSpace::ToSkYUVColorSpace()` before
    `skia::BlitRGBAToYUVA()`, and that does have mappings for `FCC` and `SMPTE240M` in
    addition to `601/709/2020`. I feels like we should honer the original colorspace if possible.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Dale Curtis
    • Qiu, Jianlin
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
    Gerrit-Change-Number: 8163560
    Gerrit-PatchSet: 8
    Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Attention: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Attention: Dale Curtis <dalec...@chromium.org>
    Gerrit-Comment-Date: Tue, 04 Aug 2026 09:34:30 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dale Curtis <dalec...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dale Curtis (Gerrit)

    unread,
    Aug 4, 2026, 7:20:35 PM (12 hours ago) Aug 4
    to Qiu, Jianlin, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
    Attention needed from Qiu, Jianlin and Sida Zhu

    Dale Curtis voted and added 1 comment

    Votes added by Dale Curtis

    Code-Review+1

    1 comment

    File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
    Line 626, Patchset 7:gfx::ColorSpace GetReadbackYuvColorSpace(
    Dale Curtis . resolved

    Does all this actually work? I'm not positive that the readback path supports all these color conversion. I'd only bet on 601, 709, and 2020.

    Sida Zhu

    The lower copy path goes through `ColorSpace::ToSkYUVColorSpace()` before
    `skia::BlitRGBAToYUVA()`, and that does have mappings for `FCC` and `SMPTE240M` in
    addition to `601/709/2020`. I feels like we should honer the original colorspace if possible.

    Dale Curtis

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Qiu, Jianlin
    • Sida Zhu
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
    Gerrit-Change-Number: 8163560
    Gerrit-PatchSet: 8
    Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
    Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Attention: Sida Zhu <zhu...@bytedance.com>
    Gerrit-Attention: Qiu, Jianlin <jianl...@intel.com>
    Gerrit-Comment-Date: Tue, 04 Aug 2026 23:20:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Sida Zhu <zhu...@bytedance.com>
    Comment-In-Reply-To: Dale Curtis <dalec...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Qiu, Jianlin (Gerrit)

    unread,
    Aug 4, 2026, 9:36:38 PM (10 hours ago) Aug 4
    to Dale Curtis, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
    Attention needed from Sida Zhu

    Qiu, Jianlin voted and added 1 comment

    Votes added by Qiu, Jianlin

    Code-Review+1

    1 comment

    File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
    Line 636, Patchset 8 (Latest): if (source_matrix != gfx::ColorSpace::MatrixID::RGB &&
    source_matrix != gfx::ColorSpace::MatrixID::GBR) {
    return source_color_space.GetWithMatrixAndRange(
    source_matrix, gfx::ColorSpace::RangeID::LIMITED);
    }

    // RGB/GBR are identity matrices. Select a YCbCr matrix from the primaries
    // before RGB-to-YUV readback.
    return source_color_space.GetWithMatrixAndRange(
    GetYuvMatrixForPrimaries(source_color_space.GetPrimaryID()),
    gfx::ColorSpace::RangeID::LIMITED);
    }
    Qiu, Jianlin . unresolved

    Previously we hard-code to REC709 so it was fine to ask for limited. Is it intentional that for source p010 at full-range, you also do this for reading back?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Sida Zhu
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
      Gerrit-Change-Number: 8163560
      Gerrit-PatchSet: 8
      Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
      Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
      Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
      Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
      Gerrit-Attention: Sida Zhu <zhu...@bytedance.com>
      Gerrit-Comment-Date: Wed, 05 Aug 2026 01:36:21 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Sida Zhu (Gerrit)

      unread,
      2:07 AM (5 hours ago) 2:07 AM
      to Qiu, Jianlin, Dale Curtis, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
      Attention needed from Qiu, Jianlin

      Sida Zhu added 1 comment

      File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
      Line 636, Patchset 8 (Latest): if (source_matrix != gfx::ColorSpace::MatrixID::RGB &&
      source_matrix != gfx::ColorSpace::MatrixID::GBR) {
      return source_color_space.GetWithMatrixAndRange(
      source_matrix, gfx::ColorSpace::RangeID::LIMITED);
      }

      // RGB/GBR are identity matrices. Select a YCbCr matrix from the primaries
      // before RGB-to-YUV readback.
      return source_color_space.GetWithMatrixAndRange(
      GetYuvMatrixForPrimaries(source_color_space.GetPrimaryID()),
      gfx::ColorSpace::RangeID::LIMITED);
      }
      Qiu, Jianlin . unresolved

      Previously we hard-code to REC709 so it was fine to ask for limited. Is it intentional that for source p010 at full-range, you also do this for reading back?

      Sida Zhu

      Thanks, I traced the complete allocation and conversion path.

      LIMITED is not an inherent requirement of NV12 or of
      `CopyRGBATextureToVideoFrame()` in general. It is intentional for the current
      macOS destination backing.

      The readback pool currently always requests an NV12 mappable SharedImage. On
      macOS it uses `SCANOUT_VEA_CPU_READ` together with the VideoToolbox usage, so
      SharedImageFactory selects an IOSurface backing. The kNV12 SharedImage format
      is currently mapped to
      `kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange` (`420v`).

      The IOSurface is allocated before the conversion. CopySharedImage() then
      obtains writable SkSurfaces for the Y and UV planes of that IOSurface, and
      `skia::BlitRGBAToYUVA()` writes the converted samples directly into those
      planes. Therefore the matrix/range passed to the blit must agree with the
      range represented by the destination backing. Writing full-range samples while
      the IOSurface remains `420v` would make the sample values and their downstream
      interpretation inconsistent.

      This is different on Windows, where the same readback pool normally creates a
      compound SharedImage consisting of a renderable GPU backing and a mappable
      shared-memory backing. `BlitRGBAToYUVA()` writes the GPU backing first, and the
      result is then copied into the shared-memory GMB. Android does not use this
      accelerated GMB readback path and instead reads the RGBA texture into a CPU
      RGBA frame before conversion in `VideoEncodeAcceleratorAdapter`.

      A full-range P010 input does not enter this RGBA readback path. It is handled
      directly by the VEA/VideoToolbox path, which selects the P010 CVPixelBuffer
      format and compression-session range from the frame ColorSpace.

      For Main10 encoding from an RGBA texture, the current path is:

        RGBA texture -> limited-range NV12 readback
      -> NV12-to-P010 in VideoEncodeAcceleratorAdapter
      -> VideoToolbox

      This produces valid P010 input for VideoToolbox, but it is not a true 10-bit
      readback because the pixels have already been quantized to 8-bit NV12. Direct
      RGBA-to-P010 readback should be implemented in a follow-up CL.

      That follow-up is more involved than changing the pool format. P010 uses
      R16/RG16 planes, and the current macOS Ganesh IOSurface representation cannot
      expose those planes as writable SkSurfaces. It will require a supported
      Graphite/Dawn multiplanar rendering path or a dedicated platform conversion
      shader, together with validation of P010's 10-bit MSB packing.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Qiu, Jianlin
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
      Gerrit-Change-Number: 8163560
      Gerrit-PatchSet: 8
      Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
      Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
      Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
      Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
      Gerrit-Attention: Qiu, Jianlin <jianl...@intel.com>
      Gerrit-Comment-Date: Wed, 05 Aug 2026 06:07:23 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Qiu, Jianlin <jianl...@intel.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Qiu, Jianlin (Gerrit)

      unread,
      3:12 AM (4 hours ago) 3:12 AM
      to Dale Curtis, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, feature-me...@chromium.org
      Attention needed from Sida Zhu

      Qiu, Jianlin added 1 comment

      File third_party/blink/renderer/modules/webcodecs/video_encoder.cc
      Line 636, Patchset 8 (Latest): if (source_matrix != gfx::ColorSpace::MatrixID::RGB &&
      source_matrix != gfx::ColorSpace::MatrixID::GBR) {
      return source_color_space.GetWithMatrixAndRange(
      source_matrix, gfx::ColorSpace::RangeID::LIMITED);
      }

      // RGB/GBR are identity matrices. Select a YCbCr matrix from the primaries
      // before RGB-to-YUV readback.
      return source_color_space.GetWithMatrixAndRange(
      GetYuvMatrixForPrimaries(source_color_space.GetPrimaryID()),
      gfx::ColorSpace::RangeID::LIMITED);
      }
      Qiu, Jianlin . resolved
      Qiu, Jianlin

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Sida Zhu
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ia16dd0adbd67758e2257274e08dd3c7f631e35ab
        Gerrit-Change-Number: 8163560
        Gerrit-PatchSet: 8
        Gerrit-Owner: Sida Zhu <zhu...@bytedance.com>
        Gerrit-Reviewer: Dale Curtis <dalec...@chromium.org>
        Gerrit-Reviewer: Qiu, Jianlin <jianl...@intel.com>
        Gerrit-Reviewer: Sida Zhu <zhu...@bytedance.com>
        Gerrit-Attention: Sida Zhu <zhu...@bytedance.com>
        Gerrit-Comment-Date: Wed, 05 Aug 2026 07:12:38 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Sida Zhu <zhu...@bytedance.com>
        Comment-In-Reply-To: Qiu, Jianlin <jianl...@intel.com>
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages