当前位置: 首页>>代码示例>>Python>>正文


Python BitReader.bytes方法代码示例

本文整理汇总了Python中mutagen._util.BitReader.bytes方法的典型用法代码示例。如果您正苦于以下问题:Python BitReader.bytes方法的具体用法?Python BitReader.bytes怎么用?Python BitReader.bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mutagen._util.BitReader的用法示例。


在下文中一共展示了BitReader.bytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mutagen._util import BitReader [as 别名]
# 或者: from mutagen._util.BitReader import bytes [as 别名]
    def __init__(self, fileobj, length):
        """Raises DescriptorError"""

        r = BitReader(fileobj)
        try:
            self.ES_ID = r.bits(16)
            self.streamDependenceFlag = r.bits(1)
            self.URL_Flag = r.bits(1)
            self.OCRstreamFlag = r.bits(1)
            self.streamPriority = r.bits(5)
            if self.streamDependenceFlag:
                self.dependsOn_ES_ID = r.bits(16)
            if self.URL_Flag:
                URLlength = r.bits(8)
                self.URLstring = r.bytes(URLlength)
            if self.OCRstreamFlag:
                self.OCR_ES_Id = r.bits(16)

            tag = r.bits(8)
        except BitReaderError as e:
            raise DescriptorError(e)

        if tag != DecoderConfigDescriptor.TAG:
            raise DescriptorError("unexpected DecoderConfigDescrTag %d" % tag)

        assert r.is_aligned()
        self.decConfigDescr = DecoderConfigDescriptor.parse(fileobj)
开发者ID:dcramer,项目名称:sickbeard_mp4_automator,代码行数:29,代码来源:_as_entry.py

示例2: __init__

# 需要导入模块: from mutagen._util import BitReader [as 别名]
# 或者: from mutagen._util.BitReader import bytes [as 别名]
    def __init__(self, xing, fileobj):
        """Raises LAMEError if parsing fails"""

        payload = fileobj.read(27)
        if len(payload) != 27:
            raise LAMEError("Not enough data")

        # extended lame header
        r = BitReader(cBytesIO(payload))
        revision = r.bits(4)
        if revision != 0:
            raise LAMEError("unsupported header revision %d" % revision)

        self.vbr_method = r.bits(4)
        self.lowpass_filter = r.bits(8) * 100

        # these have a different meaning for lame; expose them again here
        self.quality = (100 - xing.vbr_scale) % 10
        self.vbr_quality = (100 - xing.vbr_scale) // 10

        track_peak_data = r.bytes(4)
        if track_peak_data == b"\x00\x00\x00\x00":
            self.track_peak = None
        else:
            # see PutLameVBR() in LAME's VbrTag.c
            self.track_peak = (
                cdata.uint32_be(track_peak_data) - 0.5) / 2 ** 23
        track_gain_type = r.bits(3)
        self.track_gain_origin = r.bits(3)
        sign = r.bits(1)
        gain_adj = r.bits(9) / 10.0
        if sign:
            gain_adj *= -1
        if track_gain_type == 1:
            self.track_gain_adjustment = gain_adj
        else:
            self.track_gain_adjustment = None
        assert r.is_aligned()

        album_gain_type = r.bits(3)
        self.album_gain_origin = r.bits(3)
        sign = r.bits(1)
        album_gain_adj = r.bits(9) / 10.0
        if album_gain_type == 2:
            self.album_gain_adjustment = album_gain_adj
        else:
            self.album_gain_adjustment = None

        self.encoding_flags = r.bits(4)
        self.ath_type = r.bits(4)

        self.bitrate = r.bits(8)

        self.encoder_delay_start = r.bits(12)
        self.encoder_padding_end = r.bits(12)

        self.source_sample_frequency_enum = r.bits(2)
        self.unwise_setting_used = r.bits(1)
        self.stereo_mode = r.bits(3)
        self.noise_shaping = r.bits(2)

        sign = r.bits(1)
        mp3_gain = r.bits(7)
        if sign:
            mp3_gain *= -1
        self.mp3_gain = mp3_gain

        r.skip(2)
        self.surround_info = r.bits(3)
        self.preset_used = r.bits(11)
        self.music_length = r.bits(32)
        self.music_crc = r.bits(16)

        self.header_crc = r.bits(16)
        assert r.is_aligned()
开发者ID:YipYup,项目名称:headphones,代码行数:77,代码来源:_util.py

示例3: test_bytes_unaligned

# 需要导入模块: from mutagen._util import BitReader [as 别名]
# 或者: from mutagen._util.BitReader import bytes [as 别名]
 def test_bytes_unaligned(self):
     r = BitReader(cBytesIO(b"\xAB\xCD\xEF"))
     r.skip(4)
     self.assertEqual(r.bytes(2), b"\xBC\xDE")
开发者ID:akerbis,项目名称:mutagen,代码行数:6,代码来源:test__util.py

示例4: test_bytes

# 需要导入模块: from mutagen._util import BitReader [as 别名]
# 或者: from mutagen._util.BitReader import bytes [as 别名]
 def test_bytes(self):
     r = BitReader(cBytesIO(b"\xAB\xCD\xEF"))
     self.assertEqual(r.bytes(2), b"\xAB\xCD")
     self.assertEqual(r.bytes(0), b"")
开发者ID:akerbis,项目名称:mutagen,代码行数:6,代码来源:test__util.py


注:本文中的mutagen._util.BitReader.bytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。