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

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

Issue 2382113002: Use clearer names for the PictureBuffer texture id members (Closed)
Patch Set: Added comments Created 4 years, 2 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 | « no previous file | content/renderer/pepper/video_decoder_shim.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_decoder.h" 5 #include "content/renderer/media/gpu/rtc_video_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 if (it == assigned_picture_buffers_.end()) { 376 if (it == assigned_picture_buffers_.end()) {
377 NOTREACHED() << "Missing picture buffer: " << id; 377 NOTREACHED() << "Missing picture buffer: " << id;
378 return; 378 return;
379 } 379 }
380 380
381 media::PictureBuffer buffer_to_dismiss = it->second; 381 media::PictureBuffer buffer_to_dismiss = it->second;
382 assigned_picture_buffers_.erase(it); 382 assigned_picture_buffers_.erase(it);
383 383
384 if (!picture_buffers_at_display_.count(id)) { 384 if (!picture_buffers_at_display_.count(id)) {
385 // We can delete the texture immediately as it's not being displayed. 385 // We can delete the texture immediately as it's not being displayed.
386 factories_->DeleteTexture(buffer_to_dismiss.texture_ids()[0]); 386 factories_->DeleteTexture(buffer_to_dismiss.client_texture_ids()[0]);
387 return; 387 return;
388 } 388 }
389 // Not destroying a texture in display in |picture_buffers_at_display_|. 389 // Not destroying a texture in display in |picture_buffers_at_display_|.
390 // Postpone deletion until after it's returned to us. 390 // Postpone deletion until after it's returned to us.
391 } 391 }
392 392
393 void RTCVideoDecoder::PictureReady(const media::Picture& picture) { 393 void RTCVideoDecoder::PictureReady(const media::Picture& picture) {
394 DVLOG(3) << "PictureReady"; 394 DVLOG(3) << "PictureReady";
395 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 395 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
396 396
(...skipping 20 matching lines...) Expand all
417 } 417 }
418 418
419 scoped_refptr<media::VideoFrame> frame = 419 scoped_refptr<media::VideoFrame> frame =
420 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_); 420 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_);
421 if (!frame) { 421 if (!frame) {
422 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 422 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
423 return; 423 return;
424 } 424 }
425 bool inserted = picture_buffers_at_display_ 425 bool inserted = picture_buffers_at_display_
426 .insert(std::make_pair(picture.picture_buffer_id(), 426 .insert(std::make_pair(picture.picture_buffer_id(),
427 pb.texture_ids()[0])) 427 pb.client_texture_ids()[0]))
428 .second; 428 .second;
429 DCHECK(inserted); 429 DCHECK(inserted);
430 430
431 // Create a WebRTC video frame. 431 // Create a WebRTC video frame.
432 webrtc::VideoFrame decoded_image( 432 webrtc::VideoFrame decoded_image(
433 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame), timestamp, 0, 433 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame), timestamp, 0,
434 webrtc::kVideoRotation_0); 434 webrtc::kVideoRotation_0);
435 435
436 // Invoke decode callback. WebRTC expects no callback after Release. 436 // Invoke decode callback. WebRTC expects no callback after Release.
437 { 437 {
(...skipping 25 matching lines...) Expand all
463 // platform can handle the former format natively. Make sure the 463 // platform can handle the former format natively. Make sure the
464 // correct format is used and everyone down the line understands it. 464 // correct format is used and everyone down the line understands it.
465 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { 465 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = {
466 gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), 466 gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(),
467 decoder_texture_target_)}; 467 decoder_texture_target_)};
468 scoped_refptr<media::VideoFrame> frame = 468 scoped_refptr<media::VideoFrame> frame =
469 media::VideoFrame::WrapNativeTextures( 469 media::VideoFrame::WrapNativeTextures(
470 pixel_format, holders, 470 pixel_format, holders,
471 media::BindToCurrentLoop(base::Bind( 471 media::BindToCurrentLoop(base::Bind(
472 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), 472 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
473 factories_, picture.picture_buffer_id(), pb.texture_ids()[0])), 473 factories_, picture.picture_buffer_id(),
474 pb.client_texture_ids()[0])),
474 pb.size(), visible_rect, visible_rect.size(), timestamp_ms); 475 pb.size(), visible_rect, visible_rect.size(), timestamp_ms);
475 if (frame && picture.allow_overlay()) { 476 if (frame && picture.allow_overlay()) {
476 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, 477 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY,
477 true); 478 true);
478 } 479 }
479 return frame; 480 return frame;
480 } 481 }
481 482
482 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32_t id) { 483 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32_t id) {
483 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; 484 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 754
754 void RTCVideoDecoder::DestroyTextures() { 755 void RTCVideoDecoder::DestroyTextures() {
755 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 756 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
756 757
757 // Not destroying PictureBuffers in |picture_buffers_at_display_| yet, since 758 // Not destroying PictureBuffers in |picture_buffers_at_display_| yet, since
758 // their textures may still be in use by the user of this RTCVideoDecoder. 759 // their textures may still be in use by the user of this RTCVideoDecoder.
759 for (const auto& picture_buffer_at_display : picture_buffers_at_display_) 760 for (const auto& picture_buffer_at_display : picture_buffers_at_display_)
760 assigned_picture_buffers_.erase(picture_buffer_at_display.first); 761 assigned_picture_buffers_.erase(picture_buffer_at_display.first);
761 762
762 for (const auto& assigned_picture_buffer : assigned_picture_buffers_) 763 for (const auto& assigned_picture_buffer : assigned_picture_buffers_)
763 factories_->DeleteTexture(assigned_picture_buffer.second.texture_ids()[0]); 764 factories_->DeleteTexture(
765 assigned_picture_buffer.second.client_texture_ids()[0]);
764 766
765 assigned_picture_buffers_.clear(); 767 assigned_picture_buffers_.clear();
766 } 768 }
767 769
768 void RTCVideoDecoder::DestroyVDA() { 770 void RTCVideoDecoder::DestroyVDA() {
769 DVLOG(2) << "DestroyVDA"; 771 DVLOG(2) << "DestroyVDA";
770 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 772 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
771 if (vda_) 773 if (vda_)
772 vda_.release()->Destroy(); 774 vda_.release()->Destroy();
773 DestroyTextures(); 775 DestroyTextures();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } 886 }
885 887
886 void RTCVideoDecoder::ClearPendingBuffers() { 888 void RTCVideoDecoder::ClearPendingBuffers() {
887 // Delete WebRTC input buffers. 889 // Delete WebRTC input buffers.
888 for (const auto& pending_buffer : pending_buffers_) 890 for (const auto& pending_buffer : pending_buffers_)
889 delete[] pending_buffer.first._buffer; 891 delete[] pending_buffer.first._buffer;
890 pending_buffers_.clear(); 892 pending_buffers_.clear();
891 } 893 }
892 894
893 } // namespace content 895 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/video_decoder_shim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698