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 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 std::vector<TransportFeedback::StatusSymbol>* vec) const override { | 134 std::vector<TransportFeedback::StatusSymbol>* vec) const override { |
135 vec->insert(vec->end(), &symbols_[0], &symbols_[kCapacity]); | 135 vec->insert(vec->end(), &symbols_[0], &symbols_[kCapacity]); |
136 } | 136 } |
137 | 137 |
138 void WriteTo(uint8_t* buffer) const override { | 138 void WriteTo(uint8_t* buffer) const override { |
139 constexpr int kSymbolsInFirstByte = 6; | 139 constexpr int kSymbolsInFirstByte = 6; |
140 constexpr int kSymbolsInSecondByte = 8; | 140 constexpr int kSymbolsInSecondByte = 8; |
141 buffer[0] = 0x80u; | 141 buffer[0] = 0x80u; |
142 for (int i = 0; i < kSymbolsInFirstByte; ++i) { | 142 for (int i = 0; i < kSymbolsInFirstByte; ++i) { |
143 uint8_t encoded_symbol = EncodeSymbol(symbols_[i]); | 143 uint8_t encoded_symbol = EncodeSymbol(symbols_[i]); |
144 RTC_DCHECK_LE(encoded_symbol, 1u); | 144 RTC_DCHECK_LE(encoded_symbol, 1); |
145 buffer[0] |= encoded_symbol << (kSymbolsInFirstByte - (i + 1)); | 145 buffer[0] |= encoded_symbol << (kSymbolsInFirstByte - (i + 1)); |
146 } | 146 } |
147 buffer[1] = 0x00u; | 147 buffer[1] = 0x00u; |
148 for (int i = 0; i < kSymbolsInSecondByte; ++i) { | 148 for (int i = 0; i < kSymbolsInSecondByte; ++i) { |
149 uint8_t encoded_symbol = EncodeSymbol(symbols_[i + kSymbolsInFirstByte]); | 149 uint8_t encoded_symbol = EncodeSymbol(symbols_[i + kSymbolsInFirstByte]); |
150 RTC_DCHECK_LE(encoded_symbol, 1u); | 150 RTC_DCHECK_LE(encoded_symbol, 1); |
151 buffer[1] |= encoded_symbol << (kSymbolsInSecondByte - (i + 1)); | 151 buffer[1] |= encoded_symbol << (kSymbolsInSecondByte - (i + 1)); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 static OneBitVectorChunk* ParseFrom(const uint8_t* data) { | 155 static OneBitVectorChunk* ParseFrom(const uint8_t* data) { |
156 OneBitVectorChunk* chunk = new OneBitVectorChunk(); | 156 OneBitVectorChunk* chunk = new OneBitVectorChunk(); |
157 | 157 |
158 size_t index = 0; | 158 size_t index = 0; |
159 for (int i = 5; i >= 0; --i) // Last 5 bits from first byte. | 159 for (int i = 5; i >= 0; --i) // Last 5 bits from first byte. |
160 chunk->symbols_[index++] = DecodeSymbol((data[0] >> i) & 0x01); | 160 chunk->symbols_[index++] = DecodeSymbol((data[0] >> i) & 0x01); |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 "RLE block of size " << rle_chunk->NumSymbols() | 762 "RLE block of size " << rle_chunk->NumSymbols() |
763 << " but only " << max_size << " left to read."; | 763 << " but only " << max_size << " left to read."; |
764 delete rle_chunk; | 764 delete rle_chunk; |
765 return nullptr; | 765 return nullptr; |
766 } | 766 } |
767 return rle_chunk; | 767 return rle_chunk; |
768 } | 768 } |
769 | 769 |
770 } // namespace rtcp | 770 } // namespace rtcp |
771 } // namespace webrtc | 771 } // namespace webrtc |
OLD | NEW |