| OLD | NEW |
| 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/checks.h" | 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/trace_event.h" |
| 16 | 17 |
| 17 namespace webrtc { | 18 namespace webrtc { |
| 18 | 19 |
| 19 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len, | 20 int AudioDecoder::Decode(const uint8_t* encoded, size_t encoded_len, |
| 20 int sample_rate_hz, size_t max_decoded_bytes, | 21 int sample_rate_hz, size_t max_decoded_bytes, |
| 21 int16_t* decoded, SpeechType* speech_type) { | 22 int16_t* decoded, SpeechType* speech_type) { |
| 23 TRACE_EVENT0("webrtc", "AudioDecoder::Decode"); |
| 22 int duration = PacketDuration(encoded, encoded_len); | 24 int duration = PacketDuration(encoded, encoded_len); |
| 23 if (duration >= 0 && | 25 if (duration >= 0 && |
| 24 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { | 26 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { |
| 25 return -1; | 27 return -1; |
| 26 } | 28 } |
| 27 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, | 29 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, |
| 28 speech_type); | 30 speech_type); |
| 29 } | 31 } |
| 30 | 32 |
| 31 int AudioDecoder::DecodeRedundant(const uint8_t* encoded, size_t encoded_len, | 33 int AudioDecoder::DecodeRedundant(const uint8_t* encoded, size_t encoded_len, |
| 32 int sample_rate_hz, size_t max_decoded_bytes, | 34 int sample_rate_hz, size_t max_decoded_bytes, |
| 33 int16_t* decoded, SpeechType* speech_type) { | 35 int16_t* decoded, SpeechType* speech_type) { |
| 36 TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant"); |
| 34 int duration = PacketDurationRedundant(encoded, encoded_len); | 37 int duration = PacketDurationRedundant(encoded, encoded_len); |
| 35 if (duration >= 0 && | 38 if (duration >= 0 && |
| 36 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { | 39 duration * Channels() * sizeof(int16_t) > max_decoded_bytes) { |
| 37 return -1; | 40 return -1; |
| 38 } | 41 } |
| 39 return DecodeRedundantInternal(encoded, encoded_len, sample_rate_hz, decoded, | 42 return DecodeRedundantInternal(encoded, encoded_len, sample_rate_hz, decoded, |
| 40 speech_type); | 43 speech_type); |
| 41 } | 44 } |
| 42 | 45 |
| 43 int AudioDecoder::DecodeInternal(const uint8_t* encoded, size_t encoded_len, | |
| 44 int sample_rate_hz, int16_t* decoded, | |
| 45 SpeechType* speech_type) { | |
| 46 return kNotImplemented; | |
| 47 } | |
| 48 | |
| 49 int AudioDecoder::DecodeRedundantInternal(const uint8_t* encoded, | 46 int AudioDecoder::DecodeRedundantInternal(const uint8_t* encoded, |
| 50 size_t encoded_len, | 47 size_t encoded_len, |
| 51 int sample_rate_hz, int16_t* decoded, | 48 int sample_rate_hz, int16_t* decoded, |
| 52 SpeechType* speech_type) { | 49 SpeechType* speech_type) { |
| 53 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, | 50 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, |
| 54 speech_type); | 51 speech_type); |
| 55 } | 52 } |
| 56 | 53 |
| 57 bool AudioDecoder::HasDecodePlc() const { return false; } | 54 bool AudioDecoder::HasDecodePlc() const { return false; } |
| 58 | 55 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return kSpeech; | 94 return kSpeech; |
| 98 case 2: | 95 case 2: |
| 99 return kComfortNoise; | 96 return kComfortNoise; |
| 100 default: | 97 default: |
| 101 assert(false); | 98 assert(false); |
| 102 return kSpeech; | 99 return kSpeech; |
| 103 } | 100 } |
| 104 } | 101 } |
| 105 | 102 |
| 106 } // namespace webrtc | 103 } // namespace webrtc |
| OLD | NEW |