Copied the implementation from h264parser and adapted it to the HEVC syntax. gstreamer/gst-plugins-bad#790