Chromium Code Reviews| Index: webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| index dab5805f98afcc41eaa714d49e4cd8baec5ebe59..968f91abf0f0d6000d0fc16fad4370d1fe93ead8 100644 |
| --- a/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| +++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| @@ -11,6 +11,7 @@ |
| #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" |
| #include "webrtc/base/checks.h" |
| +#include "webrtc/base/logging.h" |
| #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" |
| namespace webrtc { |
| @@ -49,6 +50,44 @@ void AudioDecoderIlbc::Reset() { |
| WebRtcIlbcfix_Decoderinit30Ms(dec_state_); |
| } |
| +std::vector<AudioDecoder::PacketSplit> AudioDecoderIlbc::SplitPacket( |
| + rtc::ArrayView<const uint8_t> payload) const { |
| + 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
|
| + size_t bytes_per_frame; |
| + int timestamps_per_frame; |
| + 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.
|
| + LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Payload too large"; |
| + return splits; |
| + } |
| + if (payload.size() % 38 == 0) { |
| + // 20 ms frames. |
| + bytes_per_frame = 38; |
| + timestamps_per_frame = 160; |
| + } else if (payload.size() % 50 == 0) { |
| + // 30 ms frames. |
| + bytes_per_frame = 50; |
| + timestamps_per_frame = 240; |
| + } else { |
| + LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Invalid payload"; |
| + return splits; |
| + } |
| + |
| + if (payload.size() == bytes_per_frame) { |
| + // Special case. Do not split the payload. |
| + return {PacketSplit{0, payload.size(), 0}}; |
| + } |
|
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
|
| + |
| + PacketSplit split = {0, bytes_per_frame, 0}; |
| + 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.
|
| + RTC_DCHECK(len >= bytes_per_frame); |
| + splits.push_back(split); |
| + split.byte_offset += bytes_per_frame; |
| + split.timestamp_offset += timestamps_per_frame; |
| + } |
| + |
| + return splits; |
| +} |
| + |
| int AudioDecoderIlbc::SampleRateHz() const { |
| return 8000; |
| } |