Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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/ilbc/audio_decoder_ilbc.h" | 11 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" | |
| 14 #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" | 15 #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" |
| 15 | 16 |
| 16 namespace webrtc { | 17 namespace webrtc { |
| 17 | 18 |
| 18 AudioDecoderIlbc::AudioDecoderIlbc() { | 19 AudioDecoderIlbc::AudioDecoderIlbc() { |
| 19 WebRtcIlbcfix_DecoderCreate(&dec_state_); | 20 WebRtcIlbcfix_DecoderCreate(&dec_state_); |
| 20 WebRtcIlbcfix_Decoderinit30Ms(dec_state_); | 21 WebRtcIlbcfix_Decoderinit30Ms(dec_state_); |
| 21 } | 22 } |
| 22 | 23 |
| 23 AudioDecoderIlbc::~AudioDecoderIlbc() { | 24 AudioDecoderIlbc::~AudioDecoderIlbc() { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 42 } | 43 } |
| 43 | 44 |
| 44 size_t AudioDecoderIlbc::DecodePlc(size_t num_frames, int16_t* decoded) { | 45 size_t AudioDecoderIlbc::DecodePlc(size_t num_frames, int16_t* decoded) { |
| 45 return WebRtcIlbcfix_NetEqPlc(dec_state_, decoded, num_frames); | 46 return WebRtcIlbcfix_NetEqPlc(dec_state_, decoded, num_frames); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void AudioDecoderIlbc::Reset() { | 49 void AudioDecoderIlbc::Reset() { |
| 49 WebRtcIlbcfix_Decoderinit30Ms(dec_state_); | 50 WebRtcIlbcfix_Decoderinit30Ms(dec_state_); |
| 50 } | 51 } |
| 51 | 52 |
| 53 AudioDecoder::PacketSplits AudioDecoderIlbc::SplitPacket( | |
| 54 const uint8_t* payload, | |
| 55 size_t payload_len) const { | |
| 56 PacketSplits splits; | |
| 57 size_t bytes_per_frame; | |
| 58 int timestamps_per_frame; | |
| 59 if (payload_len >= 950) { | |
|
kwiberg-webrtc
2016/08/26 12:39:25
It's probably best to name the constants:
const
| |
| 60 LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Payload too large"; | |
| 61 return splits; | |
| 62 } | |
| 63 if (payload_len % 38 == 0) { | |
| 64 // 20 ms frames. | |
| 65 bytes_per_frame = 38; | |
| 66 timestamps_per_frame = 160; | |
| 67 } else if (payload_len % 50 == 0) { | |
| 68 // 30 ms frames. | |
| 69 bytes_per_frame = 50; | |
| 70 timestamps_per_frame = 240; | |
| 71 } else { | |
| 72 LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Invalid payload"; | |
| 73 return splits; | |
| 74 } | |
| 75 | |
| 76 if (payload_len == bytes_per_frame) { | |
| 77 // Special case. Do not split the payload. | |
| 78 return {PacketSplit{0, payload_len, 0}}; | |
| 79 } | |
|
kwiberg-webrtc
2016/08/26 12:39:25
Is this special case really needed? It looks like
ossu
2016/08/26 13:05:30
You're right. This shouldn't be necessary. I'll re
| |
| 80 | |
| 81 PacketSplit split = {0, bytes_per_frame, 0}; | |
| 82 for (size_t len = payload_len; len > 0; len -= bytes_per_frame) { | |
| 83 RTC_DCHECK(len >= bytes_per_frame); | |
| 84 splits.push_back(split); | |
| 85 split.byte_offset += bytes_per_frame; | |
| 86 split.timestamp_offset += timestamps_per_frame; | |
| 87 } | |
| 88 | |
| 89 return splits; | |
| 90 } | |
| 91 | |
| 52 int AudioDecoderIlbc::SampleRateHz() const { | 92 int AudioDecoderIlbc::SampleRateHz() const { |
| 53 return 8000; | 93 return 8000; |
| 54 } | 94 } |
| 55 | 95 |
| 56 size_t AudioDecoderIlbc::Channels() const { | 96 size_t AudioDecoderIlbc::Channels() const { |
| 57 return 1; | 97 return 1; |
| 58 } | 98 } |
| 59 | 99 |
| 60 } // namespace webrtc | 100 } // namespace webrtc |
| OLD | NEW |