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

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

Issue 2385143002: Revert "Revert of Use sps and pps to determine decodability of H.264 frames. (patchset #4 id:60001 … (Closed)
Patch Set: Add unittest. Created 4 years, 2 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/rtp_format_h264.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
index 19467ca6513421cbb628fe0f7f35bb9fe77190c8..81dcb8b9e242b15bef9d7608f2d6b5a5971e3199 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
@@ -484,6 +484,8 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
parsed_payload->type.Video.width = sps->width;
parsed_payload->type.Video.height = sps->height;
nalu.sps_id = sps->id;
+ } else {
+ LOG(LS_WARNING) << "Failed to parse SPS id from SPS slice.";
}
parsed_payload->frame_type = kVideoFrameKey;
break;
@@ -502,18 +504,32 @@ bool RtpDepacketizerH264::ProcessStapAOrSingleNalu(
}
break;
}
- case H264::NaluType::kSei:
- FALLTHROUGH();
case H264::NaluType::kIdr:
parsed_payload->frame_type = kVideoFrameKey;
FALLTHROUGH();
- default: {
+ case H264::NaluType::kSlice: {
rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
&payload_data[start_offset], end_offset - start_offset);
- if (pps_id)
+ if (pps_id) {
nalu.pps_id = *pps_id;
+ } else {
+ LOG(LS_WARNING) << "Failed to parse PPS id from slice of type: "
+ << static_cast<int>(nalu.type);
+ }
break;
}
+ // Slices below don't contain SPS or PPS ids.
+ case H264::NaluType::kAud:
+ case H264::NaluType::kEndOfSequence:
+ case H264::NaluType::kEndOfStream:
+ case H264::NaluType::kFiller:
+ break;
+ case H264::NaluType::kSei:
+ parsed_payload->frame_type = kVideoFrameKey;
+ break;
+ case H264::NaluType::kStapA:
+ case H264::NaluType::kFuA:
+ RTC_NOTREACHED();
}
RTPVideoHeaderH264* h264 = &parsed_payload->type.Video.codecHeader.H264;
if (h264->nalus_length == kMaxNalusPerPacket) {
@@ -547,8 +563,13 @@ bool RtpDepacketizerH264::ParseFuaNalu(
length_ -= kNalHeaderSize;
rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
payload_data + 2 * kNalHeaderSize, length_ - kNalHeaderSize);
- if (pps_id)
+ if (pps_id) {
nalu.pps_id = *pps_id;
+ } else {
+ LOG(LS_WARNING) << "Failed to parse PPS from first fragment of FU-A NAL "
+ "unit with original type: "
+ << static_cast<int>(nalu.type);
+ }
uint8_t original_nal_header = fnri | original_nal_type;
modified_buffer_.reset(new rtc::Buffer());
modified_buffer_->AppendData(payload_data + kNalHeaderSize, length_);
@@ -570,8 +591,10 @@ bool RtpDepacketizerH264::ParseFuaNalu(
RTPVideoHeaderH264* h264 = &parsed_payload->type.Video.codecHeader.H264;
h264->packetization_type = kH264FuA;
h264->nalu_type = original_nal_type;
- h264->nalus[h264->nalus_length] = nalu;
- h264->nalus_length = 1;
+ if (first_fragment) {
+ h264->nalus[h264->nalus_length] = nalu;
+ h264->nalus_length = 1;
+ }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698