• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cdata.uint_be函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mutagen._util.cdata.uint_be函数的典型用法代码示例。如果您正苦于以下问题:Python uint_be函数的具体用法?Python uint_be怎么用?Python uint_be使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __read_offsets

 def __read_offsets(self, filename):
     fileobj = open(filename, 'rb')
     atoms = Atoms(fileobj)
     moov = atoms['moov']
     samples = []
     for atom in moov.findall('stco', True):
         fileobj.seek(atom.offset + 12)
         data = fileobj.read(atom.length - 12)
         fmt = ">%dI" % cdata.uint_be(data[:4])
         offsets = struct.unpack(fmt, data[4:])
         for offset in offsets:
             fileobj.seek(offset)
             samples.append(fileobj.read(8))
     for atom in moov.findall('co64', True):
         fileobj.seek(atom.offset + 12)
         data = fileobj.read(atom.length - 12)
         fmt = ">%dQ" % cdata.uint_be(data[:4])
         offsets = struct.unpack(fmt, data[4:])
         for offset in offsets:
             fileobj.seek(offset)
             samples.append(fileobj.read(8))
     try:
         for atom in atoms["moof"].findall('tfhd', True):
             data = fileobj.read(atom.length - 9)
             flags = cdata.uint_be("\x00" + data[:3])
             if flags & 1:
                 offset = cdata.ulonglong_be(data[7:15])
                 fileobj.seek(offset)
                 samples.append(fileobj.read(8))
     except KeyError:
         pass
     fileobj.close()
     return samples
开发者ID:andrewboie,项目名称:discogstool,代码行数:33,代码来源:test_mp4.py


示例2: __parse_freeform

    def __parse_freeform(self, atom, data):
        length = cdata.uint_be(data[:4])
        mean = data[12:length]
        pos = length
        length = cdata.uint_be(data[pos : pos + 4])
        name = data[pos + 12 : pos + length]
        pos += length
        value = []
        while pos < atom.length - 8:
            length, atom_name = struct.unpack(">I4s", data[pos : pos + 8])
            if atom_name != b"data":
                raise MP4MetadataError(
                    "unexpected atom %r inside %r" % (atom_name, atom.name)
                )

            version = ord(data[pos + 8 : pos + 8 + 1])
            flags = struct.unpack(">I", b"\x00" + data[pos + 9 : pos + 12])[0]
            value.append(
                MP4FreeForm(
                    data[pos + 16 : pos + length], dataformat=flags, version=version
                )
            )
            pos += length

        key = _name2key(atom.name + b":" + mean + b":" + name)
        self.__add(key, value)
开发者ID:dcramer,项目名称:sickbeard_mp4_automator,代码行数:26,代码来源:__init__.py


示例3: __init__

    def __init__(self, atoms, fileobj):
        for trak in list(atoms["moov"].findall(b"trak")):
            hdlr = trak["mdia", "hdlr"]
            fileobj.seek(hdlr.offset)
            data = fileobj.read(hdlr.length)
            if data[16:20] == b"soun":
                break
        else:
            raise MP4StreamInfoError("track has no audio data")

        mdhd = trak["mdia", "mdhd"]
        fileobj.seek(mdhd.offset)
        data = bytearray(fileobj.read(mdhd.length))
        if data[8] == 0:
            offset = 20
            fmt = ">2I"
        else:
            offset = 28
            fmt = ">IQ"
        end = offset + struct_calcsize(fmt)
        unit, length = struct_unpack(fmt, data[offset:end])
        self.length = float(length) / unit

        try:
            atom = trak["mdia", "minf", "stbl", "stsd"]
            fileobj.seek(atom.offset)
            data = bytearray(fileobj.read(atom.length))
            if data[20:24] == b"mp4a":
                length = cdata.uint_be(data[16:20])
                (self.channels, self.bits_per_sample, _,
                 self.sample_rate) = struct_unpack(">3HI", data[40:50])
                # ES descriptor type
                if data[56:60] == b"esds" and ord(data[64:65]) == 0x03:
                    pos = 65
                    # skip extended descriptor type tag, length, ES ID
                    # and stream priority
                    if data[pos:pos+3] == b"\x80\x80\x80":
                        pos += 3
                    pos += 4
                    # decoder config descriptor type
                    if data[pos] == 0x04:
                        pos += 1
                        # skip extended descriptor type tag, length,
                        # object type ID, stream type, buffer size
                        # and maximum bitrate
                        if data[pos:pos+3] == b"\x80\x80\x80":
                            pos += 3
                        pos += 10
                        # average bitrate
                        self.bitrate = cdata.uint_be(data[pos:pos+4])
        except (ValueError, KeyError):
            # stsd atoms are optional
            pass
