openh264enc: fix broken sps/pps header generation and some minor leaks
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
openh264enc: fix caps and header buffer leak
openh264enc: improve readability of header handling code
Related to 17113695
Edited by Nicolas Dufresne