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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/rtc_video_decoder.cc
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index 97303220305955b6aa268a2e2c0f224dd8648fbb..82c853c980c8d7508dbf79af6f649e5a443f629d 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -215,10 +215,20 @@ int32_t RTCVideoDecoder::Decode(
bool need_to_reset_for_midstream_resize = false;
if (inputImage._frameType == webrtc::kKeyFrame) {
- DVLOG(2) << "Got key frame. size=" << inputImage._encodedWidth << "x"
- << inputImage._encodedHeight;
+ gfx::Size new_frame_size(inputImage._encodedWidth,
+ inputImage._encodedHeight);
+ DVLOG(2) << "Got key frame. size=" << new_frame_size.ToString();
+
+ if (new_frame_size.width() > max_resolution_.width() ||
+ new_frame_size.width() < min_resolution_.width() ||
+ new_frame_size.height() > max_resolution_.height() ||
+ new_frame_size.height() < min_resolution_.height()) {
+ DVLOG(1) << "Resolution unsupported, falling back to software decode";
+ return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
+ }
+
gfx::Size prev_frame_size = frame_size_;
- frame_size_.SetSize(inputImage._encodedWidth, inputImage._encodedHeight);
+ frame_size_ = new_frame_size;
if (!kVDACanHandleMidstreamResize && !prev_frame_size.IsEmpty() &&
prev_frame_size != frame_size_) {
need_to_reset_for_midstream_resize = true;
@@ -655,12 +665,34 @@ void RTCVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id) {
vda_->ReusePictureBuffer(picture_buffer_id);
}
+bool RTCVideoDecoder::IsProfileSupported(media::VideoCodecProfile profile) {
+ DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
+ media::VideoDecodeAccelerator::SupportedProfiles supported_profiles =
+ factories_->GetVideoDecodeAcceleratorSupportedProfiles();
+
+ for (const auto& supported_profile : supported_profiles) {
+ if (profile == supported_profile.profile) {
+ min_resolution_ = supported_profile.min_resolution;
+ max_resolution_ = supported_profile.max_resolution;
+ return true;
+ }
+ }
+
+ return false;
+}
+
void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile,
base::WaitableEvent* waiter) {
DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
- vda_ = factories_->CreateVideoDecodeAccelerator();
- if (vda_ && !vda_->Initialize(profile, this))
- vda_.release()->Destroy();
+
+ if (!IsProfileSupported(profile)) {
+ DVLOG(1) << "Unsupported profile " << profile;
+ } else {
+ vda_ = factories_->CreateVideoDecodeAccelerator();
+ if (vda_ && !vda_->Initialize(profile, this))
+ vda_.release()->Destroy();
+ }
+
waiter->Signal();
}
« 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