开发者ID:Sophist-UK,项目名称:mutagen,代码行数:53,代码来源:mp4.py


示例4: test_uint

    def test_uint(self):
        self.failUnlessEqual(cdata.uint_le(self.ZERO(4)), 0)
        self.failUnlessEqual(cdata.uint_le(self.LEONE(4)), 1)
        self.failUnlessEqual(cdata.uint_le(self.BEONE(4)), 2 ** 32 >> 8)
        self.failUnlessEqual(cdata.uint_le(self.NEGONE(4)), 2 ** 32 - 1)
        self.assertTrue(cdata.uint_le is cdata.uint32_le)

        self.failUnlessEqual(cdata.uint_be(self.ZERO(4)), 0)
        self.failUnlessEqual(cdata.uint_be(self.LEONE(4)), 2 ** 32 >> 8)
        self.failUnlessEqual(cdata.uint_be(self.BEONE(4)), 1)
        self.failUnlessEqual(cdata.uint_be(self.NEGONE(4)), 2 ** 32 - 1)
        self.assertTrue(cdata.uint_be is cdata.uint32_be)
开发者ID:akerbis,项目名称:mutagen,代码行数:12,代码来源:test__util.py


示例5: __update_parents

 def __update_parents(self, fileobj, path, delta, offset):
     # Update all parent atoms with the new size.
     for atom in path:
         fileobj.seek(atom.offset + offset)
         size = cdata.uint_be(fileobj.read(4)) + delta
         fileobj.seek(atom.offset + offset)
         fileobj.write(cdata.to_uint_be(size))
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:7,代码来源:m4a.py


示例6: __init__

    def __init__(self, atoms, fileobj):
        hdlr = atoms["moov.trak.mdia.hdlr"]
        fileobj.seek(hdlr.offset)
        if "soun" not in fileobj.read(hdlr.length):
            raise M4AStreamInfoError("track has no audio data")

        mdhd = atoms["moov.trak.mdia.mdhd"]
        fileobj.seek(mdhd.offset)
        data = fileobj.read(mdhd.length)
        if ord(data[8]) == 0:
            offset = 20
            fmt = ">2I"
        else:
            offset = 28
            fmt = ">IQ"
        end = offset + struct.calcsize(fmt)
        unit, length = struct.unpack(fmt, data[offset:end])
        self.length = float(length) / unit

        try:
            atom = atoms["moov.trak.mdia.minf.stbl.stsd"]
            fileobj.seek(atom.offset)
            data = fileobj.read(atom.length)
            self.bitrate = cdata.uint_be(data[-17:-13])
        except (ValueError, KeyError):
            # Bitrate values are optional.
            pass
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:27,代码来源:m4a.py


示例7: __parse_freeform

 def __parse_freeform(self, atom, data):
     length = cdata.uint_be(data[:4])
     mean = data[12:length]
     pos = length
     length = cdata.uint_be(data[pos : pos + 4])
     name = data[pos + 12 : pos + length]
     pos += length
     value = []
     while pos < atom.length - 8:
         length, atom_name = struct.unpack(">I4s", data[pos : pos + 8])
         if atom_name != "data":
             raise MP4MetadataError("unexpected atom %r inside %r" % (atom_name, atom.name))
         value.append(data[pos + 16 : pos + length])
         pos += length
     if value:
         self["%s:%s:%s" % (atom.name, mean, name)] = value
开发者ID:kwytay,项目名称:Magger,代码行数:16,代码来源:mp4.py


示例8: __parse_freeform

 def __parse_freeform(self, atom, data):
     try:
         fileobj = StringIO(data)
         mean_length = cdata.uint_be(fileobj.read(4))
         # skip over 8 bytes of atom name, flags
         mean = fileobj.read(mean_length - 4)[8:]
         name_length = cdata.uint_be(fileobj.read(4))
         name = fileobj.read(name_length - 4)[8:]
         value_length = cdata.uint_be(fileobj.read(4))
         # Name, flags, and reserved bytes
         value = fileobj.read(value_length - 4)[12:]
     except struct.error:
         # Some ---- atoms have no data atom, I have no clue why
         # they actually end up in the file.
         pass
     else:
         self["%s:%s:%s" % (atom.name, mean, name)] = value
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:17,代码来源:m4a.py


示例9: __update_offset_table

 def __update_offset_table(self, fileobj, fmt, atom, delta, offset):
     """Update offset table in the specified atom."""
     if atom.offset > offset:
         atom.offset += delta
     fileobj.seek(atom.offset + 12)
     data = fileobj.read(atom.length - 12)
     fmt = fmt % cdata.uint_be(data[:4])
     offsets = struct.unpack(fmt, data[4:])
     offsets = [o + (0, delta)[offset < o] for o in offsets]
     fileobj.seek(atom.offset + 16)
     fileobj.write(struct.pack(fmt, *offsets))
