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

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

Issue 1150543002: RtcVideoDecoder: fall back to SW decode for unsupported profiles/resolutions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rtcvd unittest Created 5 years, 7 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // change gracefully need to have their clients cover for them, and we do that 208 // change gracefully need to have their clients cover for them, and we do that
209 // here. 209 // here.
210 #ifdef ANDROID 210 #ifdef ANDROID
211 const bool kVDACanHandleMidstreamResize = false; 211 const bool kVDACanHandleMidstreamResize = false;
212 #else 212 #else
213 const bool kVDACanHandleMidstreamResize = true; 213 const bool kVDACanHandleMidstreamResize = true;
214 #endif 214 #endif
215 215
216 bool need_to_reset_for_midstream_resize = false; 216 bool need_to_reset_for_midstream_resize = false;
217 if (inputImage._frameType == webrtc::kKeyFrame) { 217 if (inputImage._frameType == webrtc::kKeyFrame) {
218 DVLOG(2) << "Got key frame. size=" << inputImage._encodedWidth << "x" 218 gfx::Size new_frame_size(inputImage._encodedWidth,
219 << inputImage._encodedHeight; 219 inputImage._encodedHeight);
220 DVLOG(2) << "Got key frame. size=" << new_frame_size.ToString();
221
222 if (new_frame_size.width() > max_resolution_.width() ||
223 new_frame_size.width() < min_resolution_.width() ||
224 new_frame_size.height() > max_resolution_.height() ||
225 new_frame_size.height() < min_resolution_.height()) {
226 DVLOG(1) << "Resolution unsupported, falling back to software decode";
227 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
228 }
229
220 gfx::Size prev_frame_size = frame_size_; 230 gfx::Size prev_frame_size = frame_size_;
221 frame_size_.SetSize(inputImage._encodedWidth, inputImage._encodedHeight); 231 frame_size_ = new_frame_size;
222 if (!kVDACanHandleMidstreamResize && !prev_frame_size.IsEmpty() && 232 if (!kVDACanHandleMidstreamResize && !prev_frame_size.IsEmpty() &&
223 prev_frame_size != frame_size_) { 233 prev_frame_size != frame_size_) {
224 need_to_reset_for_midstream_resize = true; 234 need_to_reset_for_midstream_resize = true;
225 } 235 }
226 } else if (IsFirstBufferAfterReset(next_bitstream_buffer_id_, 236 } else if (IsFirstBufferAfterReset(next_bitstream_buffer_id_,
227 reset_bitstream_buffer_id_)) { 237 reset_bitstream_buffer_id_)) {
228 // TODO(wuchengli): VDA should handle it. Remove this when 238 // TODO(wuchengli): VDA should handle it. Remove this when
229 // http://crosbug.com/p/21913 is fixed. 239 // http://crosbug.com/p/21913 is fixed.
230 DVLOG(1) << "The first frame should be a key frame. Drop this."; 240 DVLOG(1) << "The first frame should be a key frame. Drop this.";
231 return WEBRTC_VIDEO_CODEC_ERROR; 241 return WEBRTC_VIDEO_CODEC_ERROR;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 // This picture was dismissed while in display, so we postponed deletion. 658 // This picture was dismissed while in display, so we postponed deletion.
649 factories_->DeleteTexture(texture_id); 659 factories_->DeleteTexture(texture_id);
650 return; 660 return;
651 } 661 }
652 662
653 // DestroyVDA() might already have been called. 663 // DestroyVDA() might already have been called.
654 if (vda_) 664 if (vda_)
655 vda_->ReusePictureBuffer(picture_buffer_id); 665 vda_->ReusePictureBuffer(picture_buffer_id);
656 } 666 }
657 667
668 bool RTCVideoDecoder::IsProfileSupported(media::VideoCodecProfile profile) {
669 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
670 media::VideoDecodeAccelerator::SupportedProfiles supported_profiles =
671 factories_->GetVideoDecodeAcceleratorSupportedProfiles();
672
673 for (const auto& supported_profile : supported_profiles) {
674 if (profile == supported_profile.profile) {
675 min_resolution_ = supported_profile.min_resolution;
676 max_resolution_ = supported_profile.max_resolution;
677 return true;
678 }
679 }
680
681 return false;
682 }
683
658 void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile, 684 void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile,
659 base::WaitableEvent* waiter) { 685 base::WaitableEvent* waiter) {
660 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 686 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
661 vda_ = factories_->CreateVideoDecodeAccelerator(); 687
662 if (vda_ && !vda_->Initialize(profile, this)) 688 if (!IsProfileSupported(profile)) {
663 vda_.release()->Destroy(); 689 DVLOG(1) << "Unsupported profile " << profile;
690 } else {
691 vda_ = factories_->CreateVideoDecodeAccelerator();
692 if (vda_ && !vda_->Initialize(profile, this))
693 vda_.release()->Destroy();
694 }
695
664 waiter->Signal(); 696 waiter->Signal();
665 } 697 }
666 698
667 void RTCVideoDecoder::DestroyTextures() { 699 void RTCVideoDecoder::DestroyTextures() {
668 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 700 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
669 701
670 // Not destroying PictureBuffers in |picture_buffers_at_display_| yet, since 702 // Not destroying PictureBuffers in |picture_buffers_at_display_| yet, since
671 // their textures may still be in use by the user of this RTCVideoDecoder. 703 // their textures may still be in use by the user of this RTCVideoDecoder.
672 for (PictureBufferTextureMap::iterator it = 704 for (PictureBufferTextureMap::iterator it =
673 picture_buffers_at_display_.begin(); 705 picture_buffers_at_display_.begin();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); 810 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample);
779 return status; 811 return status;
780 } 812 }
781 813
782 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 814 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
783 const { 815 const {
784 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 816 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
785 } 817 }
786 818
787 } // namespace content 819 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698