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 std::vector<AudioDecoder::PacketSplit> AudioDecoderIlbc::SplitPacket( | |
| 54 rtc::ArrayView<const uint8_t> payload) const { | |
| 55 std::vector<PacketSplit> splits; | |
|
kwiberg-webrtc
2016/09/12 02:11:01
Allocate this one much closer to first point of us
ossu
2016/09/12 11:26:37
Acknowledged.
ossu
2016/09/13 14:25:55
I looked at it again and it's used five lines down
| |
| 56 size_t bytes_per_frame; | |
| 57 int timestamps_per_frame; | |
| 58 if (payload.size() >= 950) { | |
|
kwiberg-webrtc
2016/09/12 02:11:01
As I think I've noted before, the only sizes that
ossu
2016/09/12 11:26:37
Yes, that is the case. If acceptable, I'd like to
kwiberg-webrtc
2016/09/13 12:23:37
Acknowledged.
| |
| 59 LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Payload too large"; | |
| 60 return splits; | |
| 61 } | |
| 62 if (payload.size() % 38 == 0) { | |
| 63 // 20 ms frames. | |
| 64 bytes_per_frame = 38; | |
| 65 timestamps_per_frame = 160; | |
| 66 } else if (payload.size() % 50 == 0) { | |
| 67 // 30 ms frames. | |
| 68 bytes_per_frame = 50; | |
| 69 timestamps_per_frame = 240; | |
| 70 } else { | |
| 71 LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Invalid payload"; | |
| 72 return splits; | |
| 73 } | |
| 74 | |
| 75 if (payload.size() == bytes_per_frame) { | |
| 76 // Special case. Do not split the payload. | |
| 77 return {PacketSplit{0, payload.size(), 0}}; | |
| 78 } | |
|
kwiberg-webrtc
2016/09/12 02:11:01
Why is this special case needed? Doesn't the loop
ossu
2016/09/12 11:26:37
It does. You mentioned that on the previous CL and
kwiberg-webrtc
2016/09/13 12:23:37
Nice to know that even if my memory isn't what it
hlundin-webrtc
2016/09/15 08:49:14
If you recall correctly, your memory is not what i
| |
| 79 | |
| 80 PacketSplit split = {0, bytes_per_frame, 0}; | |
| 81 for (size_t len = payload.size(); len > 0; len -= bytes_per_frame) { | |
|
kwiberg-webrtc
2016/09/12 02:11:01
Better DCHECK that payload.size() % bytes_per_fram
ossu
2016/09/12 11:26:37
Hmm. I see the problem but I'm not sure that's how
kwiberg-webrtc
2016/09/13 12:23:37
I don't think you need to do that. Just a DCHECK i
ossu
2016/09/13 14:25:55
Acknowledged.
| |
| 82 RTC_DCHECK(len >= bytes_per_frame); | |
| 83 splits.push_back(split); | |
| 84 split.byte_offset += bytes_per_frame; | |
| 85 split.timestamp_offset += timestamps_per_frame; | |
| 86 } | |
| 87 | |
| 88 return splits; | |
| 89 } | |
| 90 | |
| 52 int AudioDecoderIlbc::SampleRateHz() const { | 91 int AudioDecoderIlbc::SampleRateHz() const { |
| 53 return 8000; | 92 return 8000; |
| 54 } | 93 } |
| 55 | 94 |
| 56 size_t AudioDecoderIlbc::Channels() const { | 95 size_t AudioDecoderIlbc::Channels() const { |
| 57 return 1; | 96 return 1; |
| 58 } | 97 } |
| 59 | 98 |
| 60 } // namespace webrtc | 99 } // namespace webrtc |
| OLD | NEW |