Index: content/renderer/media/rtc_video_encoder.cc |
diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc |
index 416317d36354f531bca3797711529fc9cc5b5f3f..4df6478abdf132392b92fb6e8c630f2059320903 100644 |
--- a/content/renderer/media/rtc_video_encoder.cc |
+++ b/content/renderer/media/rtc_video_encoder.cc |
@@ -268,7 +268,9 @@ void RTCVideoEncoder::Impl::RequireBitstreamBuffers( |
for (unsigned int i = 0; i < input_count + kInputBufferExtraCount; ++i) { |
base::SharedMemory* shm = |
- gpu_factories_->CreateSharedMemory(input_coded_size.GetArea() * 3 / 2); |
+ gpu_factories_->CreateSharedMemory( |
+ media::VideoFrame::AllocationSize(media::VideoFrame::I420, |
+ input_coded_size)); |
if (!shm) { |
DLOG(ERROR) << "Impl::RequireBitstreamBuffers(): " |
"failed to create input buffer " << i; |
@@ -434,6 +436,7 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() { |
gfx::Rect(input_visible_size_), |
input_visible_size_, |
y_dst, |
+ dst - y_dst, |
input_buffer->handle(), |
base::TimeDelta(), |
base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index)); |
@@ -485,6 +488,7 @@ RTCVideoEncoder::RTCVideoEncoder( |
: video_codec_type_(type), |
video_codec_profile_(profile), |
gpu_factories_(gpu_factories), |
+ weak_this_factory_(this), |
encoded_image_callback_(NULL), |
impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED) { |
DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; |
@@ -506,8 +510,8 @@ int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(!impl_); |
- weak_this_factory_.reset(new base::WeakPtrFactory<RTCVideoEncoder>(this)); |
- impl_ = new Impl(weak_this_factory_->GetWeakPtr(), gpu_factories_); |
+ weak_this_factory_.InvalidateWeakPtrs(); |
+ impl_ = new Impl(weak_this_factory_.GetWeakPtr(), gpu_factories_); |
base::WaitableEvent initialization_waiter(true, false); |
int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
gpu_factories_->GetMessageLoop()->PostTask( |
@@ -578,7 +582,7 @@ int32_t RTCVideoEncoder::Release() { |
gpu_factories_->GetMessageLoop()->PostTask( |
FROM_HERE, base::Bind(&RTCVideoEncoder::Impl::Destroy, impl_)); |
impl_ = NULL; |
- weak_this_factory_.reset(); |
+ weak_this_factory_.InvalidateWeakPtrs(); |
impl_status_ = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
} |
return WEBRTC_VIDEO_CODEC_OK; |