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

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

Issue 2024303003: Enable RTCVideoDecoder SW H264 fallback only when it is available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | no next file » | 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/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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
17 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h" 17 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h"
18 #include "gpu/command_buffer/common/mailbox_holder.h" 18 #include "gpu/command_buffer/common/mailbox_holder.h"
19 #include "media/base/bind_to_current_loop.h" 19 #include "media/base/bind_to_current_loop.h"
20 #include "media/renderers/gpu_video_accelerator_factories.h" 20 #include "media/renderers/gpu_video_accelerator_factories.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "third_party/webrtc/base/bind.h" 22 #include "third_party/webrtc/base/bind.h"
23 #include "third_party/webrtc/base/refcount.h" 23 #include "third_party/webrtc/base/refcount.h"
24 #include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h"
24 #include "third_party/webrtc/video_frame.h" 25 #include "third_party/webrtc/video_frame.h"
25 26
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
27 #include "base/command_line.h" 28 #include "base/command_line.h"
28 #include "base/win/windows_version.h" 29 #include "base/win/windows_version.h"
29 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
30 #endif // defined(OS_WIN) 31 #endif // defined(OS_WIN)
31 32
32 namespace content { 33 namespace content {
33 34
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::AutoLock auto_lock(lock_); 173 base::AutoLock auto_lock(lock_);
173 174
174 if (state_ == UNINITIALIZED || !decode_complete_callback_) { 175 if (state_ == UNINITIALIZED || !decode_complete_callback_) {
175 LOG(ERROR) << "The decoder has not initialized."; 176 LOG(ERROR) << "The decoder has not initialized.";
176 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 177 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
177 } 178 }
178 179
179 if (state_ == DECODE_ERROR) { 180 if (state_ == DECODE_ERROR) {
180 LOG(ERROR) << "Decoding error occurred."; 181 LOG(ERROR) << "Decoding error occurred.";
181 // Try reseting the session up to |kNumVDAErrorsHandled| times. 182 // Try reseting the session up to |kNumVDAErrorsHandled| times.
182 if (vda_error_counter_ > kNumVDAErrorsBeforeSWFallback) { 183 // Check if SW H264 implementation is available before falling back.
184 if (vda_error_counter_ > kNumVDAErrorsBeforeSWFallback &&
185 (video_codec_type_ != webrtc::kVideoCodecH264 ||
186 webrtc::H264Decoder::IsSupported())) {
183 DLOG(ERROR) << vda_error_counter_ 187 DLOG(ERROR) << vda_error_counter_
184 << " errors reported by VDA, falling back to software decode"; 188 << " errors reported by VDA, falling back to software decode";
185 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; 189 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
186 } 190 }
187 base::AutoUnlock auto_unlock(lock_); 191 base::AutoUnlock auto_unlock(lock_);
188 Release(); 192 Release();
189 return WEBRTC_VIDEO_CODEC_ERROR; 193 return WEBRTC_VIDEO_CODEC_ERROR;
190 } 194 }
191 195
192 if (missingFrames || !inputImage._completeFrame) { 196 if (missingFrames || !inputImage._completeFrame) {
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 881
878 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { 882 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() {
879 lock_.AssertAcquired(); 883 lock_.AssertAcquired();
880 884
881 if (vda_error_counter_ == 0) 885 if (vda_error_counter_ == 0)
882 return; 886 return;
883 vda_error_counter_ = 0; 887 vda_error_counter_ = 0;
884 } 888 }
885 889
886 } // namespace content 890 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698