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

Side by Side Diff: content/renderer/media/gpu/rtc_video_encoder.cc

Issue 2182183007: Handle scaling frames in RTCVideoEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: posciak@ comments. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/media/gpu/rtc_video_encoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/gpu/rtc_video_encoder.h" 5 #include "content/renderer/media/gpu/rtc_video_encoder.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 frame = media::VideoFrame::WrapExternalSharedMemory( 578 frame = media::VideoFrame::WrapExternalSharedMemory(
579 media::PIXEL_FORMAT_I420, input_frame_coded_size_, 579 media::PIXEL_FORMAT_I420, input_frame_coded_size_,
580 gfx::Rect(input_visible_size_), input_visible_size_, 580 gfx::Rect(input_visible_size_), input_visible_size_,
581 reinterpret_cast<uint8_t*>(input_buffer->memory()), 581 reinterpret_cast<uint8_t*>(input_buffer->memory()),
582 input_buffer->mapped_size(), input_buffer->handle(), 0, timestamp); 582 input_buffer->mapped_size(), input_buffer->handle(), 0, timestamp);
583 if (!frame.get()) { 583 if (!frame.get()) {
584 LogAndNotifyError(FROM_HERE, "failed to create frame", 584 LogAndNotifyError(FROM_HERE, "failed to create frame",
585 media::VideoEncodeAccelerator::kPlatformFailureError); 585 media::VideoEncodeAccelerator::kPlatformFailureError);
586 return; 586 return;
587 } 587 }
588 // Do a strided copy of the input frame to match the input requirements for 588
589 // the encoder. 589 // Do a strided copy and scale (if necessary) the input frame to match
590 // TODO(sheu): support zero-copy from WebRTC. http://crbug.com/269312 590 // the input requirements for the encoder.
591 if (libyuv::I420Copy(next_frame->video_frame_buffer()->DataY(), 591 // TODO(sheu): Support zero-copy from WebRTC. http://crbug.com/269312
592 next_frame->video_frame_buffer()->StrideY(), 592 // TODO(magjed): Downscale with kFilterBox in an image pyramid instead.
593 next_frame->video_frame_buffer()->DataU(), 593 if (libyuv::I420Scale(next_frame->video_frame_buffer()->DataY(),
594 next_frame->video_frame_buffer()->StrideU(), 594 next_frame->video_frame_buffer()->StrideY(),
595 next_frame->video_frame_buffer()->DataV(), 595 next_frame->video_frame_buffer()->DataU(),
596 next_frame->video_frame_buffer()->StrideV(), 596 next_frame->video_frame_buffer()->StrideU(),
597 frame->data(media::VideoFrame::kYPlane), 597 next_frame->video_frame_buffer()->DataV(),
598 frame->stride(media::VideoFrame::kYPlane), 598 next_frame->video_frame_buffer()->StrideV(),
599 frame->data(media::VideoFrame::kUPlane), 599 next_frame->width(), next_frame->height(),
600 frame->stride(media::VideoFrame::kUPlane), 600 frame->visible_data(media::VideoFrame::kYPlane),
601 frame->data(media::VideoFrame::kVPlane), 601 frame->stride(media::VideoFrame::kYPlane),
602 frame->stride(media::VideoFrame::kVPlane), 602 frame->visible_data(media::VideoFrame::kUPlane),
603 next_frame->width(), next_frame->height())) { 603 frame->stride(media::VideoFrame::kUPlane),
604 frame->visible_data(media::VideoFrame::kVPlane),
605 frame->stride(media::VideoFrame::kVPlane),
606 frame->visible_rect().width(),
607 frame->visible_rect().height(),
608 libyuv::kFilterBox)) {
604 LogAndNotifyError(FROM_HERE, "Failed to copy buffer", 609 LogAndNotifyError(FROM_HERE, "Failed to copy buffer",
605 media::VideoEncodeAccelerator::kPlatformFailureError); 610 media::VideoEncodeAccelerator::kPlatformFailureError);
606 return; 611 return;
607 } 612 }
608 } 613 }
609 frame->AddDestructionObserver(media::BindToCurrentLoop( 614 frame->AddDestructionObserver(media::BindToCurrentLoop(
610 base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index))); 615 base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index)));
611 video_encoder_->Encode(frame, next_frame_keyframe); 616 video_encoder_->Encode(frame, next_frame_keyframe);
612 input_buffers_free_.pop_back(); 617 input_buffers_free_.pop_back();
613 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK); 618 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", 879 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess",
875 init_retval == WEBRTC_VIDEO_CODEC_OK); 880 init_retval == WEBRTC_VIDEO_CODEC_OK);
876 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { 881 if (init_retval == WEBRTC_VIDEO_CODEC_OK) {
877 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", 882 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile",
878 profile, 883 profile,
879 media::VIDEO_CODEC_PROFILE_MAX + 1); 884 media::VIDEO_CODEC_PROFILE_MAX + 1);
880 } 885 }
881 } 886 }
882 887
883 } // namespace content 888 } // namespace content
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/media/gpu/rtc_video_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698