| Index: content/renderer/media/gpu/rtc_video_decoder.cc
|
| diff --git a/content/renderer/media/gpu/rtc_video_decoder.cc b/content/renderer/media/gpu/rtc_video_decoder.cc
|
| index 9a44d326772fdf513f6b3bdb4623e0d4f4f0365b..e373f2f0246780f0961825f363095f917e155642 100644
|
| --- a/content/renderer/media/gpu/rtc_video_decoder.cc
|
| +++ b/content/renderer/media/gpu/rtc_video_decoder.cc
|
| @@ -305,14 +305,13 @@ int32_t RTCVideoDecoder::Release() {
|
| return WEBRTC_VIDEO_CODEC_OK;
|
| }
|
|
|
| -void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count,
|
| +void RTCVideoDecoder::ProvidePictureBuffers(uint32_t buffer_count,
|
| media::VideoPixelFormat format,
|
| uint32_t textures_per_buffer,
|
| const gfx::Size& size,
|
| uint32_t texture_target) {
|
| DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
|
| DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target;
|
| - DCHECK_EQ(1u, textures_per_buffer);
|
|
|
| if (!vda_)
|
| return;
|
| @@ -331,28 +330,35 @@ void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count,
|
| }
|
|
|
| pixel_format_ = format;
|
| - if (!factories_->CreateTextures(count,
|
| - size,
|
| - &texture_ids,
|
| + const uint32_t texture_count = buffer_count * textures_per_buffer;
|
| + if (!factories_->CreateTextures(texture_count, size, &texture_ids,
|
| &texture_mailboxes,
|
| decoder_texture_target_)) {
|
| NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
|
| return;
|
| }
|
| - DCHECK_EQ(count, texture_ids.size());
|
| - DCHECK_EQ(count, texture_mailboxes.size());
|
| + DCHECK_EQ(texture_count, texture_ids.size());
|
| + DCHECK_EQ(texture_count, texture_mailboxes.size());
|
|
|
| std::vector<media::PictureBuffer> picture_buffers;
|
| - for (size_t i = 0; i < texture_ids.size(); ++i) {
|
| + for (size_t buffer_index = 0; buffer_index < buffer_count; ++buffer_index) {
|
| media::PictureBuffer::TextureIds ids;
|
| - ids.push_back(texture_ids[i]);
|
| std::vector<gpu::Mailbox> mailboxes;
|
| - mailboxes.push_back(texture_mailboxes[i]);
|
| + for (size_t texture_index = 0; texture_index < textures_per_buffer;
|
| + ++texture_index) {
|
| + const size_t texture_id =
|
| + texture_index + textures_per_buffer * buffer_index;
|
| + ids.push_back(texture_ids[texture_id]);
|
| + mailboxes.push_back(texture_mailboxes[texture_id]);
|
| + }
|
|
|
| picture_buffers.push_back(
|
| media::PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes));
|
| - bool inserted = assigned_picture_buffers_.insert(std::make_pair(
|
| - picture_buffers.back().id(), picture_buffers.back())).second;
|
| + const bool inserted =
|
| + assigned_picture_buffers_
|
| + .insert(std::make_pair(picture_buffers.back().id(),
|
| + picture_buffers.back()))
|
| + .second;
|
| DCHECK(inserted);
|
| }
|
| vda_->AssignPictureBuffers(picture_buffers);
|
| @@ -374,7 +380,8 @@ void RTCVideoDecoder::DismissPictureBuffer(int32_t id) {
|
|
|
| if (!picture_buffers_at_display_.count(id)) {
|
| // We can delete the texture immediately as it's not being displayed.
|
| - factories_->DeleteTexture(buffer_to_dismiss.client_texture_ids()[0]);
|
| + for (const auto& id : buffer_to_dismiss.client_texture_ids())
|
| + factories_->DeleteTexture(id);
|
| return;
|
| }
|
| // Not destroying a texture in display in |picture_buffers_at_display_|.
|
| @@ -415,7 +422,7 @@ void RTCVideoDecoder::PictureReady(const media::Picture& picture) {
|
| }
|
| bool inserted = picture_buffers_at_display_
|
| .insert(std::make_pair(picture.picture_buffer_id(),
|
| - pb.client_texture_ids()[0]))
|
| + pb.client_texture_ids()))
|
| .second;
|
| DCHECK(inserted);
|
|
|
| @@ -454,16 +461,18 @@ scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame(
|
| // This prevents the compositor from messing with it, since the underlying
|
| // platform can handle the former format natively. Make sure the
|
| // correct format is used and everyone down the line understands it.
|
| - gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = {
|
| - gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(),
|
| - decoder_texture_target_)};
|
| + gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes];
|
| + for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) {
|
| + holders[i].mailbox = pb.texture_mailbox(i);
|
| + holders[i].texture_target = decoder_texture_target_;
|
| + }
|
| scoped_refptr<media::VideoFrame> frame =
|
| media::VideoFrame::WrapNativeTextures(
|
| pixel_format, holders,
|
| - media::BindToCurrentLoop(base::Bind(
|
| - &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
|
| - factories_, picture.picture_buffer_id(),
|
| - pb.client_texture_ids()[0])),
|
| + media::BindToCurrentLoop(
|
| + base::Bind(&RTCVideoDecoder::ReleaseMailbox,
|
| + weak_factory_.GetWeakPtr(), factories_,
|
| + picture.picture_buffer_id(), pb.client_texture_ids())),
|
| pb.size(), visible_rect, visible_rect.size(), timestamp_ms);
|
| if (frame && picture.allow_overlay()) {
|
| frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY,
|
| @@ -686,7 +695,7 @@ void RTCVideoDecoder::ReleaseMailbox(
|
| base::WeakPtr<RTCVideoDecoder> decoder,
|
| media::GpuVideoAcceleratorFactories* factories,
|
| int64_t picture_buffer_id,
|
| - uint32_t texture_id,
|
| + const media::PictureBuffer::TextureIds& texture_ids,
|
| const gpu::SyncToken& release_sync_token) {
|
| DCHECK(factories->GetTaskRunner()->BelongsToCurrentThread());
|
| factories->WaitSyncToken(release_sync_token);
|
| @@ -697,7 +706,8 @@ void RTCVideoDecoder::ReleaseMailbox(
|
| }
|
| // It's the last chance to delete the texture after display,
|
| // because RTCVideoDecoder was destructed.
|
| - factories->DeleteTexture(texture_id);
|
| + for (const auto& id : texture_ids)
|
| + factories->DeleteTexture(id);
|
| }
|
|
|
| void RTCVideoDecoder::ReusePictureBuffer(int64_t picture_buffer_id) {
|
| @@ -707,13 +717,14 @@ void RTCVideoDecoder::ReusePictureBuffer(int64_t picture_buffer_id) {
|
| DCHECK(!picture_buffers_at_display_.empty());
|
| PictureBufferTextureMap::iterator display_iterator =
|
| picture_buffers_at_display_.find(picture_buffer_id);
|
| - uint32_t texture_id = display_iterator->second;
|
| + const auto texture_ids = display_iterator->second;
|
| DCHECK(display_iterator != picture_buffers_at_display_.end());
|
| picture_buffers_at_display_.erase(display_iterator);
|
|
|
| if (!assigned_picture_buffers_.count(picture_buffer_id)) {
|
| // This picture was dismissed while in display, so we postponed deletion.
|
| - factories_->DeleteTexture(texture_id);
|
| + for (const auto& id : texture_ids)
|
| + factories_->DeleteTexture(id);
|
| return;
|
| }
|
|
|
| @@ -765,9 +776,10 @@ void RTCVideoDecoder::DestroyTextures() {
|
| for (const auto& picture_buffer_at_display : picture_buffers_at_display_)
|
| assigned_picture_buffers_.erase(picture_buffer_at_display.first);
|
|
|
| - for (const auto& assigned_picture_buffer : assigned_picture_buffers_)
|
| - factories_->DeleteTexture(
|
| - assigned_picture_buffer.second.client_texture_ids()[0]);
|
| + for (const auto& assigned_picture_buffer : assigned_picture_buffers_) {
|
| + for (const auto& id : assigned_picture_buffer.second.client_texture_ids())
|
| + factories_->DeleteTexture(id);
|
| + }
|
|
|
| assigned_picture_buffers_.clear();
|
| }
|
|
|