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

Unified Diff: content/renderer/media/video_track_recorder.cc

Issue 2147753002: VideoTrackRecorder: add support for texture backed ARGB VideoFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: content/renderer/media/video_track_recorder.cc
diff --git a/content/renderer/media/video_track_recorder.cc b/content/renderer/media/video_track_recorder.cc
index d65e238e8795e5d07b6ffcba163d6c135fb684c0..9fc9096d6579c6bfc8bd2e1a9098c545cd7761ac 100644
--- a/content/renderer/media/video_track_recorder.cc
+++ b/content/renderer/media/video_track_recorder.cc
@@ -185,14 +185,43 @@ void VideoTrackRecorder::Encoder::StartFrameEncode(
if (!(video_frame->format() == media::PIXEL_FORMAT_I420 ||
video_frame->format() == media::PIXEL_FORMAT_YV12 ||
+ video_frame->format() == media::PIXEL_FORMAT_ARGB ||
video_frame->format() == media::PIXEL_FORMAT_YV12A)) {
- NOTREACHED();
+ NOTREACHED() << media::VideoPixelFormatToString(video_frame->format());
return;
}
emircan 2016/07/12 22:57:00 This code looks very similar to CopyFrame() below,
mcasas 2016/07/13 00:45:30 Happy to do that, but I see that CopyFrame() has a
- scoped_refptr<media::VideoFrame> frame = video_frame;
- // Drop alpha channel since we do not support it yet.
- if (frame->format() == media::PIXEL_FORMAT_YV12A)
+ scoped_refptr<media::VideoFrame> frame;
+ if (video_frame->format() == media::PIXEL_FORMAT_ARGB) {
+ // Certain Android (hardware) decoders produce media::PIXEL_FORMAT_ARGB,
+ // (see https://crbug.com/585242) that may or may not be opaque. In the
+ // former case, record black frames (yuv = {0, 0x80, 0x80}) instead.
+ if (!video_frame->IsMappable()) {
+ frame = media::VideoFrame::CreateColorFrame(
+ video_frame->coded_size(), 0u, 0x80, 0x80, video_frame->timestamp());
emircan 2016/07/12 22:57:00 What if the coded_size() is not equal to visible_s
mcasas 2016/07/13 00:45:30 Well, I guess at this point the user is not going
+ } else {
+ frame = media::VideoFrame::CreateFrame(
+ media::PIXEL_FORMAT_I420, video_frame->coded_size(),
+ video_frame->visible_rect(), video_frame->natural_size(),
+ video_frame->timestamp());
+ const int result =
+ libyuv::ARGBToI420(video_frame->data(media::VideoFrame::kARGBPlane),
+ video_frame->stride(media::VideoFrame::kARGBPlane),
+ frame->data(media::VideoFrame::kYPlane),
+ frame->stride(media::VideoFrame::kYPlane),
+ frame->data(media::VideoFrame::kUPlane),
+ frame->stride(media::VideoFrame::kUPlane),
+ frame->data(media::VideoFrame::kVPlane),
+ frame->stride(media::VideoFrame::kVPlane),
+ video_frame->coded_size().width(),
+ video_frame->coded_size().height());
+ DCHECK_EQ(0, result) << "Error converting ARGB input frame to I420";
+ }
+ } else if (video_frame->format() == media::PIXEL_FORMAT_YV12A) {
+ // Drop alpha channel since we do not support it yet.
frame = media::WrapAsI420VideoFrame(video_frame);
+ } else {
+ frame = video_frame;
+ }
encoding_task_runner_->PostTask(
FROM_HERE, base::Bind(&Encoder::EncodeOnEncodingTaskRunner, this, frame,

Powered by Google App Engine
This is Rietveld 408576698