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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h

Issue 2503443002: Let Opus increase complexity for low bitrates (Closed)
Patch Set: Fixing a typo Created 4 years 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 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
13 13
14 #include <functional> 14 #include <functional>
15 #include <memory>
16 #include <string>
15 #include <vector> 17 #include <vector>
16 18
17 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/base/optional.h" 20 #include "webrtc/base/optional.h"
19 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 21 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
20 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" 22 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
22 24
23 namespace webrtc { 25 namespace webrtc {
24 26
25 struct CodecInst; 27 struct CodecInst;
26 28
27 class AudioEncoderOpus final : public AudioEncoder { 29 class AudioEncoderOpus final : public AudioEncoder {
28 public: 30 public:
29 enum ApplicationMode { 31 enum ApplicationMode {
30 kVoip = 0, 32 kVoip = 0,
31 kAudio = 1, 33 kAudio = 1,
32 }; 34 };
33 35
34 struct Config { 36 struct Config {
35 Config(); 37 Config();
36 Config(const Config&); 38 Config(const Config&);
37 ~Config(); 39 ~Config();
38 Config& operator=(const Config&); 40 Config& operator=(const Config&);
39 41
40 bool IsOk() const; 42 bool IsOk() const;
41 int GetBitrateBps() const; 43 int GetBitrateBps() const;
44 // Returns empty if the current bitrate falls within the hysteresis window,
45 // defined by complexity_threshold_bps +/- complexity_threshold_window_bps.
46 // Otherwise, returns the current complexity depending on whether the
47 // current bitrate is above or below complexity_threshold_bps.
48 rtc::Optional<int> GetNewComplexity() const;
42 49
43 int frame_size_ms = 20; 50 int frame_size_ms = 20;
44 size_t num_channels = 1; 51 size_t num_channels = 1;
45 int payload_type = 120; 52 int payload_type = 120;
46 ApplicationMode application = kVoip; 53 ApplicationMode application = kVoip;
47 rtc::Optional<int> bitrate_bps; // Unset means to use default value. 54 rtc::Optional<int> bitrate_bps; // Unset means to use default value.
48 bool fec_enabled = false; 55 bool fec_enabled = false;
49 int max_playback_rate_hz = 48000; 56 int max_playback_rate_hz = 48000;
50 int complexity = kDefaultComplexity; 57 int complexity = kDefaultComplexity;
58 // This value may change in the struct's constructor.
59 int low_rate_complexity = kDefaultComplexity;
60 // low_rate_complexity is used when the bitrate is below this threshold.
61 int complexity_threshold_bps = 12500;
62 int complexity_threshold_window_bps = 1500;
51 bool dtx_enabled = false; 63 bool dtx_enabled = false;
52 std::vector<int> supported_frame_lengths_ms; 64 std::vector<int> supported_frame_lengths_ms;
53 const Clock* clock = nullptr; 65 const Clock* clock = nullptr;
54 66
55 private: 67 private:
56 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) 68 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM)
57 // If we are on Android, iOS and/or ARM, use a lower complexity setting as 69 // If we are on Android, iOS and/or ARM, use a lower complexity setting as
58 // default, to save encoder complexity. 70 // default, to save encoder complexity.
59 static const int kDefaultComplexity = 5; 71 static const int kDefaultComplexity = 5;
60 #else 72 #else
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const std::string& config_string, 145 const std::string& config_string,
134 const Clock* clock) const; 146 const Clock* clock) const;
135 147
136 Config config_; 148 Config config_;
137 double packet_loss_rate_; 149 double packet_loss_rate_;
138 std::vector<int16_t> input_buffer_; 150 std::vector<int16_t> input_buffer_;
139 OpusEncInst* inst_; 151 OpusEncInst* inst_;
140 uint32_t first_timestamp_in_buffer_; 152 uint32_t first_timestamp_in_buffer_;
141 size_t num_channels_to_encode_; 153 size_t num_channels_to_encode_;
142 int next_frame_length_ms_; 154 int next_frame_length_ms_;
155 int complexity_;
143 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; 156 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_;
144 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; 157 AudioNetworkAdaptorCreator audio_network_adaptor_creator_;
145 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; 158 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_;
146 159
147 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 160 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
148 }; 161 };
149 162
150 } // namespace webrtc 163 } // namespace webrtc
151 164
152 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 165 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/BUILD.gn ('k') | webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698