spanification: spanify PaintCanvasVideoRenderer::ConvertVideoFrameToRGBPixels. [chromium/src : main]

0 views
Skip to first unread message

Weidong Liu (Gerrit)

unread,
Jan 9, 2026, 4:05:55 AM (12 days ago) Jan 9
to Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Colin Blundell

Weidong Liu voted and added 1 comment

Votes added by Weidong Liu

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 5:
Colin Blundell . resolved

Thanks! Is it possible to split up this CL into multiple CLs attacking different chunks, i.e., are there independent spanifications happening in the one file in this CL?

Weidong Liu

All of these files are required by spanify `paint_canvas_video_renderer.cc`. Modifications to other files are primarily due to API changes in `PaintCanvasVideoRenderer::ConvertVideoFrameToRGBPixels`.

Colin Blundell

Thanks - What I meant is: Can we spanify `paint_canvas_video_renderer.cc` incrementally, e.g. API entrypoint by API entrypoint starting at leaf entrypoints? These types of CLs are easier to review the smaller they are.

Weidong Liu

Thank you for your reply. I removed the spanning of PlaneMetaData. Currently, only the modifications related to `PaintCanvasVideoRenderer::ConvertVideoFrameToRGBPixels` remain.

Open in Gerrit

Related details

Attention is currently required from:
  • Colin Blundell
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
Gerrit-Change-Number: 7264088
Gerrit-PatchSet: 6
Gerrit-Owner: Weidong Liu <weido...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Colin Blundell <blun...@chromium.org>
Gerrit-Comment-Date: Fri, 09 Jan 2026 09:05:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Colin Blundell <blun...@chromium.org>
Comment-In-Reply-To: Weidong Liu <weido...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Colin Blundell (Gerrit)

unread,
Jan 9, 2026, 4:39:45 AM (12 days ago) Jan 9
to Weidong Liu, Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Weidong Liu

Colin Blundell added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Colin Blundell . resolved

Thanks, Weidong! +Stephen, could you do the technical review given your expertise in this domain? Then I can stamp for //media OWNERS.

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Weidong Liu
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
Gerrit-Change-Number: 7264088
Gerrit-PatchSet: 6
Gerrit-Owner: Weidong Liu <weido...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Weidong Liu <weido...@chromium.org>
Gerrit-Comment-Date: Fri, 09 Jan 2026 09:39:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Stephen Nusko (Gerrit)

unread,
Jan 13, 2026, 1:18:47 AM (8 days ago) Jan 13
to Weidong Liu, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Weidong Liu

Stephen Nusko added 6 comments

Patchset-level comments
Stephen Nusko . resolved

I'll take another review round after changes.

File chromeos/ash/services/recording/recording_service.cc
Line 104, Patchset 6 (Latest): base::span<uint8_t> pixmap_span = UNSAFE_BUFFERS(base::span(
static_cast<uint8_t*>(bitmap.getPixels()), bitmap.computeByteSize()));
Stephen Nusko . unresolved

Please add a macro in https://source.chromium.org/chromium/chromium/src/+/main:base/containers/auto_spanification_helper.h similar to `UNSAFE_SKBITMAP_GETADDR32` (probably something like `UNSAFE_SKBITMAP_TO_BYTES_SPAN`)/

File media/renderers/paint_canvas_video_renderer.cc
Line 681, Patchset 6 (Latest): // SAFETY: Skia's API states that it will request memory of size
// `bitmap.computeByteSize()`.
Stephen Nusko . unresolved

nit: can you link to the API docs where it states this?

Line 1019, Patchset 6 (Latest): // SAFETY: Skia's API states that it will request memory of size
// `info.computeByteSize(row_bytes)`.
base::span<uint8_t> pixmap_span = UNSAFE_BUFFERS(base::span(
static_cast<uint8_t*>(pixels), info.computeByteSize(row_bytes)));
Stephen Nusko . unresolved

Same here can you a macro as well. Other places in Chrome will want to similarly wrap this.

