Fix math involving enums in C++20

(-Wdeprecated-anon-enum-enum-conversion)
- Replace enum with constexpr if necessary.
- Merge multiple definitions for H.264 NalDefs and FuDefs and apply
  constexpr.

Bug: chromium:1284275
Change-Id: I4a4d95ed6aba258e7c19c3ae6251c8b78caf84ec
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276561
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Daniel.L (Byoungchan) Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/main@{#38215}
This commit is contained in:
Byoungchan Lee
2022-09-27 14:37:26 +09:00
committed by WebRTC LUCI CQ
parent 806261ae8e
commit 6c2ac2ea6b
8 changed files with 55 additions and 57 deletions

View File

@ -37,12 +37,6 @@ static const size_t kNalHeaderSize = 1;
static const size_t kFuAHeaderSize = 2;
static const size_t kLengthFieldSize = 2;
// Bit masks for FU (A and B) indicators.
enum NalDefs : uint8_t { kFBit = 0x80, kNriMask = 0x60, kTypeMask = 0x1F };
// Bit masks for FU (A and B) headers.
enum FuDefs : uint8_t { kSBit = 0x80, kEBit = 0x40, kRBit = 0x20 };
} // namespace
RtpPacketizerH264::RtpPacketizerH264(rtc::ArrayView<const uint8_t> payload,
@ -267,7 +261,8 @@ void RtpPacketizerH264::NextAggregatePacket(RtpPacketToSend* rtp_packet) {
PacketUnit* packet = &packets_.front();
RTC_CHECK(packet->first_fragment);
// STAP-A NALU header.
buffer[0] = (packet->header & (kFBit | kNriMask)) | H264::NaluType::kStapA;
buffer[0] =
(packet->header & (kH264FBit | kH264NriMask)) | H264::NaluType::kStapA;
size_t index = kNalHeaderSize;
bool is_last_fragment = packet->last_fragment;
while (packet->aggregated) {
@ -296,13 +291,13 @@ void RtpPacketizerH264::NextFragmentPacket(RtpPacketToSend* rtp_packet) {
// We do not send original NALU header, so it will be replaced by the
// FU indicator header of the first packet.
uint8_t fu_indicator =
(packet->header & (kFBit | kNriMask)) | H264::NaluType::kFuA;
(packet->header & (kH264FBit | kH264NriMask)) | H264::NaluType::kFuA;
uint8_t fu_header = 0;
// S | E | R | 5 bit type.
fu_header |= (packet->first_fragment ? kSBit : 0);
fu_header |= (packet->last_fragment ? kEBit : 0);
uint8_t type = packet->header & kTypeMask;
fu_header |= (packet->first_fragment ? kH264SBit : 0);
fu_header |= (packet->last_fragment ? kH264EBit : 0);
uint8_t type = packet->header & kH264TypeMask;
fu_header |= type;
rtc::ArrayView<const uint8_t> fragment = packet->source_fragment;
uint8_t* buffer =