LibMedia+LibWeb: Store decoded YUV data in video frames

Decoded video frames should own their planar YUV data and color space
directly. Keeping that storage behind ImmutableBitmap gave a
still-image abstraction media-specific behavior and made calls like
bitmap() potentially allocate and convert a whole video frame.

Move YUV ownership into Media::VideoFrame, where the lifetime naturally
follows media playback, and remove the YUV-backed mode from
ImmutableBitmap. This commit intentionally keeps the visible Web paint
path on ExternalContentSource by converting the current frame back to
an ImmutableBitmap where Web still expects one.

Callers that need pixels now ask the frame to convert explicitly. That
preserves behavior for canvas and bitmap consumers while making the
expensive YUV-to-pixel path visible at the call site instead of
hiding it behind ImmutableBitmap::bitmap().
This commit is contained in:
Aliaksandr Kalenik
2026-05-05 11:38:50 +02:00
committed by Gregory Bertilson
parent 7f09cdfc82
commit febd85f417
Notes: github-actions[bot] 2026-05-05 19:41:14 +00:00
11 changed files with 58 additions and 91 deletions

View File

@@ -346,7 +346,12 @@ RefPtr<Gfx::ImmutableBitmap> HTMLVideoElement::bitmap() const
auto current_frame = sink->current_frame();
if (!current_frame)
return nullptr;
return current_frame->immutable_bitmap();
auto bitmap_or_error = current_frame->to_immutable_bitmap();
if (bitmap_or_error.is_error()) {
dbgln("Could not convert video frame to bitmap: {}", bitmap_or_error.release_error());
return nullptr;
}
return bitmap_or_error.release_value();
}
}