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/rtc_video_decoder.h" | 5 #include "content/renderer/media/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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 visible_rect = picture.visible_rect(); | 377 visible_rect = picture.visible_rect(); |
378 | 378 |
379 const media::PictureBuffer& pb = it->second; | 379 const media::PictureBuffer& pb = it->second; |
380 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { | 380 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { |
381 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() | 381 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() |
382 << " should fit in " << pb.size().ToString(); | 382 << " should fit in " << pb.size().ToString(); |
383 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 383 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
384 return; | 384 return; |
385 } | 385 } |
386 | 386 |
| 387 media::VideoPixelFormat pixel_format = vda_->GetOutputFormat(); |
| 388 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) |
| 389 pixel_format = media::PIXEL_FORMAT_ARGB; |
| 390 |
387 scoped_refptr<media::VideoFrame> frame = | 391 scoped_refptr<media::VideoFrame> frame = |
388 CreateVideoFrame(picture, pb, timestamp, visible_rect); | 392 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format); |
389 if (!frame) { | 393 if (!frame) { |
390 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 394 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
391 return; | 395 return; |
392 } | 396 } |
393 bool inserted = picture_buffers_at_display_ | 397 bool inserted = picture_buffers_at_display_ |
394 .insert(std::make_pair(picture.picture_buffer_id(), | 398 .insert(std::make_pair(picture.picture_buffer_id(), |
395 pb.texture_ids()[0])) | 399 pb.texture_ids()[0])) |
396 .second; | 400 .second; |
397 DCHECK(inserted); | 401 DCHECK(inserted); |
398 | 402 |
(...skipping 10 matching lines...) Expand all Loading... |
409 reset_bitstream_buffer_id_)) { | 413 reset_bitstream_buffer_id_)) { |
410 decode_complete_callback_->Decoded(decoded_image); | 414 decode_complete_callback_->Decoded(decoded_image); |
411 } | 415 } |
412 } | 416 } |
413 } | 417 } |
414 | 418 |
415 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame( | 419 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame( |
416 const media::Picture& picture, | 420 const media::Picture& picture, |
417 const media::PictureBuffer& pb, | 421 const media::PictureBuffer& pb, |
418 uint32_t timestamp, | 422 uint32_t timestamp, |
419 const gfx::Rect& visible_rect) { | 423 const gfx::Rect& visible_rect, |
| 424 media::VideoPixelFormat pixel_format) { |
420 DCHECK(decoder_texture_target_); | 425 DCHECK(decoder_texture_target_); |
421 // Convert timestamp from 90KHz to ms. | 426 // Convert timestamp from 90KHz to ms. |
422 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( | 427 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( |
423 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); | 428 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); |
424 // TODO(mcasas): The incoming data is actually a YUV format, but is labelled | 429 // TODO(mcasas): The incoming data may actually be in a YUV format, but may be |
425 // as ARGB. This prevents the compositor from messing with it, since the | 430 // labelled as ARGB. This may or may not be reported by VDA, depending on |
426 // underlying platform can handle the former format natively. Make sure the | 431 // whether it provides an implementation of VDA::GetOutputFormat(). |
| 432 // This prevents the compositor from messing with it, since the underlying |
| 433 // platform can handle the former format natively. Make sure the |
427 // correct format is used and everyone down the line understands it. | 434 // correct format is used and everyone down the line understands it. |
428 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( | 435 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( |
429 media::PIXEL_FORMAT_ARGB, | 436 pixel_format, gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), |
430 gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), | 437 decoder_texture_target_), |
431 decoder_texture_target_), | |
432 media::BindToCurrentLoop(base::Bind( | 438 media::BindToCurrentLoop(base::Bind( |
433 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), | 439 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), |
434 factories_, picture.picture_buffer_id(), pb.texture_ids()[0])), | 440 factories_, picture.picture_buffer_id(), pb.texture_ids()[0])), |
435 pb.size(), visible_rect, visible_rect.size(), timestamp_ms); | 441 pb.size(), visible_rect, visible_rect.size(), timestamp_ms); |
436 if (frame && picture.allow_overlay()) { | 442 if (frame && picture.allow_overlay()) { |
437 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, | 443 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, |
438 true); | 444 true); |
439 } | 445 } |
440 return frame; | 446 return frame; |
441 } | 447 } |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 858 |
853 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { | 859 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { |
854 lock_.AssertAcquired(); | 860 lock_.AssertAcquired(); |
855 | 861 |
856 if (vda_error_counter_ == 0) | 862 if (vda_error_counter_ == 0) |
857 return; | 863 return; |
858 vda_error_counter_ = 0; | 864 vda_error_counter_ = 0; |
859 } | 865 } |
860 | 866 |
861 } // namespace content | 867 } // namespace content |
OLD | NEW |