开发者ID:jbcurtin,项目名称:mutagen,代码行数:11,代码来源:__init__.py


示例10: _parse_full_atom

def _parse_full_atom(data):
    """Some atoms are versioned. Split them up in (version, flags, payload).
    Can raise ValueError.
    """

    if len(data) < 4:
        raise ValueError("not enough data")

    version = ord(data[0:1])
    flags = cdata.uint_be(b"\x00" + data[1:4])
    return version, flags, data[4:]
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:11,代码来源:mp4.py


示例11: __update_tfhd

 def __update_tfhd(self, fileobj, atom, delta, offset):
     if atom.offset > offset:
         atom.offset += delta
     fileobj.seek(atom.offset + 9)
     data = fileobj.read(atom.length - 9)
     flags = cdata.uint_be(b"\x00" + data[:3])
     if flags & 1:
         o = cdata.ulonglong_be(data[7:15])
         if o > offset:
             o += delta
         fileobj.seek(atom.offset + 16)
         fileobj.write(cdata.to_ulonglong_be(o))
开发者ID:jbcurtin,项目名称:mutagen,代码行数:12,代码来源:__init__.py


示例12: __update_parents

 def __update_parents(self, fileobj, path, delta):
     """Update all parent atoms with the new size."""
     for atom in path:
         fileobj.seek(atom.offset)
         size = cdata.uint_be(fileobj.read(4))
         if size == 1: # 64bit
             # skip name (4B) and read size (8B)
             size = cdata.ulonglong_be(fileobj.read(12)[4:])
             fileobj.seek(atom.offset + 8)
             fileobj.write(cdata.to_ulonglong_be(size + delta))
         else: # 32bit
             fileobj.seek(atom.offset)
             fileobj.write(cdata.to_uint_be(size + delta))
开发者ID:Sophist-UK,项目名称:mutagen,代码行数:13,代码来源:mp4.py


示例13: __parse_freeform

    def __parse_freeform(self, atom, data):
        length = cdata.uint_be(data[:4])
        mean = data[12:length]
        pos = length
        length = cdata.uint_be(data[pos : pos + 4])
        name = data[pos + 12 : pos + length]
        pos += length
        value = []
        while pos < atom.length - 8:
            length, atom_name = struct.unpack(">I4s", data[pos : pos + 8])
            if atom_name != "data":
                raise MP4MetadataError("unexpected atom %r inside %r" % (atom_name, atom.name))

            version = ord(data[pos + 8])
            if version != 0:
                raise MP4MetadataError("Unsupported version: %r" % version)

            flags = struct.unpack(">I", "\x00" + data[pos + 9 : pos + 12])[0]
            value.append(MP4FreeForm(data[pos + 16 : pos + length], dataformat=flags))
            pos += length
        if value:
            self["%s:%s:%s" % (atom.name, mean, name)] = value
开发者ID:andrewboie,项目名称:discogstool,代码行数:22,代码来源:mp4.py


示例14: __init__

 def __init__(self, fileobj):
     page = OggPage(fileobj)
     while not page.packets[0].startswith("\x80theora"):
         page = OggPage(fileobj)
     if not page.first:
         raise OggTheoraHeaderError(
             "page has ID header, but doesn't start a stream")
     data = page.packets[0]
     vmaj, vmin = struct.unpack("2B", data[7:9])
     if (vmaj, vmin) != (3, 2):
         raise OggTheoraHeaderError(
             "found Theora version %d.%d != 3.2" % (vmaj, vmin))
     fps_num, fps_den = struct.unpack(">2I", data[22:30])
     self.fps = fps_num / float(fps_den)
     self.bitrate = cdata.uint_be("\x00" + data[37:40])
     self.granule_shift = (cdata.ushort_be(data[40:42]) >> 5) & 0x1F
     self.serial = page.serial
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:17,代码来源:oggtheora.py


示例15: __parse_text

 def __parse_text(self, atom, data):
     flags = cdata.uint_be(data[8:12])
     if flags == 1:
         self[atom.name] = data[16:].decode('utf-8', 'replace')
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:4,代码来源:m4a.py


示例16: __parse_uint32

 def __parse_uint32(self, atom, data):
     self[atom.name] = [cdata.uint_be(value[1]) for
                        value in self.__parse_data(atom, data)]
开发者ID:floam,项目名称:sickbeard_mp4_automator,代码行数:3,代码来源:mp4.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cdata.uint_le函数代码示例发布时间:2022-05-27
下一篇:
Python cdata.to_ulonglong_be函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap