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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.cc

Issue 2535593002: RTC_[D]CHECK_op: Remove "u" suffix on integer constants (Closed)
Patch Set: 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 #include "webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h" 11 #include "webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h"
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/safe_conversions.h" 14 #include "webrtc/base/safe_conversions.h"
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 namespace test { 18 namespace test {
19 19
20 int FakeDecodeFromFile::DecodeInternal(const uint8_t* encoded, 20 int FakeDecodeFromFile::DecodeInternal(const uint8_t* encoded,
21 size_t encoded_len, 21 size_t encoded_len,
22 int sample_rate_hz, 22 int sample_rate_hz,
23 int16_t* decoded, 23 int16_t* decoded,
24 SpeechType* speech_type) { 24 SpeechType* speech_type) {
25 if (encoded_len == 0) { 25 if (encoded_len == 0) {
26 // Decoder is asked to produce codec-internal comfort noise. 26 // Decoder is asked to produce codec-internal comfort noise.
27 RTC_DCHECK(!encoded); // NetEq always sends nullptr in this case. 27 RTC_DCHECK(!encoded); // NetEq always sends nullptr in this case.
28 RTC_DCHECK(cng_mode_); 28 RTC_DCHECK(cng_mode_);
29 RTC_DCHECK_GT(last_decoded_length_, 0u); 29 RTC_DCHECK_GT(last_decoded_length_, 0);
30 std::fill_n(decoded, last_decoded_length_, 0); 30 std::fill_n(decoded, last_decoded_length_, 0);
31 *speech_type = kComfortNoise; 31 *speech_type = kComfortNoise;
32 return last_decoded_length_; 32 return last_decoded_length_;
33 } 33 }
34 34
35 RTC_CHECK_GE(encoded_len, 12u); 35 RTC_CHECK_GE(encoded_len, 12);
36 uint32_t timestamp_to_decode = 36 uint32_t timestamp_to_decode =
37 ByteReader<uint32_t>::ReadLittleEndian(encoded); 37 ByteReader<uint32_t>::ReadLittleEndian(encoded);
38 uint32_t samples_to_decode = 38 uint32_t samples_to_decode =
39 ByteReader<uint32_t>::ReadLittleEndian(&encoded[4]); 39 ByteReader<uint32_t>::ReadLittleEndian(&encoded[4]);
40 if (samples_to_decode == 0) { 40 if (samples_to_decode == 0) {
41 // Number of samples in packet is unknown. 41 // Number of samples in packet is unknown.
42 if (last_decoded_length_ > 0) { 42 if (last_decoded_length_ > 0) {
43 // Use length of last decoded packet, but since this is the total for all 43 // Use length of last decoded packet, but since this is the total for all
44 // channels, we have to divide by 2 in the stereo case. 44 // channels, we have to divide by 2 in the stereo case.
45 samples_to_decode = rtc::CheckedDivExact( 45 samples_to_decode = rtc::CheckedDivExact(
(...skipping 13 matching lines...) Expand all
59 RTC_CHECK(input_->Seek(jump)); 59 RTC_CHECK(input_->Seek(jump));
60 } 60 }
61 61
62 next_timestamp_from_input_ = 62 next_timestamp_from_input_ =
63 rtc::Optional<uint32_t>(timestamp_to_decode + samples_to_decode); 63 rtc::Optional<uint32_t>(timestamp_to_decode + samples_to_decode);
64 64
65 uint32_t original_payload_size_bytes = 65 uint32_t original_payload_size_bytes =
66 ByteReader<uint32_t>::ReadLittleEndian(&encoded[8]); 66 ByteReader<uint32_t>::ReadLittleEndian(&encoded[8]);
67 if (original_payload_size_bytes == 1) { 67 if (original_payload_size_bytes == 1) {
68 // This is a comfort noise payload. 68 // This is a comfort noise payload.
69 RTC_DCHECK_GT(last_decoded_length_, 0u); 69 RTC_DCHECK_GT(last_decoded_length_, 0);
70 std::fill_n(decoded, last_decoded_length_, 0); 70 std::fill_n(decoded, last_decoded_length_, 0);
71 *speech_type = kComfortNoise; 71 *speech_type = kComfortNoise;
72 cng_mode_ = true; 72 cng_mode_ = true;
73 return last_decoded_length_; 73 return last_decoded_length_;
74 } 74 }
75 75
76 cng_mode_ = false; 76 cng_mode_ = false;
77 RTC_CHECK(input_->Read(static_cast<size_t>(samples_to_decode), decoded)); 77 RTC_CHECK(input_->Read(static_cast<size_t>(samples_to_decode), decoded));
78 78
79 if (stereo_) { 79 if (stereo_) {
80 InputAudioFile::DuplicateInterleaved(decoded, samples_to_decode, 2, 80 InputAudioFile::DuplicateInterleaved(decoded, samples_to_decode, 2,
81 decoded); 81 decoded);
82 samples_to_decode *= 2; 82 samples_to_decode *= 2;
83 } 83 }
84 84
85 *speech_type = kSpeech; 85 *speech_type = kSpeech;
86 return last_decoded_length_ = samples_to_decode; 86 return last_decoded_length_ = samples_to_decode;
87 } 87 }
88 88
89 void FakeDecodeFromFile::PrepareEncoded(uint32_t timestamp, 89 void FakeDecodeFromFile::PrepareEncoded(uint32_t timestamp,
90 size_t samples, 90 size_t samples,
91 size_t original_payload_size_bytes, 91 size_t original_payload_size_bytes,
92 rtc::ArrayView<uint8_t> encoded) { 92 rtc::ArrayView<uint8_t> encoded) {
93 RTC_CHECK_GE(encoded.size(), 12u); 93 RTC_CHECK_GE(encoded.size(), 12);
94 ByteWriter<uint32_t>::WriteLittleEndian(&encoded[0], timestamp); 94 ByteWriter<uint32_t>::WriteLittleEndian(&encoded[0], timestamp);
95 ByteWriter<uint32_t>::WriteLittleEndian(&encoded[4], 95 ByteWriter<uint32_t>::WriteLittleEndian(&encoded[4],
96 rtc::checked_cast<uint32_t>(samples)); 96 rtc::checked_cast<uint32_t>(samples));
97 ByteWriter<uint32_t>::WriteLittleEndian( 97 ByteWriter<uint32_t>::WriteLittleEndian(
98 &encoded[8], rtc::checked_cast<uint32_t>(original_payload_size_bytes)); 98 &encoded[8], rtc::checked_cast<uint32_t>(original_payload_size_bytes));
99 } 99 }
100 100
101 } // namespace test 101 } // namespace test
102 } // namespace webrtc 102 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698