Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc

Issue 2269893002: Move InsertZeroColumns and CopyColumn to ::internal. (pt. 1) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Review response. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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/rtp_rtcp/source/forward_error_correction_internal.h" 11 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <string.h> 14 #include <string.h>
15 15
16 #include <algorithm>
17
16 #include "webrtc/modules/rtp_rtcp/source/fec_private_tables_bursty.h" 18 #include "webrtc/modules/rtp_rtcp/source/fec_private_tables_bursty.h"
17 #include "webrtc/modules/rtp_rtcp/source/fec_private_tables_random.h" 19 #include "webrtc/modules/rtp_rtcp/source/fec_private_tables_random.h"
18 20
19 namespace { 21 namespace {
20 using webrtc::fec_private_tables::kPacketMaskBurstyTbl; 22 using webrtc::fec_private_tables::kPacketMaskBurstyTbl;
21 using webrtc::fec_private_tables::kPacketMaskRandomTbl; 23 using webrtc::fec_private_tables::kPacketMaskRandomTbl;
22 24
23 // Allow for different modes of protection for packets in UEP case. 25 // Allow for different modes of protection for packets in UEP case.
24 enum ProtectionMode { 26 enum ProtectionMode {
25 kModeNoOverlap, 27 kModeNoOverlap,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 memcpy(packet_mask, 387 memcpy(packet_mask,
386 mask_table.fec_packet_mask_table()[num_media_packets - 388 mask_table.fec_packet_mask_table()[num_media_packets -
387 1][num_fec_packets - 1], 389 1][num_fec_packets - 1],
388 num_fec_packets * num_mask_bytes); 390 num_fec_packets * num_mask_bytes);
389 } else { // UEP case 391 } else { // UEP case
390 UnequalProtectionMask(num_media_packets, num_fec_packets, num_imp_packets, 392 UnequalProtectionMask(num_media_packets, num_fec_packets, num_imp_packets,
391 num_mask_bytes, packet_mask, mask_table); 393 num_mask_bytes, packet_mask, mask_table);
392 } // End of UEP modification 394 } // End of UEP modification
393 } // End of GetPacketMasks 395 } // End of GetPacketMasks
394 396
397 void InsertZeroColumns(int num_zeros,
398 uint8_t* new_mask,
399 int new_mask_bytes,
400 int num_fec_packets,
401 int new_bit_index) {
402 for (uint16_t row = 0; row < num_fec_packets; ++row) {
403 const int new_byte_index = row * new_mask_bytes + new_bit_index / 8;
404 const int max_shifts = (7 - (new_bit_index % 8));
405 new_mask[new_byte_index] <<= std::min(num_zeros, max_shifts);
406 }
407 }
408
409 void CopyColumn(uint8_t* new_mask,
410 int new_mask_bytes,
411 uint8_t* old_mask,
412 int old_mask_bytes,
413 int num_fec_packets,
414 int new_bit_index,
415 int old_bit_index) {
416 // Copy column from the old mask to the beginning of the new mask and shift it
417 // out from the old mask.
418 for (uint16_t row = 0; row < num_fec_packets; ++row) {
419 int new_byte_index = row * new_mask_bytes + new_bit_index / 8;
420 int old_byte_index = row * old_mask_bytes + old_bit_index / 8;
421 new_mask[new_byte_index] |= ((old_mask[old_byte_index] & 0x80) >> 7);
422 if (new_bit_index % 8 != 7) {
423 new_mask[new_byte_index] <<= 1;
424 }
425 old_mask[old_byte_index] <<= 1;
426 }
427 }
428
395 } // namespace internal 429 } // namespace internal
396 } // namespace webrtc 430 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698