Write the original H.264 SPS if it required no fixups

This commit is contained in:
Cameron Gutman
2026-07-26 18:33:28 -05:00
parent 490229be3f
commit 2fc0d84aa0
+9
View File
@@ -1781,6 +1781,7 @@ void FFmpegVideoDecoder::writeBuffer(PLENTRY entry, int& offset)
// Fixup the SPS to what OS X needs to use hardware acceleration
// This is also critical for decoding latency on the Pi 2.
if (stream->sps->num_ref_frames != 1 || stream->sps->vui.max_dec_frame_buffering != 1) {
stream->sps->num_ref_frames = 1;
stream->sps->vui.max_dec_frame_buffering = 1;
@@ -1808,6 +1809,14 @@ void FFmpegVideoDecoder::writeBuffer(PLENTRY entry, int& offset)
// Copy the NALU prefix over from the original SPS
memcpy(&m_DecodeBuffer.data()[initialOffset], entry->data, nalStart);
offset += nalStart;
}
else {
// Write the SPS as-is if it required no modification
memcpy(&m_DecodeBuffer.data()[offset],
entry->data,
entry->length);
offset += entry->length;
}
h264_free(stream);
}