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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc

Issue 2988963002: Add support for a forced software encoder fallback. (Closed)
Patch Set: address comments Created 3 years, 4 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 | « webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc ('k') | 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 (c) 2013 The WebRTC project authors. All Rights Reserved. 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
2 * 2 *
3 * Use of this source code is governed by a BSD-style license 3 * Use of this source code is governed by a BSD-style license
4 * that can be found in the LICENSE file in the root of the source 4 * that can be found in the LICENSE file in the root of the source
5 * tree. An additional intellectual property rights grant can be found 5 * tree. An additional intellectual property rights grant can be found
6 * in the file PATENTS. All contributing project authors may 6 * in the file PATENTS. All contributing project authors may
7 * be found in the AUTHORS file in the root of the source tree. 7 * be found in the AUTHORS file in the root of the source tree.
8 */ 8 */
9 9
10 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" 10 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h"
11 11
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <string.h> 13 #include <string.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/modules/include/module_common_types.h" 18 #include "webrtc/modules/include/module_common_types.h"
19 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 19 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
20 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 20 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
21 #include "webrtc/rtc_base/checks.h" 21 #include "webrtc/rtc_base/checks.h"
22 #include "webrtc/system_wrappers/include/field_trial.h"
22 23
23 #include "vpx/vpx_encoder.h" 24 #include "vpx/vpx_encoder.h"
24 #include "vpx/vp8cx.h" 25 #include "vpx/vp8cx.h"
25 26
26 namespace webrtc { 27 namespace webrtc {
27 28
28 TemporalLayers::FrameConfig::FrameConfig() 29 TemporalLayers::FrameConfig::FrameConfig()
29 : FrameConfig(kNone, kNone, kNone, false) {} 30 : FrameConfig(kNone, kNone, kNone, false) {}
30 31
31 TemporalLayers::FrameConfig::FrameConfig(TemporalLayers::BufferFlags last, 32 TemporalLayers::FrameConfig::FrameConfig(TemporalLayers::BufferFlags last,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 TemporalLayers::kReference, TemporalLayers::kFreezeEntropy)}; 242 TemporalLayers::kReference, TemporalLayers::kFreezeEntropy)};
242 default: 243 default:
243 RTC_NOTREACHED(); 244 RTC_NOTREACHED();
244 break; 245 break;
245 } 246 }
246 RTC_NOTREACHED(); 247 RTC_NOTREACHED();
247 return {TemporalLayers::FrameConfig( 248 return {TemporalLayers::FrameConfig(
248 TemporalLayers::kNone, TemporalLayers::kNone, TemporalLayers::kNone)}; 249 TemporalLayers::kNone, TemporalLayers::kNone, TemporalLayers::kNone)};
249 } 250 }
250 251
252 // Temporary fix for forced SW fallback.
253 // For VP8 SW codec, |TemporalLayers| is created and reported to
254 // SimulcastRateAllocator::OnTemporalLayersCreated but not for VP8 HW.
255 // Causes an issue when going from forced SW -> HW as |TemporalLayers| is not
256 // deregistred when deleted by SW codec (tl factory might not exist, owned by
257 // SimulcastRateAllocator).
258 bool ExcludeOnTemporalLayersCreated(int num_temporal_layers) {
259 return webrtc::field_trial::IsEnabled("WebRTC-VP8-Forced-Fallback-Encoder") &&
260 num_temporal_layers == 1;
261 }
251 } // namespace 262 } // namespace
252 263
253 DefaultTemporalLayers::DefaultTemporalLayers(int number_of_temporal_layers, 264 DefaultTemporalLayers::DefaultTemporalLayers(int number_of_temporal_layers,
254 uint8_t initial_tl0_pic_idx) 265 uint8_t initial_tl0_pic_idx)
255 : num_layers_(std::max(1, number_of_temporal_layers)), 266 : num_layers_(std::max(1, number_of_temporal_layers)),
256 temporal_ids_(GetTemporalIds(num_layers_)), 267 temporal_ids_(GetTemporalIds(num_layers_)),
257 temporal_layer_sync_(GetTemporalLayerSync(num_layers_)), 268 temporal_layer_sync_(GetTemporalLayerSync(num_layers_)),
258 temporal_pattern_(GetTemporalPattern(num_layers_)), 269 temporal_pattern_(GetTemporalPattern(num_layers_)),
259 tl0_pic_idx_(initial_tl0_pic_idx), 270 tl0_pic_idx_(initial_tl0_pic_idx),
260 pattern_idx_(255), 271 pattern_idx_(255),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 vp8_info->tl0PicIdx = tl0_pic_idx_; 376 vp8_info->tl0PicIdx = tl0_pic_idx_;
366 } 377 }
367 } 378 }
368 379
369 TemporalLayers* TemporalLayersFactory::Create( 380 TemporalLayers* TemporalLayersFactory::Create(
370 int simulcast_id, 381 int simulcast_id,
371 int temporal_layers, 382 int temporal_layers,
372 uint8_t initial_tl0_pic_idx) const { 383 uint8_t initial_tl0_pic_idx) const {
373 TemporalLayers* tl = 384 TemporalLayers* tl =
374 new DefaultTemporalLayers(temporal_layers, initial_tl0_pic_idx); 385 new DefaultTemporalLayers(temporal_layers, initial_tl0_pic_idx);
375 if (listener_) 386 if (listener_ && !ExcludeOnTemporalLayersCreated(temporal_layers))
376 listener_->OnTemporalLayersCreated(simulcast_id, tl); 387 listener_->OnTemporalLayersCreated(simulcast_id, tl);
377 return tl; 388 return tl;
378 } 389 }
379 390
380 void TemporalLayersFactory::SetListener(TemporalLayersListener* listener) { 391 void TemporalLayersFactory::SetListener(TemporalLayersListener* listener) {
381 listener_ = listener; 392 listener_ = listener;
382 } 393 }
383 394
384 } // namespace webrtc 395 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698