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

Unified Diff: webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc

Issue 2260803002: Generalize FEC header formatting. (pt. 4) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Lint fix. 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc
diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc b/webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc
index 790e705bc4aa4e9505496e84d8e9e7cf556fdead..faef7716fdca8892d302297a1dd12fe0c6fe7a33 100644
--- a/webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc
+++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.cc
@@ -15,6 +15,7 @@
#include <algorithm>
+#include "webrtc/base/checks.h"
#include "webrtc/modules/rtp_rtcp/source/fec_private_tables_bursty.h"
#include "webrtc/modules/rtp_rtcp/source/fec_private_tables_random.h"
@@ -202,11 +203,8 @@ void RemainingPacketProtection(int num_media_packets,
if (mode == kModeNoOverlap) {
// sub_mask21
- const int l_bit =
- (num_media_packets - num_fec_for_imp_packets) > 16 ? 1 : 0;
-
const int res_mask_bytes =
- (l_bit == 1) ? kMaskSizeLBitSet : kMaskSizeLBitClear;
+ PacketMaskSize(num_media_packets - num_fec_for_imp_packets);
const uint8_t* packet_mask_sub_21 =
mask_table.fec_packet_mask_table()[num_media_packets -
@@ -245,9 +243,7 @@ void ImportantPacketProtection(int num_fec_for_imp_packets,
int num_mask_bytes,
uint8_t* packet_mask,
const PacketMaskTable& mask_table) {
- const int l_bit = num_imp_packets > 16 ? 1 : 0;
- const int num_imp_mask_bytes =
- (l_bit == 1) ? kMaskSizeLBitSet : kMaskSizeLBitClear;
+ const int num_imp_mask_bytes = PacketMaskSize(num_imp_packets);
// Get sub_mask1 from table
const uint8_t* packet_mask_sub_1 =
@@ -375,9 +371,7 @@ void GeneratePacketMasks(int num_media_packets,
assert(num_fec_packets <= num_media_packets && num_fec_packets > 0);
assert(num_imp_packets <= num_media_packets && num_imp_packets >= 0);
- int l_bit = num_media_packets > 16 ? 1 : 0;
- const int num_mask_bytes =
- (l_bit == 1) ? kMaskSizeLBitSet : kMaskSizeLBitClear;
+ const int num_mask_bytes = PacketMaskSize(num_media_packets);
// Equal-protection for these cases.
if (!use_unequal_protection || num_imp_packets == 0) {
@@ -394,6 +388,14 @@ void GeneratePacketMasks(int num_media_packets,
} // End of UEP modification
} // End of GetPacketMasks
+size_t PacketMaskSize(size_t num_sequence_numbers) {
+ RTC_DCHECK_LE(num_sequence_numbers, 8 * kUlpfecPacketMaskSizeLBitSet);
+ if (num_sequence_numbers > 8 * kUlpfecPacketMaskSizeLBitClear) {
+ return kUlpfecPacketMaskSizeLBitSet;
+ }
+ return kUlpfecPacketMaskSizeLBitClear;
+}
+
void InsertZeroColumns(int num_zeros,
uint8_t* new_mask,
int new_mask_bytes,
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h ('k') | webrtc/modules/rtp_rtcp/source/producer_fec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698