OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/audio_coding/codecs/split_by_samples.h" | |
12 | |
13 namespace webrtc { | |
14 | |
15 namespace internal { | |
16 | |
17 std::vector<AudioDecoder::PacketSplit> SplitBySamples( | |
18 rtc::ArrayView<const uint8_t> payload, | |
19 size_t bytes_per_ms, | |
20 uint32_t timestamps_per_ms) { | |
21 RTC_DCHECK(payload.data()); | |
22 std::vector<AudioDecoder::PacketSplit> splits; | |
23 size_t split_size_bytes = payload.size(); | |
24 | |
25 // Find a "chunk size" >= 20 ms and < 40 ms. | |
26 size_t min_chunk_size = bytes_per_ms * 20; | |
kwiberg-webrtc
2016/09/12 02:11:01
const
ossu
2016/09/12 11:26:37
Acknowledged.
| |
27 // Reduce the split size by half as long as |split_size_bytes| is at least | |
28 // twice the minimum chunk size (so that the resulting size is at least as | |
29 // large as the minimum chunk size). | |
30 while (split_size_bytes >= 2 * min_chunk_size) { | |
31 split_size_bytes >>= 1; | |
32 } | |
33 uint32_t timestamps_per_chunk = static_cast<uint32_t>( | |
kwiberg-webrtc
2016/09/12 02:11:01
const
ossu
2016/09/12 11:26:37
Acknowledged.
| |
34 split_size_bytes * timestamps_per_ms / bytes_per_ms); | |
35 AudioDecoder::PacketSplit split = {0, split_size_bytes, 0}; | |
36 size_t len = payload.size(); | |
37 for (len = payload.size(); | |
kwiberg-webrtc
2016/09/12 02:11:01
You initialize twice.
ossu
2016/09/12 11:26:37
Would you look at that!
| |
38 len >= (2 * split_size_bytes); | |
39 len -= split_size_bytes) { | |
40 splits.push_back(split); | |
41 split.byte_offset += split_size_bytes; | |
42 split.timestamp_offset += timestamps_per_chunk; | |
43 } | |
44 | |
45 if (len > 0) { | |
46 split.num_bytes = len; | |
47 splits.push_back(split); | |
48 } | |
49 | |
50 return splits; | |
51 } | |
52 | |
53 } // namespace internal | |
54 | |
55 } // namespace webrtc | |
OLD | NEW |