Use nalus_length instead of is_first_packet_in_frame to insert startcodes in the H264SpsPpsTracker.

Bug: none
Change-Id: I752b1696a6545356fc9ada9d70c63b2ab9bae9e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145334
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Mirta Dvornicic <mirtad@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28559}
This commit is contained in:
philipel
2019-07-12 15:32:17 +02:00
committed by Commit Bot
parent 6564366f75
commit 2c850afe8d
2 changed files with 8 additions and 6 deletions

View File

@ -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);
}

View File

@ -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<uint8_t> 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();