diff --git a/modules/video_coding/h264_sps_pps_tracker.cc b/modules/video_coding/h264_sps_pps_tracker.cc index f98ec52a46..06244f5de9 100644 --- a/modules/video_coding/h264_sps_pps_tracker.cc +++ b/modules/video_coding/h264_sps_pps_tracker.cc @@ -140,8 +140,10 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream( nalu_ptr += segment_length; } } else { - if (video_header.is_first_packet_in_frame) + if (video_header.is_first_packet_in_frame || + h264_header.packetization_type == kH264SingleNalu) { required_size += sizeof(start_code_h264); + } required_size += data_size; } @@ -202,7 +204,8 @@ H264SpsPpsTracker::PacketAction H264SpsPpsTracker::CopyAndFixBitstream( nalu_ptr += segment_length; } } else { - if (video_header.is_first_packet_in_frame) { + if (video_header.is_first_packet_in_frame || + h264_header.packetization_type == kH264SingleNalu) { 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 7fe2cd121e..bb442eb6bc 100644 --- a/modules/video_coding/h264_sps_pps_tracker_unittest.cc +++ b/modules/video_coding/h264_sps_pps_tracker_unittest.cc @@ -149,10 +149,9 @@ TEST_F(TestH264SpsPpsTracker, StapAIncorrectSegmentLength) { EXPECT_EQ(H264SpsPpsTracker::kDrop, tracker_.CopyAndFixBitstream(&packet)); } -TEST_F(TestH264SpsPpsTracker, NoNalusFirstPacket) { +TEST_F(TestH264SpsPpsTracker, SingleNaluInsertStartCode) { uint8_t data[] = {1, 2, 3}; H264VcmPacket packet; - packet.video_header.is_first_packet_in_frame = true; packet.dataPtr = data; packet.sizeBytes = sizeof(data);