summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2021-04-20 19:11:12 +0100
committerTim-Philipp Müller <tim@centricular.com>2021-08-24 23:42:27 +0100
commit42a7edd40fa606eeb82a213168fff2d6d151a78c (patch)
tree8fc8f7558d9366b5a1bb3d2af75c86396dd3b9e1 /ext
parentfe4ec03a4b44c97befdafebd20e00c62b6698a26 (diff)
downloadgstreamer-plugins-bad-42a7edd40fa606eeb82a213168fff2d6d151a78c.tar.gz
openh264enc: fix broken sps/pps header generation
This was putting a truncated SPS into the initial header instead of the PPS because it was always reading from the beginning of the bitstream buffer (pBsBuf) and not from the offset where the current NAL is at in the bitstream buffer (psBsBuf + nal_offset). This was broken in commit 17113695. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1576 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2178>
Diffstat (limited to 'ext')
-rw-r--r--ext/openh264/gstopenh264enc.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/openh264/gstopenh264enc.cpp b/ext/openh264/gstopenh264enc.cpp
index b8b80c491..103794197 100644
--- a/ext/openh264/gstopenh264enc.cpp
+++ b/ext/openh264/gstopenh264enc.cpp
@@ -1042,8 +1042,13 @@ gst_openh264enc_handle_frame (GstVideoEncoder * encoder,
if (j > 0)
nal_offset = nal_offset + frame_info.sLayerInfo[i].pNalLengthInByte[j-1];
nal_type = ((* (frame_info.sLayerInfo[i].pBsBuf + nal_offset + 4)) & 0x1f);
- if (nal_type == NAL_SPS || nal_type == NAL_PPS)
- gst_buffer_fill (hdr, nal_offset, frame_info.sLayerInfo[i].pBsBuf, frame_info.sLayerInfo[i].pNalLengthInByte[j]);
+ /* Note: This only works if SPS/PPS are the first two NALs in which case
+ * nal_offset is the same for both the output and the bitstream buffer */
+ if (nal_type == NAL_SPS || nal_type == NAL_PPS) {
+ gst_buffer_fill (hdr, nal_offset,
+ frame_info.sLayerInfo[i].pBsBuf + nal_offset,
+ frame_info.sLayerInfo[i].pNalLengthInByte[j]);
+ }
}
headers = g_list_append (headers, gst_buffer_ref (hdr));
}