Class VorbisUtil

  • public final class VorbisUtil
    extends Object
    Utility methods for parsing Vorbis streams.
    • Method Detail

      • iLog

        public static int iLog​(int x)
        Returns ilog(x), which is the index of the highest set bit in x.
        x - the value of which the ilog should be calculated.
        See Also:
        Vorbis spec
      • readVorbisCommentHeader

        public static VorbisUtil.CommentHeader readVorbisCommentHeader​(ParsableByteArray headerData,
                                                                       boolean hasMetadataHeader,
                                                                       boolean hasFramingBit)
                                                                throws ParserException
        Reads a Vorbis comment header.

        The data provided may not contain the Vorbis metadata common header and the framing bit.

        headerData - A ParsableByteArray wrapping the header data.
        hasMetadataHeader - Whether the headerData contains a Vorbis metadata common header preceding the comment header.
        hasFramingBit - Whether the headerData contains a framing bit.
        A VorbisUtil.CommentHeader with all the comments.
        ParserException - If an error occurs parsing the comment header.
        See Also:
        Vorbis spec/Comment header
      • parseVorbisComments

        public static Metadata parseVorbisComments​(List<String> vorbisComments)
        Builds a Metadata instance from a list of Vorbis Comments.

        METADATA_BLOCK_PICTURE comments will be transformed into PictureFrame entries. All others will be transformed into VorbisComment entries.

        vorbisComments - The raw input of comments, as a key-value pair KEY=VAL.
        The fully parsed Metadata instance. Null if no vorbis comments could be parsed.
      • verifyVorbisHeaderCapturePattern

        public static boolean verifyVorbisHeaderCapturePattern​(int headerType,
                                                               ParsableByteArray header,
                                                               boolean quiet)
                                                        throws ParserException
        Verifies whether the next bytes in header are a Vorbis header of the given headerType.
        headerType - the type of the header expected.
        header - the alleged header bytes.
        quiet - if true no exceptions are thrown. Instead false is returned.
        the number of bytes read.
        ParserException - thrown if header type or capture pattern is not as expected.
      • readVorbisModes

        public static VorbisUtil.Mode[] readVorbisModes​(ParsableByteArray headerData,
                                                        int channels)
                                                 throws ParserException
        This method reads the modes which are located at the very end of the Vorbis setup header. That's why we need to partially decode or at least read the entire setup header to know where to start reading the modes.
        headerData - a ParsableByteArray containing setup header data.
        channels - the number of channels.
        an array of VorbisUtil.Modes.
        ParserException - thrown if bit stream is invalid.
        See Also:
        Vorbis spec/Setup header