Line 1138, Patchset 6 (Latest): base::span<const uint8_t> row = row_head.subspan(
Stephen Nusko . unresolved

This has changed type? Why?

This introduces the tricky logic of endian, whereas if you left this as uint16_t you wouldn't need to add that logic?

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . unresolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Open in Gerrit

Related details

Attention is currently required from:
  • Weidong Liu
Gerrit-Attention: Weidong Liu <weido...@chromium.org>
Gerrit-Comment-Date: Tue, 13 Jan 2026 06:18:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Weidong Liu (Gerrit)

unread,
Jan 13, 2026, 11:14:04 AM (8 days ago) Jan 13
to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Thomas Guilbert

Weidong Liu added 5 comments

File chromeos/ash/services/recording/recording_service.cc
Line 104, Patchset 6: base::span<uint8_t> pixmap_span = UNSAFE_BUFFERS(base::span(
static_cast<uint8_t*>(bitmap.getPixels()), bitmap.computeByteSize()));
Stephen Nusko . resolved

Please add a macro in https://source.chromium.org/chromium/chromium/src/+/main:base/containers/auto_spanification_helper.h similar to `UNSAFE_SKBITMAP_GETADDR32` (probably something like `UNSAFE_SKBITMAP_TO_BYTES_SPAN`)/

Weidong Liu

Done

File media/renderers/paint_canvas_video_renderer.cc
Line 681, Patchset 6: // SAFETY: Skia's API states that it will request memory of size
// `bitmap.computeByteSize()`.
Stephen Nusko . resolved

nit: can you link to the API docs where it states this?

Weidong Liu

Done

Line 1019, Patchset 6: // SAFETY: Skia's API states that it will request memory of size

// `info.computeByteSize(row_bytes)`.
base::span<uint8_t> pixmap_span = UNSAFE_BUFFERS(base::span(
static_cast<uint8_t*>(pixels), info.computeByteSize(row_bytes)));
Stephen Nusko . resolved

Same here can you a macro as well. Other places in Chrome will want to similarly wrap this.

Weidong Liu

Done

Line 1138, Patchset 6: base::span<const uint8_t> row = row_head.subspan(
Stephen Nusko . unresolved

This has changed type? Why?

This introduces the tricky logic of endian, whereas if you left this as uint16_t you wouldn't need to add that logic?

Weidong Liu

If we're using `uint16_t` (including the following within this function), then we need to introduce a new `UNSAFE_BUFFERS` to convert the `span` to other types.

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . unresolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Weidong Liu

I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Thomas Guilbert
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
Gerrit-Change-Number: 7264088
Gerrit-PatchSet: 7
Gerrit-Owner: Weidong Liu <weido...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Comment-Date: Tue, 13 Jan 2026 16:13:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Stephen Nusko (Gerrit)

unread,
Jan 14, 2026, 11:44:19 PM (6 days ago) Jan 14
to Weidong Liu, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Thomas Guilbert and Weidong Liu

Stephen Nusko added 10 comments

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Stephen Nusko . resolved

LGTM after comments + owner's approval of Endian changes.

File base/containers/auto_spanification_helper.h
Line 201, Patchset 7 (Latest):#define UNSAFE_SKPIXMAP_TO_BYTES_SPAN(arg_self) \
([](auto&& self) { \
uint8_t* row = static_cast<uint8_t*>(self->writable_addr()); \
size_t size = self->computeByteSize(); \
return UNSAFE_TODO(base::span<uint8_t>(row, size)); \
}(::base::spanification_internal::ToPointer(arg_self)))

// https://source.chromium.org/chromium/chromium/src/+/main:cc/paint/paint_canvas.h;l=66;drc=c76e4f83a8c5786b463c3e55c070a21ac751b96b
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/core/SkCanvas.cpp;l=1264;drc=6c24069ae3996c883ea5d5886d0c013cb78f8394;bpv=1;bpt=1
#define UNSAFE_PAINTCANVAS_TOP_LAYER_TO_BYTES_SPAN(arg_self, arg_info, \
arg_row_bytes, arg_origin) \
([](auto&& self, SkImageInfo* info, size_t* rowBytes, SkIPoint* origin) { \
uint8_t* row = static_cast<uint8_t*>( \
self->accessTopLayerPixels(info, rowBytes, origin)); \
size_t size = info->computeByteSize(*rowBytes); \
return UNSAFE_TODO(base::span<uint8_t>(row, size)); \
}(::base::spanification_internal::ToPointer(arg_self), arg_info, \
arg_row_bytes, arg_origin))
Stephen Nusko . unresolved

Similarly for these we should attempt to verify the assumptions to ensure the state is all correct, so that the span we return should always be safe to index in bounds.

Line 195, Patchset 7 (Latest): size_t size = self->computeByteSize(); \
Stephen Nusko . unresolved

The link says this returns SIZE_MAX if the result doesn't fit inside, should we check for this?

```
CHECK_NE(size, SIZE_MAX);
```

?

Line 194, Patchset 7 (Latest): uint8_t* row = static_cast<uint8_t*>(self->getPixels()); \
Stephen Nusko . unresolved

getPixels appears like it returns a member variable which can sometimes be a nullptr. We should ensure that if it is a nullptr that computeByteSize is properly zero.

So could you add a

```
CHECK(row || size == 0);
```

I.E. if row is not a valid pointer, size should be zero.

File media/renderers/paint_canvas_video_renderer.cc
Line 661, Patchset 7 (Latest): explicit VideoImageGenerator(scoped_refptr<VideoFrame> frame)
Stephen Nusko . unresolved

This seems to move this into style guide compliance (a good thing), but do you know why it wasn't explicit before? And why this was done in this CL?

Line 1138, Patchset 6: base::span<const uint8_t> row = row_head.subspan(
Stephen Nusko . resolved

This has changed type? Why?

This introduces the tricky logic of endian, whereas if you left this as uint16_t you wouldn't need to add that logic?

Weidong Liu

If we're using `uint16_t` (including the following within this function), then we need to introduce a new `UNSAFE_BUFFERS` to convert the `span` to other types.

Stephen Nusko

As long as we do a

```
CHECK_EQ(row_head.size() % sizeof(uint16_t), 0u);
```

I think I'm completely okay with adding a

```
// SAFETY: We've verified that this fits inside of a uint16_t and access it as such.
row = UNSAFE_BUFFERS(base::span<uint16_t>(row_head.data(), row_head.size() / sizeof(uint16_t));
```

As needed, but I'll resolve this comment change and let @tgui...@chromium.org as a media owner decide.

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . unresolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Weidong Liu

I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

Stephen Nusko

I'm going to leave this final decision up to @tgui...@chromium.org, I'm a spanification expert not a media expert.

With U16 methods on SpanWriter/SpanReader this seems "okay" to me, but the other option is to not introduce this endian at all and just reinterpret cast the spans to uint16_t (or whatever) as the current code was doing (with a couple UNSAFE_BUFFERS and checks to ensure it is all in bounds).

If no one relies then this change to use Write/ReadNativeEndian reads pretty reasonable to me.

Line 1293, Patchset 7 (Latest): case PIXEL_FORMAT_Y16: {
Stephen Nusko . unresolved

nit: I don't think you need the bracket anymore since you are introducing a new variable here.

File media/renderers/paint_canvas_video_renderer_unittest.cc
Line 76, Patchset 7 (Latest): writer.Skip(offset_y * stride * 2);
Stephen Nusko . unresolved

this `*2` confused me until I realized that the old code was in uint16_t.

Perhaps we do

```
constexpr size_t kBytesPerPixel = 2;
```

(name to be decided).

`kU16Size` or `kBytesPerPixel` both seem fine.

Or as described we could just convert the span to uin16_t and keep the logic.

Line 1205, Patchset 7 (Latest): [](base::raw_span<uint8_t> pixels, const gfx::Size& size, int x,
Stephen Nusko . unresolved

generally function parameters shouldn't be raw_span, is there a reason this is a raw_span and not just a regular span?

Open in Gerrit

Related details

Attention is currently required from:
  • Thomas Guilbert
  • Weidong Liu
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
Gerrit-Change-Number: 7264088
Gerrit-PatchSet: 7
Gerrit-Owner: Weidong Liu <weido...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Attention: Weidong Liu <weido...@chromium.org>
Gerrit-Comment-Date: Thu, 15 Jan 2026 04:43:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
Comment-In-Reply-To: Weidong Liu <weido...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Weidong Liu (Gerrit)

unread,
Jan 15, 2026, 9:23:58 AM (6 days ago) Jan 15
to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Thomas Guilbert

Weidong Liu voted and added 8 comments

Votes added by Weidong Liu

Commit-Queue+1

8 comments

File base/containers/auto_spanification_helper.h
Line 201, Patchset 7:#define UNSAFE_SKPIXMAP_TO_BYTES_SPAN(arg_self) \

([](auto&& self) { \
uint8_t* row = static_cast<uint8_t*>(self->writable_addr()); \
size_t size = self->computeByteSize(); \
return UNSAFE_TODO(base::span<uint8_t>(row, size)); \
}(::base::spanification_internal::ToPointer(arg_self)))

// https://source.chromium.org/chromium/chromium/src/+/main:cc/paint/paint_canvas.h;l=66;drc=c76e4f83a8c5786b463c3e55c070a21ac751b96b
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/core/SkCanvas.cpp;l=1264;drc=6c24069ae3996c883ea5d5886d0c013cb78f8394;bpv=1;bpt=1
#define UNSAFE_PAINTCANVAS_TOP_LAYER_TO_BYTES_SPAN(arg_self, arg_info, \
arg_row_bytes, arg_origin) \
([](auto&& self, SkImageInfo* info, size_t* rowBytes, SkIPoint* origin) { \
uint8_t* row = static_cast<uint8_t*>( \
self->accessTopLayerPixels(info, rowBytes, origin)); \
size_t size = info->computeByteSize(*rowBytes); \
return UNSAFE_TODO(base::span<uint8_t>(row, size)); \
}(::base::spanification_internal::ToPointer(arg_self), arg_info, \
arg_row_bytes, arg_origin))
Stephen Nusko . resolved

Similarly for these we should attempt to verify the assumptions to ensure the state is all correct, so that the span we return should always be safe to index in bounds.

Weidong Liu

Done

Line 195, Patchset 7: size_t size = self->computeByteSize(); \
Stephen Nusko . resolved

The link says this returns SIZE_MAX if the result doesn't fit inside, should we check for this?

```
CHECK_NE(size, SIZE_MAX);
```

?

Weidong Liu

Done

Line 194, Patchset 7: uint8_t* row = static_cast<uint8_t*>(self->getPixels()); \
Stephen Nusko . resolved

getPixels appears like it returns a member variable which can sometimes be a nullptr. We should ensure that if it is a nullptr that computeByteSize is properly zero.

So could you add a

```
CHECK(row || size == 0);
```

I.E. if row is not a valid pointer, size should be zero.

Weidong Liu

Done

File media/renderers/paint_canvas_video_renderer.cc
Line 661, Patchset 7: explicit VideoImageGenerator(scoped_refptr<VideoFrame> frame)
Stephen Nusko . resolved

This seems to move this into style guide compliance (a good thing), but do you know why it wasn't explicit before? And why this was done in this CL?

Weidong Liu

I don't know the reason. I checked the blame, and the code here is too old (10 years ago). Currently, it's only used within the current file, so it shouldn't introduce any new problems.

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . unresolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Weidong Liu

I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

Stephen Nusko

I'm going to leave this final decision up to @tgui...@chromium.org, I'm a spanification expert not a media expert.

With U16 methods on SpanWriter/SpanReader this seems "okay" to me, but the other option is to not introduce this endian at all and just reinterpret cast the spans to uint16_t (or whatever) as the current code was doing (with a couple UNSAFE_BUFFERS and checks to ensure it is all in bounds).

If no one relies then this change to use Write/ReadNativeEndian reads pretty reasonable to me.

Weidong Liu

Thank you for reviewing. I will await comments from @tgui...@chromium.org.

Line 1293, Patchset 7: case PIXEL_FORMAT_Y16: {
Stephen Nusko . resolved

nit: I don't think you need the bracket anymore since you are introducing a new variable here.

Weidong Liu

Done

File media/renderers/paint_canvas_video_renderer_unittest.cc
Line 76, Patchset 7: writer.Skip(offset_y * stride * 2);
Stephen Nusko . resolved

this `*2` confused me until I realized that the old code was in uint16_t.

Perhaps we do

```
constexpr size_t kBytesPerPixel = 2;
```

(name to be decided).

`kU16Size` or `kBytesPerPixel` both seem fine.

Or as described we could just convert the span to uin16_t and keep the logic.

Weidong Liu

Done

Line 1205, Patchset 7: [](base::raw_span<uint8_t> pixels, const gfx::Size& size, int x,
Stephen Nusko . resolved

generally function parameters shouldn't be raw_span, is there a reason this is a raw_span and not just a regular span?

Weidong Liu

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Thomas Guilbert
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
Gerrit-Change-Number: 7264088
Gerrit-PatchSet: 8
Gerrit-Owner: Weidong Liu <weido...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Comment-Date: Thu, 15 Jan 2026 14:23:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Thomas Guilbert (Gerrit)

unread,
Jan 15, 2026, 5:46:08 PM (5 days ago) Jan 15
to Weidong Liu, Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Weidong Liu

Thomas Guilbert added 3 comments

File media/renderers/paint_canvas_video_renderer.cc
Line 1133, Patchset 8 (Latest): const float result[] = {gray_value, gray_value, gray_value, 1.0f};
Thomas Guilbert . unresolved

The AI review helper outlined this as a potential performance regression. This code is executed per-pixel, so this might be called millions of times per frame.

It might be worth using a micro-benchmark to measure the impact of this change.

An alternative could be to reuse an `std::array<float, 4>` defined outside of the loop. Using `out_row.take_first<4*sizeof(float)>()` instead of the `SpanReader` also seems to be ok, from the examples [here](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md#avoid-reinterpret_cast).

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . unresolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Weidong Liu

I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

Stephen Nusko

I'm going to leave this final decision up to @tgui...@chromium.org, I'm a spanification expert not a media expert.

With U16 methods on SpanWriter/SpanReader this seems "okay" to me, but the other option is to not introduce this endian at all and just reinterpret cast the spans to uint16_t (or whatever) as the current code was doing (with a couple UNSAFE_BUFFERS and checks to ensure it is all in bounds).

If no one relies then this change to use Write/ReadNativeEndian reads pretty reasonable to me.

Weidong Liu

Thank you for reviewing. I will await comments from @tgui...@chromium.org.

Thomas Guilbert

The preference for explicitly using LittleEndianess is interesting... I learnt something new, thanks! Some of my concern was whether the video format itself had a specific endianess (e.g. like when we parse an Opus header), but this might not be relevant here.

[...] reinterpret cast the spans to uint16t_t...

I thought this was generally discouraged, following [this guidance](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md#avoid-reinterpret_cast). If this is be acceptable here, I think it is preferable, as we could use the ranged-based for-loops, which don't have a performance impact versus pointer arithmetic.

I would argue that given that this code is a "hot path", it might be worth it in this case.

File media/renderers/paint_canvas_video_renderer_unittest.cc
Line 1067, Patchset 8 (Latest): base::CheckMul<size_t>(width * 4, height, 4u).ValueOrDie()));
Thomas Guilbert . unresolved

Is this multiplying by 4 twice? Unintended?

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Weidong Liu
Gerrit-Attention: Weidong Liu <weido...@chromium.org>
Gerrit-Comment-Date: Thu, 15 Jan 2026 22:45:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Weidong Liu (Gerrit)

unread,
Jan 15, 2026, 9:08:38 PM (5 days ago) Jan 15
to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Thomas Guilbert

Weidong Liu voted and added 2 comments

Votes added by Weidong Liu

Commit-Queue+1

2 comments

File media/renderers/paint_canvas_video_renderer.cc
Line 1133, Patchset 8: const float result[] = {gray_value, gray_value, gray_value, 1.0f};
Thomas Guilbert . resolved

The AI review helper outlined this as a potential performance regression. This code is executed per-pixel, so this might be called millions of times per frame.

It might be worth using a micro-benchmark to measure the impact of this change.

An alternative could be to reuse an `std::array<float, 4>` defined outside of the loop. Using `out_row.take_first<4*sizeof(float)>()` instead of the `SpanReader` also seems to be ok, from the examples [here](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md#avoid-reinterpret_cast).

Weidong Liu

Done

Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
Thomas Guilbert . resolved

I would double check that these are all little endian.

Stephen Nusko

+1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

Weidong Liu

I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

Stephen Nusko

I'm going to leave this final decision up to @tgui...@chromium.org, I'm a spanification expert not a media expert.

With U16 methods on SpanWriter/SpanReader this seems "okay" to me, but the other option is to not introduce this endian at all and just reinterpret cast the spans to uint16_t (or whatever) as the current code was doing (with a couple UNSAFE_BUFFERS and checks to ensure it is all in bounds).

If no one relies then this change to use Write/ReadNativeEndian reads pretty reasonable to me.

Weidong Liu

Thank you for reviewing. I will await comments from @tgui...@chromium.org.

Thomas Guilbert

The preference for explicitly using LittleEndianess is interesting... I learnt something new, thanks! Some of my concern was whether the video format itself had a specific endianess (e.g. like when we parse an Opus header), but this might not be relevant here.

[...] reinterpret cast the spans to uint16t_t...

I thought this was generally discouraged, following [this guidance](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md#avoid-reinterpret_cast). If this is be acceptable here, I think it is preferable, as we could use the ranged-based for-loops, which don't have a performance impact versus pointer arithmetic.

I would argue that given that this code is a "hot path", it might be worth it in this case.

Weidong Liu

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Thomas Guilbert
Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 02:08:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Weidong Liu (Gerrit)

unread,
Jan 15, 2026, 9:11:37 PM (5 days ago) Jan 15
to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
Attention needed from Stephen Nusko and Thomas Guilbert

Weidong Liu added 1 comment

File media/renderers/paint_canvas_video_renderer_unittest.cc
Line 1067, Patchset 8: base::CheckMul<size_t>(width * 4, height, 4u).ValueOrDie()));
Thomas Guilbert . resolved

Is this multiplying by 4 twice? Unintended?

Weidong Liu

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Stephen Nusko
  • Thomas Guilbert
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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
    Gerrit-Change-Number: 7264088
    Gerrit-PatchSet: 9
    Gerrit-Owner: Weidong Liu <weido...@chromium.org>
    Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
    Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
    Gerrit-Comment-Date: Fri, 16 Jan 2026 02:11:11 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    Jan 19, 2026, 10:34:27 PM (2 days ago) Jan 19
    to Weidong Liu, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
    Attention needed from Thomas Guilbert and Weidong Liu

    Stephen Nusko added 2 comments

    File media/renderers/paint_canvas_video_renderer.cc
    Line 121, Patchset 9 (Latest): CHECK_EQ(span.size() % sizeof(T), 0u);
    Stephen Nusko . unresolved

    If we go this route can you also add

    CHECK(base::IsAligned(span.data(), alignof(T)));`

    Line 1142, Patchset 5: reader.ReadU16LittleEndian(value);
    Thomas Guilbert . resolved

    I would double check that these are all little endian.

    Stephen Nusko

    +1 I think we shouldn't move to uint8_t here and instead should remain as uint16_t and let the system track endianness.

    Weidong Liu

    I've consulted some resources. The base library states that Chromium only supports small segment orders: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=18?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

    The comments for `U16FromNativeEndian` also indicate that we prefer explicit little endian: https://source.chromium.org/chromium/chromium/src/+/main:base/numerics/byte_conversions.h;l=44?q=byte_conversions.h&ss=chromium%2Fchromium%2Fsrc

    Due to your concerns, I changed it to use the `NativeEndian` version. However, the implementation still uses little endian.

    Stephen Nusko

    I'm going to leave this final decision up to @tgui...@chromium.org, I'm a spanification expert not a media expert.

    With U16 methods on SpanWriter/SpanReader this seems "okay" to me, but the other option is to not introduce this endian at all and just reinterpret cast the spans to uint16_t (or whatever) as the current code was doing (with a couple UNSAFE_BUFFERS and checks to ensure it is all in bounds).

    If no one relies then this change to use Write/ReadNativeEndian reads pretty reasonable to me.

    Weidong Liu

    Thank you for reviewing. I will await comments from @tgui...@chromium.org.

    Thomas Guilbert

    The preference for explicitly using LittleEndianess is interesting... I learnt something new, thanks! Some of my concern was whether the video format itself had a specific endianess (e.g. like when we parse an Opus header), but this might not be relevant here.

    [...] reinterpret cast the spans to uint16t_t...

    I thought this was generally discouraged, following [this guidance](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md#avoid-reinterpret_cast). If this is be acceptable here, I think it is preferable, as we could use the ranged-based for-loops, which don't have a performance impact versus pointer arithmetic.

    I would argue that given that this code is a "hot path", it might be worth it in this case.

    Weidong Liu

    Done

    Stephen Nusko

    Thanks for pointing that out. It is indeed discouraged.

    So talking to the base::span owners they much prefer folks use these Endian (either Native or Little/Big) or the suggested take_first<2> to then pull into the value of your type.

    Apparently if you reinterpret_cast and the object of that type has not previously existed at that location it is technically undefined behaviour (until c++23 and lifetime annotations).

    However we do have occurrences of it in some areas already and pdfium uses it as well. However they also usually include an alignment check for extra safety. So I suggest we at least add that, and if we don't mind the endian we can use the readers or the slightly more verbose take_first<2>.copy_from(byte_span_from_ref()),

    ```
    CHECK(base::IsAligned(span.data(), alignof(uint16_t)));
    ```

    So the take_first<2> method would look like:
    ```
    row.take_first<2>.copy_from(base::byte_span_from_ref(value));
    ```

    If we had a benchmark on this code it might be worth trying both approaches to see if one is better than the other.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Thomas Guilbert
    • Weidong Liu
    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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
      Gerrit-Change-Number: 7264088
      Gerrit-PatchSet: 9
      Gerrit-Owner: Weidong Liu <weido...@chromium.org>
      Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
      Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
      Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
      Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
      Gerrit-CC: Stephen Chenney <sche...@chromium.org>
      Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Attention: Weidong Liu <weido...@chromium.org>
      Gerrit-Comment-Date: Tue, 20 Jan 2026 03:34:05 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Weidong Liu (Gerrit)

      unread,
      Jan 20, 2026, 12:43:42 AM (yesterday) Jan 20
      to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
      Attention needed from Stephen Nusko and Thomas Guilbert

      Weidong Liu voted and added 2 comments

      Votes added by Weidong Liu

      Commit-Queue+1

      2 comments

      File media/renderers/paint_canvas_video_renderer.cc
      Line 121, Patchset 9: CHECK_EQ(span.size() % sizeof(T), 0u);
      Stephen Nusko . resolved

      If we go this route can you also add

      CHECK(base::IsAligned(span.data(), alignof(T)));`

      Weidong Liu

      Done

      Weidong Liu

      Considering this is a popular path, I will follow Thomas's suggestion and maintain the status quo.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Stephen Nusko
      • Thomas Guilbert
      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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
        Gerrit-Change-Number: 7264088
        Gerrit-PatchSet: 10
        Gerrit-Owner: Weidong Liu <weido...@chromium.org>
        Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
        Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
        Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
        Gerrit-CC: Stephen Chenney <sche...@chromium.org>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
        Gerrit-Comment-Date: Tue, 20 Jan 2026 05:43:13 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Thomas Guilbert (Gerrit)

        unread,
        Jan 20, 2026, 8:09:16 PM (6 hours ago) Jan 20
        to Weidong Liu, Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
        Attention needed from Stephen Nusko and Weidong Liu

        Thomas Guilbert added 7 comments

        File media/renderers/paint_canvas_video_renderer.cc
        Line 1153, Patchset 10 (Latest): temp_buffer[3] = 1.0f;
        Thomas Guilbert . unresolved

        NIT: Move `temp_buffer[3] = 1.0f;` outside the loop

        File media/renderers/paint_canvas_video_renderer_unittest.cc
        Line 74, Patchset 10 (Latest): const size_t byte_size = stride * coded_size.height() * 2;
        Thomas Guilbert . unresolved

        NIT: Use `kBytesPerPixel` here too.

        Line 287, Patchset 10 (Latest): const size_t extra_width = frame->stride(0) - kWidth;
        Thomas Guilbert . unresolved

        NIT: `extra_width` might be easier to understand as `padding`.

        Line 291, Patchset 10 (Latest): uint16_t result[] = {
        fp16_ieee_from_fp32_value(1), fp16_ieee_from_fp32_value(0),
        fp16_ieee_from_fp32_value(0), fp16_ieee_from_fp32_value(1)};
        Thomas Guilbert . unresolved

        TINY NIT: Not performance critical because these are tests... But move out of both loops

        Line 731, Patchset 10 (Latest): base::span<const uint8_t> src = cropped_frame()->data_span(plane);
        base::SpanWriter writer(frame->writable_span(plane));
        for (int row = 0; row < cropped_frame()->rows(plane); row++) {
        for (int col = 0; col < width; col++) {
        writer.WriteU16NativeEndian(src[col] << (param.bit_depth - 8));
        }
        src = src.subspan(frame->stride(plane));
        writer.Skip(frame->stride(plane) - width * 2);
        }
        Thomas Guilbert . unresolved

        NIT: Using

        ```
        base::span<const uint8_t> src = cropped_frame->data_span(plane);
        base::span<uint8_t> dest = frame->writable_span(plane);

        [...]

        auto src_row = src.take_first(cropped_frame->stride(plane));
        auto dest_row = dest.take_first(frame->stride(plane));

        for (...) {
        const uint16_t value = src_row[col] << (param.bit_depth - 8);
        dest_row.take_first<sizeof(uint16_t)>()
        .copy_from(base::byte_span_from_ref(value));
        }
        ```

        avoids skipping bytes on the write, and is easier to follow IMO.

        Also, we should double check the frame vs cropped frame logic holds.

        Line 821, Patchset 10 (Latest): writer_u.WriteU16NativeEndian(2048);
        Thomas Guilbert . unresolved

        Same as:
        ```
        const uint16_t value = 4095
        std::fill(y_plane, base::byte_span_from_ref(value));
        ```

        and

        ```
        const uint16_t value = 2048
        std::fill(u_plane, base::byte_span_from_ref(value));
        std::fill(v_plane, base::byte_span_from_ref(value));
        ```

        Line 1067, Patchset 10 (Latest): base::CheckMul<size_t>(width, height, sizeof(float)).ValueOrDie()));
        Thomas Guilbert . unresolved

        Use 4 rather than `sizeof(float)`, since this is an element count, not a byte size.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Stephen Nusko
        • Weidong Liu
        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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
          Gerrit-Change-Number: 7264088
          Gerrit-PatchSet: 10
          Gerrit-Owner: Weidong Liu <weido...@chromium.org>
          Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
          Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
          Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
          Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
          Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
          Gerrit-CC: Stephen Chenney <sche...@chromium.org>
          Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
          Gerrit-Attention: Weidong Liu <weido...@chromium.org>
          Gerrit-Comment-Date: Wed, 21 Jan 2026 01:09:06 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Weidong Liu (Gerrit)

          unread,
          Jan 20, 2026, 10:30:23 PM (4 hours ago) Jan 20
          to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
          Attention needed from Stephen Nusko and Thomas Guilbert

          Weidong Liu added 7 comments

          File media/renderers/paint_canvas_video_renderer.cc
          Line 1153, Patchset 10: temp_buffer[3] = 1.0f;
          Thomas Guilbert . resolved

          NIT: Move `temp_buffer[3] = 1.0f;` outside the loop

          Weidong Liu

          Done

          File media/renderers/paint_canvas_video_renderer_unittest.cc
          Line 74, Patchset 10: const size_t byte_size = stride * coded_size.height() * 2;
          Thomas Guilbert . resolved

          NIT: Use `kBytesPerPixel` here too.

          Weidong Liu

          Done

          Line 287, Patchset 10: const size_t extra_width = frame->stride(0) - kWidth;
          Thomas Guilbert . resolved

          NIT: `extra_width` might be easier to understand as `padding`.

          Weidong Liu

          Done

          Line 291, Patchset 10: uint16_t result[] = {
          fp16_ieee_from_fp32_value(1), fp16_ieee_from_fp32_value(0),
          fp16_ieee_from_fp32_value(0), fp16_ieee_from_fp32_value(1)};
          Thomas Guilbert . resolved

          TINY NIT: Not performance critical because these are tests... But move out of both loops

          Weidong Liu

          Done

          Line 731, Patchset 10: base::span<const uint8_t> src = cropped_frame()->data_span(plane);

          base::SpanWriter writer(frame->writable_span(plane));
          for (int row = 0; row < cropped_frame()->rows(plane); row++) {
          for (int col = 0; col < width; col++) {
          writer.WriteU16NativeEndian(src[col] << (param.bit_depth - 8));
          }
          src = src.subspan(frame->stride(plane));
          writer.Skip(frame->stride(plane) - width * 2);
          }
          Thomas Guilbert . resolved

          NIT: Using

          ```
          base::span<const uint8_t> src = cropped_frame->data_span(plane);
          base::span<uint8_t> dest = frame->writable_span(plane);

          [...]

          auto src_row = src.take_first(cropped_frame->stride(plane));
          auto dest_row = dest.take_first(frame->stride(plane));

          for (...) {
          const uint16_t value = src_row[col] << (param.bit_depth - 8);
          dest_row.take_first<sizeof(uint16_t)>()
          .copy_from(base::byte_span_from_ref(value));
          }
          ```

          avoids skipping bytes on the write, and is easier to follow IMO.

          Also, we should double check the frame vs cropped frame logic holds.

          Weidong Liu

          Done

          Line 821, Patchset 10: writer_u.WriteU16NativeEndian(2048);
          Thomas Guilbert . resolved

          Same as:
          ```
          const uint16_t value = 4095
          std::fill(y_plane, base::byte_span_from_ref(value));
          ```

          and

          ```
          const uint16_t value = 2048
          std::fill(u_plane, base::byte_span_from_ref(value));
          std::fill(v_plane, base::byte_span_from_ref(value));
          ```

          Weidong Liu

          Done

          Line 1067, Patchset 10: base::CheckMul<size_t>(width, height, sizeof(float)).ValueOrDie()));
          Thomas Guilbert . resolved

          Use 4 rather than `sizeof(float)`, since this is an element count, not a byte size.

          Weidong Liu

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Stephen Nusko
          • Thomas Guilbert
          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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
            Gerrit-Change-Number: 7264088
            Gerrit-PatchSet: 11
            Gerrit-Owner: Weidong Liu <weido...@chromium.org>
            Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
            Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
            Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
            Gerrit-CC: Stephen Chenney <sche...@chromium.org>
            Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
            Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
            Gerrit-Comment-Date: Wed, 21 Jan 2026 03:29:55 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Weidong Liu (Gerrit)

            unread,
            Jan 20, 2026, 10:33:47 PM (4 hours ago) Jan 20
            to Stephen Nusko, Colin Blundell, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, Stephen Chenney, Dirk Schulze, AyeAye, oshima...@chromium.org, fserb...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, blink-reviews-p...@chromium.org, kinuko...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, fmalit...@chromium.org
            Attention needed from Stephen Nusko and Thomas Guilbert

            Weidong Liu voted Commit-Queue+1

            Commit-Queue+1
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Stephen Nusko
            • Thomas Guilbert
            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: I01e76e424e27800bdf595781f799bdedb6b8dd7a
            Gerrit-Change-Number: 7264088
            Gerrit-PatchSet: 12
            Gerrit-Owner: Weidong Liu <weido...@chromium.org>
            Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
            Gerrit-Reviewer: Weidong Liu <weido...@chromium.org>
            Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
            Gerrit-CC: Stephen Chenney <sche...@chromium.org>
            Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
            Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
            Gerrit-Comment-Date: Wed, 21 Jan 2026 03:33:22 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages