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

Side by Side Diff: webrtc/modules/audio_coding/neteq/timestamp_scaler.cc

Issue 1424083002: Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 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
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 26 matching lines...) Expand all
37 37
38 uint32_t TimestampScaler::ToInternal(uint32_t external_timestamp, 38 uint32_t TimestampScaler::ToInternal(uint32_t external_timestamp,
39 uint8_t rtp_payload_type) { 39 uint8_t rtp_payload_type) {
40 const DecoderDatabase::DecoderInfo* info = 40 const DecoderDatabase::DecoderInfo* info =
41 decoder_database_.GetDecoderInfo(rtp_payload_type); 41 decoder_database_.GetDecoderInfo(rtp_payload_type);
42 if (!info) { 42 if (!info) {
43 // Payload type is unknown. Do not scale. 43 // Payload type is unknown. Do not scale.
44 return external_timestamp; 44 return external_timestamp;
45 } 45 }
46 switch (info->codec_type) { 46 switch (info->codec_type) {
47 case kDecoderG722: 47 case NetEqDecoder::kDecoderG722:
48 case kDecoderG722_2ch: { 48 case NetEqDecoder::kDecoderG722_2ch: {
49 // Use timestamp scaling with factor 2 (two output samples per RTP 49 // Use timestamp scaling with factor 2 (two output samples per RTP
50 // timestamp). 50 // timestamp).
51 numerator_ = 2; 51 numerator_ = 2;
52 denominator_ = 1; 52 denominator_ = 1;
53 break; 53 break;
54 } 54 }
55 case kDecoderCNGswb48kHz: { 55 case NetEqDecoder::kDecoderCNGswb48kHz: {
56 // Use timestamp scaling with factor 2/3 (32 kHz sample rate, but RTP 56 // Use timestamp scaling with factor 2/3 (32 kHz sample rate, but RTP
57 // timestamps run on 48 kHz). 57 // timestamps run on 48 kHz).
58 // TODO(tlegrand): Remove scaling for kDecoderCNGswb48kHz once ACM has 58 // TODO(tlegrand): Remove scaling for kDecoderCNGswb48kHz once ACM has
59 // full 48 kHz support. 59 // full 48 kHz support.
60 numerator_ = 2; 60 numerator_ = 2;
61 denominator_ = 3; 61 denominator_ = 3;
62 break; 62 break;
63 } 63 }
64 case kDecoderAVT: 64 case NetEqDecoder::kDecoderAVT:
65 case kDecoderCNGnb: 65 case NetEqDecoder::kDecoderCNGnb:
66 case kDecoderCNGwb: 66 case NetEqDecoder::kDecoderCNGwb:
67 case kDecoderCNGswb32kHz: { 67 case NetEqDecoder::kDecoderCNGswb32kHz: {
68 // Do not change the timestamp scaling settings for DTMF or CNG. 68 // Do not change the timestamp scaling settings for DTMF or CNG.
69 break; 69 break;
70 } 70 }
71 default: { 71 default: {
72 // Do not use timestamp scaling for any other codec. 72 // Do not use timestamp scaling for any other codec.
73 numerator_ = 1; 73 numerator_ = 1;
74 denominator_ = 1; 74 denominator_ = 1;
75 break; 75 break;
76 } 76 }
77 } 77 }
(...skipping 26 matching lines...) Expand all
104 } else { 104 } else {
105 int32_t internal_diff = internal_timestamp - internal_ref_; 105 int32_t internal_diff = internal_timestamp - internal_ref_;
106 assert(numerator_ > 0); // Should not be possible. 106 assert(numerator_ > 0); // Should not be possible.
107 // Do not update references in this method. 107 // Do not update references in this method.
108 // Switch |denominator_| and |numerator_| to convert the other way. 108 // Switch |denominator_| and |numerator_| to convert the other way.
109 return external_ref_ + (internal_diff * denominator_) / numerator_; 109 return external_ref_ + (internal_diff * denominator_) / numerator_;
110 } 110 }
111 } 111 }
112 112
113 } // namespace webrtc 113 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698