diff --git a/modules/video_coding/h264_sps_pps_tracker.cc b/modules/video_coding/h264_sps_pps_tracker.cc index 06244f5de9..9c0e52178e 100644 --- a/modules/video_coding/h264_sps_pps_tracker.cc +++ b/modules/video_coding/h264_sps_pps_tracker.cc @@ -140,8 +140,7 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream( nalu_ptr += segment_length; } } else { - if (video_header.is_first_packet_in_frame || - h264_header.packetization_type == kH264SingleNalu) { + if (h264_header.nalus_length > 0) { required_size += sizeof(start_code_h264); } required_size += data_size; @@ -204,8 +203,7 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream( nalu_ptr += segment_length; } } else { - if (video_header.is_first_packet_in_frame || - h264_header.packetization_type == kH264SingleNalu) { + if (h264_header.nalus_length > 0) { memcpy(insert_at, start_code_h264, sizeof(start_code_h264)); insert_at += sizeof(start_code_h264); } diff --git a/modules/video_coding/h264_sps_pps_tracker_unittest.cc b/modules/video_coding/h264_sps_pps_tracker_unittest.cc index 86c9c2d28d..7857aa7efc 100644 --- a/modules/video_coding/h264_sps_pps_tracker_unittest.cc +++ b/modules/video_coding/h264_sps_pps_tracker_unittest.cc @@ -127,6 +127,7 @@ TEST_F(TestH264SpsPpsTracker, FuAFirstPacket) { uint8_t data[] = {1, 2, 3}; H264VcmPacket packet; packet.h264().packetization_type = kH264FuA; + packet.h264().nalus_length = 1; packet.video_header.is_first_packet_in_frame = true; packet.dataPtr = data; packet.sizeBytes = sizeof(data); @@ -153,6 +154,7 @@ TEST_F(TestH264SpsPpsTracker, StapAIncorrectSegmentLength) { TEST_F(TestH264SpsPpsTracker, SingleNaluInsertStartCode) { uint8_t data[] = {1, 2, 3}; H264VcmPacket packet; + packet.h264().nalus_length = 1; packet.dataPtr = data; packet.sizeBytes = sizeof(data); @@ -164,12 +166,14 @@ TEST_F(TestH264SpsPpsTracker, SingleNaluInsertStartCode) { delete[] packet.dataPtr; } -TEST_F(TestH264SpsPpsTracker, IdrNoSpsPpsInserted) { +TEST_F(TestH264SpsPpsTracker, NoStartCodeInsertedForSubsequentFuAPacket) { std::vector data = {1, 2, 3}; H264VcmPacket packet; packet.h264().packetization_type = kH264FuA; - AddIdr(&packet, 0); + // Since no NALU begin in this packet the nalus_length is zero. + packet.h264().nalus_length = 0; + packet.dataPtr = data.data(); packet.sizeBytes = data.size();