Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (libyuv::I420Scale(next_frame->video_frame_buffer()->DataY(), |
| 593 next_frame->video_frame_buffer()->DataU(), | 593 next_frame->video_frame_buffer()->StrideY(), |
| 594 next_frame->video_frame_buffer()->StrideU(), | 594 next_frame->video_frame_buffer()->DataU(), |
| 595 next_frame->video_frame_buffer()->DataV(), | 595 next_frame->video_frame_buffer()->StrideU(), |
| 596 next_frame->video_frame_buffer()->StrideV(), | 596 next_frame->video_frame_buffer()->DataV(), |
| 597 frame->data(media::VideoFrame::kYPlane), | 597 next_frame->video_frame_buffer()->StrideV(), |
| 598 frame->stride(media::VideoFrame::kYPlane), | 598 next_frame->width(), next_frame->height(), |
| 599 frame->data(media::VideoFrame::kUPlane), | 599 frame->visible_data(media::VideoFrame::kYPlane), |
| 600 frame->stride(media::VideoFrame::kUPlane), | 600 frame->stride(media::VideoFrame::kYPlane), |
| 601 frame->data(media::VideoFrame::kVPlane), | 601 frame->visible_data(media::VideoFrame::kUPlane), |
| 602 frame->stride(media::VideoFrame::kVPlane), | 602 frame->stride(media::VideoFrame::kUPlane), |
| 603 next_frame->width(), next_frame->height())) { | 603 frame->visible_data(media::VideoFrame::kVPlane), |
| 604 frame->stride(media::VideoFrame::kVPlane), | |
| 605 frame->visible_rect().width(), | |
| 606 frame->visible_rect().height(), | |
| 607 libyuv::kFilterBilinear)) { | |
|
Pawel Osciak
2016/07/28 01:48:08
Do we have an idea of the performance impact of bi
tommi (sloooow) - chröme
2016/07/28 07:40:40
+1
magjed_chromium
2016/07/28 10:27:19
I think we should use libyuv::kFilterBox instead o
emircan
2016/07/28 19:35:45
SimulcastEncoderAdapter uses libyuv::kFilterBiline
emircan
2016/07/28 19:35:45
Thanks for the metrics. Would you recommend changi
magjed_chromium
2016/07/30 08:30:17
I think it's ok to use kFilterBilinear for now. Yo
| |
| 604 LogAndNotifyError(FROM_HERE, "Failed to copy buffer", | 608 LogAndNotifyError(FROM_HERE, "Failed to copy buffer", |
| 605 media::VideoEncodeAccelerator::kPlatformFailureError); | 609 media::VideoEncodeAccelerator::kPlatformFailureError); |
| 606 return; | 610 return; |
| 607 } | 611 } |
| 608 } | 612 } |
| 609 frame->AddDestructionObserver(media::BindToCurrentLoop( | 613 frame->AddDestructionObserver(media::BindToCurrentLoop( |
| 610 base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index))); | 614 base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index))); |
| 611 video_encoder_->Encode(frame, next_frame_keyframe); | 615 video_encoder_->Encode(frame, next_frame_keyframe); |
| 612 input_buffers_free_.pop_back(); | 616 input_buffers_free_.pop_back(); |
| 613 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK); | 617 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_OK); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 878 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
| 875 init_retval == WEBRTC_VIDEO_CODEC_OK); | 879 init_retval == WEBRTC_VIDEO_CODEC_OK); |
| 876 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 880 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
| 877 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 881 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
| 878 profile, | 882 profile, |
| 879 media::VIDEO_CODEC_PROFILE_MAX + 1); | 883 media::VIDEO_CODEC_PROFILE_MAX + 1); |
| 880 } | 884 } |
| 881 } | 885 } |
| 882 | 886 |
| 883 } // namespace content | 887 } // namespace content |
| OLD | NEW |