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

Side by Side Diff: webrtc/modules/video_coding/utility/default_video_bitrate_allocator.cc

Issue 2510583002: Reland #2 of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h"
12 #include "webrtc/base/basictypes.h"
13 #include "webrtc/base/constructormagic.h"
14
15 namespace webrtc {
16
17 DefaultVideoBitrateAllocator::DefaultVideoBitrateAllocator(
18 const VideoCodec& codec)
19 : codec_(codec) {}
20
21 DefaultVideoBitrateAllocator::~DefaultVideoBitrateAllocator() {}
22
23 BitrateAllocation DefaultVideoBitrateAllocator::GetAllocation(
24 uint32_t total_bitrate_bps,
25 uint32_t framerate) {
26 BitrateAllocation allocation;
27 if (total_bitrate_bps == 0)
28 return allocation;
29
30 if (total_bitrate_bps < codec_.minBitrate * 1000) {
31 allocation.SetBitrate(0, 0, codec_.minBitrate * 1000);
32 } else if (codec_.maxBitrate > 0 &&
33 total_bitrate_bps > codec_.maxBitrate * 1000) {
34 allocation.SetBitrate(0, 0, codec_.maxBitrate * 1000);
35 } else {
36 allocation.SetBitrate(0, 0, total_bitrate_bps);
37 }
38
39 return allocation;
40 }
41
42 uint32_t DefaultVideoBitrateAllocator::GetPreferredBitrateBps(
43 uint32_t framerate) {
44 return GetAllocation(codec_.maxBitrate * 1000, framerate).get_sum_bps();
45 }
46
47 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698