Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: media/base/video_util.cc

Issue 1737253002: Handle Alpha channel in Canvas capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bbudge@ nit. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_util.cc
diff --git a/media/base/video_util.cc b/media/base/video_util.cc
index c628673824424e423aef616b1dd2a162a96eaa15..d9954f8f8e7b4b902d33bd6c63aebd42d619801c 100644
--- a/media/base/video_util.cc
+++ b/media/base/video_util.cc
@@ -14,6 +14,13 @@
namespace media {
+namespace {
+
+// Empty method used for keeping a reference to the original media::VideoFrame.
+void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) {}
+
+} // namespace
+
gfx::Size GetNaturalSize(const gfx::Size& visible_size,
int aspect_ratio_numerator,
int aspect_ratio_denominator) {
@@ -316,4 +323,20 @@ void CopyRGBToVideoFrame(const uint8_t* source,
uv_stride);
}
+scoped_refptr<VideoFrame> WrapAsI420VideoFrame(
+ const scoped_refptr<VideoFrame>& frame) {
+ DCHECK_EQ(VideoFrame::STORAGE_OWNED_MEMORY, frame->storage_type());
+ DCHECK_EQ(PIXEL_FORMAT_YV12A, frame->format());
+
+ scoped_refptr<media::VideoFrame> wrapped_frame =
+ media::VideoFrame::WrapVideoFrame(frame, PIXEL_FORMAT_I420,
+ frame->visible_rect(),
+ frame->natural_size());
+ if (!wrapped_frame)
+ return nullptr;
+ wrapped_frame->AddDestructionObserver(
+ base::Bind(&ReleaseOriginalFrame, frame));
+ return wrapped_frame;
+}
+
} // namespace media
« no previous file with comments | « media/base/video_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698