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

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: Created 4 years, 10 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
« media/base/video_util.h ('K') | « 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..aa527b18dbaeb13b729552d190c910f53d58c75e 100644
--- a/media/base/video_util.cc
+++ b/media/base/video_util.cc
@@ -14,6 +14,14 @@
namespace media {
+namespace {
+
+// Empty method used for keeping a reference to the original media::VideoFrame.
+// The reference to |frame| is kept in the closure that calls this method.
mcasas 2016/02/29 23:48:01 nit: This second sentence doesn't make sense :)
emircan 2016/03/01 20:07:55 Done.
+void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) {}
mcasas 2016/02/29 23:48:01 Can we use base::DeletePointer? [1] Also, no empt
emircan 2016/03/01 20:07:55 DeletePointer doesn't support ref_ptr as it only e
+
+} // namespace
+
gfx::Size GetNaturalSize(const gfx::Size& visible_size,
int aspect_ratio_numerator,
int aspect_ratio_denominator) {
@@ -316,4 +324,20 @@ void CopyRGBToVideoFrame(const uint8_t* source,
uv_stride);
}
+scoped_refptr<VideoFrame> DropYV12AAlphaChannel(
+ 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
« media/base/video_util.h ('K') | « media/base/video_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698