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

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_decoder.cc

Issue 2293893002: Add functions to interact with ASan and MSan, and some sample uses (Closed)
Patch Set: Created 4 years, 3 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
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
11 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 11 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/base/array_view.h"
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/sanitizer.h"
16 #include "webrtc/base/trace_event.h" 18 #include "webrtc/base/trace_event.h"
17 19
18 namespace webrtc { 20 namespace webrtc {
19 21
20 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len, 22 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len,
21 int sample_rate_hz, size_t max_decoded_bytes, 23 int sample_rate_hz, size_t max_decoded_bytes,
22 int16_t* decoded, SpeechType* speech_type) { 24 int16_t* decoded, SpeechType* speech_type) {
23 TRACE_EVENT0("webrtc", "AudioDecoder::Decode"); 25 TRACE_EVENT0("webrtc", "AudioDecoder::Decode");
26 rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
24 int duration = PacketDuration(encoded, encoded_len); 27 int duration = PacketDuration(encoded, encoded_len);
25 if (duration >= 0 && 28 if (duration >= 0 &&
26 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { 29 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
27 return -1; 30 return -1;
28 } 31 }
29 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, 32 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded,
30 speech_type); 33 speech_type);
31 } 34 }
32 35
33 int AudioDecoder::DecodeRedundant(const uint8_t* encoded, size_t encoded_len, 36 int AudioDecoder::DecodeRedundant(const uint8_t* encoded, size_t encoded_len,
34 int sample_rate_hz, size_t max_decoded_bytes, 37 int sample_rate_hz, size_t max_decoded_bytes,
35 int16_t* decoded, SpeechType* speech_type) { 38 int16_t* decoded, SpeechType* speech_type) {
36 TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant"); 39 TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant");
40 rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
37 int duration = PacketDurationRedundant(encoded, encoded_len); 41 int duration = PacketDurationRedundant(encoded, encoded_len);
38 if (duration >= 0 && 42 if (duration >= 0 &&
39 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { 43 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
40 return -1; 44 return -1;
41 } 45 }
42 return DecodeRedundantInternal(encoded, encoded_len, sample_rate_hz, decoded, 46 return DecodeRedundantInternal(encoded, encoded_len, sample_rate_hz, decoded,
43 speech_type); 47 speech_type);
44 } 48 }
45 49
46 int AudioDecoder::DecodeRedundantInternal(const uint8_t* encoded, 50 int AudioDecoder::DecodeRedundantInternal(const uint8_t* encoded,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return kSpeech; 93 return kSpeech;
90 case 2: 94 case 2:
91 return kComfortNoise; 95 return kComfortNoise;
92 default: 96 default:
93 assert(false); 97 assert(false);
94 return kSpeech; 98 return kSpeech;
95 } 99 }
96 } 100 }
97 101
98 } // namespace webrtc 102 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698