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

Side by Side Diff: content/renderer/media/rtc_video_decoder.cc

Issue 850993002: gpu video: optimize HW video to SW canvas and implement it for WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android build fail Created 5 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 unified diff | Download patch
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/rtc_video_decoder.h" 5 #include "content/renderer/media/rtc_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 { 400 {
401 base::AutoLock auto_lock(lock_); 401 base::AutoLock auto_lock(lock_);
402 DCHECK(decode_complete_callback_ != NULL); 402 DCHECK(decode_complete_callback_ != NULL);
403 if (IsBufferAfterReset(picture.bitstream_buffer_id(), 403 if (IsBufferAfterReset(picture.bitstream_buffer_id(),
404 reset_bitstream_buffer_id_)) { 404 reset_bitstream_buffer_id_)) {
405 decode_complete_callback_->Decoded(decoded_image); 405 decode_complete_callback_->Decoded(decoded_image);
406 } 406 }
407 } 407 }
408 } 408 }
409 409
410 static void ReadPixelsSyncInner(
411 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories,
412 uint32 texture_id,
413 const gfx::Rect& visible_rect,
414 const SkBitmap& pixels,
415 base::WaitableEvent* event) {
416 factories->ReadPixels(texture_id, visible_rect, pixels);
417 event->Signal();
418 }
419
420 static void ReadPixelsSync(
421 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories,
422 uint32 texture_id,
423 const gfx::Rect& visible_rect,
424 const SkBitmap& pixels) {
425 base::WaitableEvent event(true, false);
426 if (!factories->GetTaskRunner()->PostTask(FROM_HERE,
427 base::Bind(&ReadPixelsSyncInner,
428 factories,
429 texture_id,
430 visible_rect,
431 pixels,
432 &event)))
433 return;
434 event.Wait();
435 }
436
437 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame( 410 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame(
438 const media::Picture& picture, 411 const media::Picture& picture,
439 const media::PictureBuffer& pb, 412 const media::PictureBuffer& pb,
440 uint32_t timestamp) { 413 uint32_t timestamp) {
441 gfx::Rect visible_rect(picture.visible_rect()); 414 gfx::Rect visible_rect(picture.visible_rect());
442 DCHECK(decoder_texture_target_); 415 DCHECK(decoder_texture_target_);
443 // Convert timestamp from 90KHz to ms. 416 // Convert timestamp from 90KHz to ms.
444 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( 417 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue(
445 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); 418 base::checked_cast<uint64_t>(timestamp) * 1000 / 90);
446 return media::VideoFrame::WrapNativeTexture( 419 return media::VideoFrame::WrapNativeTexture(
447 make_scoped_ptr(new gpu::MailboxHolder(pb.texture_mailbox(), 420 make_scoped_ptr(new gpu::MailboxHolder(pb.texture_mailbox(),
448 decoder_texture_target_, 0)), 421 decoder_texture_target_, 0)),
449 media::BindToCurrentLoop(base::Bind( 422 media::BindToCurrentLoop(base::Bind(
450 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), 423 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
451 factories_, picture.picture_buffer_id(), pb.texture_id())), 424 factories_, picture.picture_buffer_id(), pb.texture_id())),
452 pb.size(), visible_rect, visible_rect.size(), timestamp_ms, 425 pb.size(), visible_rect, visible_rect.size(), timestamp_ms,
453 base::Bind(&ReadPixelsSync, factories_, pb.texture_id(), visible_rect),
454 picture.allow_overlay()); 426 picture.allow_overlay());
455 } 427 }
456 428
457 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { 429 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) {
458 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; 430 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id;
459 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 431 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
460 432
461 std::map<int32, SHMBuffer*>::iterator it = 433 std::map<int32, SHMBuffer*>::iterator it =
462 bitstream_buffers_in_decoder_.find(id); 434 bitstream_buffers_in_decoder_.find(id);
463 if (it == bitstream_buffers_in_decoder_.end()) { 435 if (it == bitstream_buffers_in_decoder_.end()) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); 776 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample);
805 return status; 777 return status;
806 } 778 }
807 779
808 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 780 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
809 const { 781 const {
810 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 782 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
811 } 783 }
812 784
813 } // namespace content 785 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_gpu_video_accelerator_factories.cc ('k') | content/renderer/media/video_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698