Reland of Save width/height of SPS nalus and restore them on the first packet of an IDR. (patchset #1 id:1 of https://codereview.webrtc.org/2754543005/ )
Reason for revert:
fix
Original issue's description:
> Revert of Save width/height of SPS nalus and restore them on the first packet of an IDR. (patchset #6 id:100001 of https://codereview.webrtc.org/2750633003/ )
>
> Reason for revert:
> Breaks build bots.
>
> Original issue's description:
> > Save width/height of SPS nalus and restore them on the first packet of an IDR.
> >
> > It appears that for some H264 streams that the width/height is not set for
> > the first packet of the IDR but in the packet containing the SPS/PPS.
> >
> > BUG=chromium:698088, webrtc:7139
> >
> > Review-Url: https://codereview.webrtc.org/2750633003
> > Cr-Commit-Position: refs/heads/master@{#17239}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/620d75f5befe1387bc457bc3ec5ad0158c4e6697
>
> TBR=stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=chromium:698088, webrtc:7139
>
> Review-Url: https://codereview.webrtc.org/2754543005
> Cr-Commit-Position: refs/heads/master@{#17250}
> Committed: https://chromium.googlesource.com/external/webrtc/+/be35a008ef39bc52a1ac30e763057d0ab5df824a
TBR=stefan@webrtc.org
BUG=chromium:698088, webrtc:7139
Review-Url: https://codereview.webrtc.org/2751843003
Cr-Commit-Position: refs/heads/master@{#17289}
diff --git a/webrtc/modules/video_coding/h264_sps_pps_tracker.cc b/webrtc/modules/video_coding/h264_sps_pps_tracker.cc
index 5dfdb49..ad836b6 100644
--- a/webrtc/modules/video_coding/h264_sps_pps_tracker.cc
+++ b/webrtc/modules/video_coding/h264_sps_pps_tracker.cc
@@ -45,6 +45,7 @@
bool insert_packet = codec_header.nalus_length == 0 ? true : false;
int pps_id = -1;
+ int sps_id = -1;
size_t required_size = 0;
for (size_t i = 0; i < codec_header.nalus_length; ++i) {
const NaluInfo& nalu = codec_header.nalus[i];
@@ -55,6 +56,8 @@
sps_data_[nalu.sps_id].data.reset(new uint8_t[nalu.size]);
memcpy(sps_data_[nalu.sps_id].data.get(), data + nalu.offset,
nalu.size);
+ sps_data_[nalu.sps_id].width = packet->width;
+ sps_data_[nalu.sps_id].height = packet->height;
break;
}
case H264::NaluType::kPps: {
@@ -83,7 +86,8 @@
return kRequestKeyframe;
}
- auto sps = sps_data_.find(pps->second.sps_id);
+ sps_id = pps->second.sps_id;
+ auto sps = sps_data_.find(sps_id);
if (sps == sps_data_.end()) {
LOG(LS_WARNING) << "No SPS with id << "
<< pps_data_[nalu.pps_id].sps_id << " received";
@@ -177,6 +181,11 @@
memcpy(insert_at, data, data_size);
}
+ if (sps_id != -1) {
+ packet->width = sps_data_[sps_id].width;
+ packet->height = sps_data_[sps_id].height;
+ }
+
packet->dataPtr = buffer;
packet->sizeBytes = required_size;
return kInsert;
@@ -222,6 +231,8 @@
SpsInfo sps_info;
sps_info.size = sps.size();
+ sps_info.width = parsed_sps->width;
+ sps_info.height = parsed_sps->height;
uint8_t* sps_data = new uint8_t[sps_info.size];
memcpy(sps_data, sps.data(), sps_info.size);
sps_info.data.reset(sps_data);