Exemplo n.º 1
0
def createNullField(parent, nbits, name="padding[]", description=None):
    if nbits <= 0:
        raise FieldError("Unable to create null padding of %s bits" % nbits)
    if (nbits % 8) == 0:
        return NullBytes(parent, name, nbits // 8, description)
    else:
        return NullBits(parent, name, nbits, description)
Exemplo n.º 2
0
    def createFields(self):
        # First kilobyte: boot sectors
        yield RawBytes(self, "boot", 1024, "Space for disklabel etc.")

        # Header
        yield UInt32(self, "version")
        yield UInt32(self, "last_page")
        yield UInt32(self, "nb_badpage")
        yield UUID(self, "sws_uuid")
        yield UUID(self, "sws_volume")
        yield NullBytes(self, "reserved", 117 * 4)

        # Read bad pages (if any)
        count = self["nb_badpage"].value
        if count:
            if MAX_SWAP_BADPAGES < count:
                raise ParserError("Invalid number of bad page (%u)" % count)
            yield GenericVector(self, "badpages", count, UInt32, "badpage")

        # Read magic
        padding = self.seekByte(PAGE_SIZE - 10, "padding", null=True)
        if padding:
            yield padding
        yield String(self, "magic", 10, charset="ASCII")

        # Read all pages
        yield GenericVector(self, "pages", self["last_page"].value, Page,
                            "page")

        # Padding at the end
        padding = self.seekBit(self.size, "end_padding", null=True)
        if padding:
            yield padding
Exemplo n.º 3
0
    def createFields(self):
        # Header
        yield NullBytes(self, "zero_vector", 16)
        yield GUID(self, "fs_guid")
        yield UInt64(self, "volume_len")
        yield String(self, "signature", 4)
        yield UInt32(self, "attributes")
        yield UInt16(self, "header_len")
        yield UInt16(self, "checksum")
        yield UInt16(self, "ext_header_offset")
        yield UInt8(self, "reserved")
        yield UInt8(self, "revision")
        while True:
            bm = BlockMap(self, "block_map[]")
            yield bm
            if bm['num_blocks'].value == 0 and bm['len'].value == 0:
                break
        # TODO must handle extended header

        # Content
        while not self.eof:
            padding = paddingSize(self.current_size // 8, 8)
            if padding:
                yield PaddingBytes(self, "padding[]", padding)
            yield File(self, "file[]")
Exemplo n.º 4
0
def parseAviHeader(self):
    yield UInt32(self, "microsec_per_frame", "Microsecond per frame")
    yield UInt32(self, "max_byte_per_sec", "Maximum byte per second")
    yield NullBytes(self, "reserved", 4)

    # Flags
    yield NullBits(self, "reserved[]", 4)
    yield Bit(self, "has_index")
    yield Bit(self, "must_use_index")
    yield NullBits(self, "reserved[]", 2)
    yield Bit(self, "is_interleaved")
    yield NullBits(self, "reserved[]", 2)
    yield Bit(self, "trust_cktype")
    yield NullBits(self, "reserved[]", 4)
    yield Bit(self, "was_capture_file")
    yield Bit(self, "is_copyrighted")
    yield NullBits(self, "reserved[]", 14)

    yield UInt32(self, "total_frame", "Total number of frames in the video")
    yield UInt32(self, "init_frame",
                 "Initial frame (used in interleaved video)")
    yield UInt32(self, "nb_stream", "Number of streams")
    yield UInt32(self, "sug_buf_size", "Suggested buffer size")
    yield UInt32(self, "width", "Width in pixel")
    yield UInt32(self, "height", "Height in pixel")
    yield UInt32(self, "scale")
    yield UInt32(self, "rate")
    yield UInt32(self, "start")
    yield UInt32(self, "length")
Exemplo n.º 5
0
    def createFields(self):
        yield Bytes(self, "endian", 2, "Endian (\\xfe\\xff for little endian)")
        yield UInt16(self, "format", "Format (0)")
        yield UInt8(self, "os_version")
        yield UInt8(self, "os_revision")
        yield Enum(UInt16(self, "os_type"), OS_NAME)
        yield GUID(self, "format_id")
        yield UInt32(self, "section_count")
        if MAX_SECTION_COUNT < self["section_count"].value:
            raise ParserError("OLE2: Too much sections (%s)" %
                              self["section_count"].value)

        section_indexes = []
        for index in range(self["section_count"].value):
            section_index = SummaryIndex(self, "section_index[]")
            yield section_index
            section_indexes.append(section_index)

        for section_index in section_indexes:
            self.seekByte(section_index["offset"].value)
            yield SummarySection(self, "section[]")

        size = (self.size - self.current_size) // 8
        if 0 < size:
            yield NullBytes(self, "end_padding", size)
Exemplo n.º 6
0
    def createFields(self):
        yield String(self, "signature", 4, "PSD signature (8BPS)", charset="ASCII")
        yield UInt16(self, "version")
        yield NullBytes(self, "reserved[]", 6)
        yield UInt16(self, "nb_channels")
        yield UInt32(self, "width")
        yield UInt32(self, "height")
        yield UInt16(self, "depth")
        yield Enum(UInt16(self, "color_mode"), self.COLOR_MODE)

        # Mode data
        yield UInt32(self, "mode_data_size")
        size = self["mode_data_size"].value
        if size:
            yield RawBytes(self, "mode_data", size)

        # Resources
        yield Config(self, "config")

        # Reserved
        yield UInt32(self, "reserved_data_size")
        size = self["reserved_data_size"].value
        if size:
            yield RawBytes(self, "reserved_data", size)

        yield Enum(UInt16(self, "compression"), self.COMPRESSION_NAME)

        size = (self.size - self.current_size) // 8
        if size:
            yield RawBytes(self, "end", size)
Exemplo n.º 7
0
 def createFields(self):
     yield NullBytes(self, "options", 4)
     yield TimestampUnix32(self, "creation_date")
     yield UInt16(self, "maj_ver", "Major version")
     yield UInt16(self, "min_ver", "Minor version")
     yield UInt16(self, "nb_name", "Number of named entries")
     yield UInt16(self, "nb_index", "Number of indexed entries")
Exemplo n.º 8
0
    def createFields(self):
        yield IFDTag(self, "tag", "Tag")
        yield Enum(UInt16(self, "type", "Type"), self.TYPE_NAME)
        self.value_cls = self.ENTRY_FORMAT.get(self['type'].value, Bytes)
        if issubclass(self.value_cls, Bytes):
            self.value_size = 8
        else:
            self.value_size = self.value_cls.static_size
        yield UInt32(self, "count", "Count")

        if not issubclass(self.value_cls, Bytes) \
                and self["count"].value > MAX_COUNT:
            raise ParserError("EXIF: Invalid count value (%s)" %
                              self["count"].value)

        count = self['count'].value
        totalsize = self.value_size * count
        if count == 0:
            yield NullBytes(self, "padding", 4)
        elif totalsize <= 32:
            name = "value"
            if issubclass(self.value_cls, Bytes):
                yield self.value_cls(self, name, count)
            else:
                if count > 1:
                    name += "[]"
                for i in range(count):
                    yield self.value_cls(self, name)
            if totalsize < 32:
                yield NullBits(self, "padding", 32 - totalsize)
        else:
            yield UInt32(self, "offset", "Value offset")
Exemplo n.º 9
0
    def createFields(self):
        yield UInt16(self, "left", "Left")
        yield UInt16(self, "top", "Top")
        yield UInt16(self, "width", "Width")
        yield UInt16(self, "height", "Height")

        yield Bits(self, "size_local_map", 3,
                   "log2(size of local map) minus one")
        yield NullBits(self, "reserved", 2)
        yield Bit(self, "sort_flag",
                  "Is the local map sorted by decreasing importance?")
        yield Bit(self, "interlaced", "Interlaced?")
        yield Bit(self, "has_local_map", "Use local color map?")

        if self["has_local_map"].value:
            nb_color = 1 << (1 + self["size_local_map"].value)
            yield PaletteRGB(self, "local_map", nb_color, "Local color map")

        yield UInt8(self, "lzw_min_code_size", "LZW Minimum Code Size")
        group = None
        while True:
            size = UInt8(self, "image_block_size[]")
            if size.value == 0:
                break
            yield size
            block = CustomFragment(self, "image_block[]", size.value * 8,
                                   GifImageBlock, "GIF Image Block", group)
            if group is None:
                block.group.args["startbits"] = self["lzw_min_code_size"].value
            group = block.group
            yield block
        yield NullBytes(self, "terminator", 1, "Terminator (0)")
Exemplo n.º 10
0
 def createFields(self):
     yield NullBytes(self, "zero", 1)
     yield textHandler(
         String(self,
                "length",
                self._size // 8 - 1,
                "Length in ms",
                charset="ASCII"), self.computeLength)
Exemplo n.º 11
0
 def createFields(self):
     yield GUID(self, "clsid", "16 bytes GUID used by some apps")
     yield UInt16(self, "ver_min", "Minor version")
     yield UInt16(self, "ver_maj", "Major version")
     yield Bytes(self, "endian", 2, "Endian (\\xfe\\xff for little endian)")
     yield UInt16(self, "bb_shift", "Log, base 2, of the big block size")
     yield UInt16(self, "sb_shift", "Log, base 2, of the small block size")
     yield NullBytes(self, "reserved[]", 6, "(reserved)")
     yield UInt32(self, "csectdir", "Number of SECTs in directory chain for 4 KB sectors (version 4)")
     yield UInt32(self, "bb_count", "Number of Big Block Depot blocks")
     yield SECT(self, "bb_start", "Root start block")
     yield NullBytes(self, "transaction", 4, "Signature used for transactions (must be zero)")
     yield UInt32(self, "threshold", "Maximum size for a mini stream (typically 4096 bytes)")
     yield SECT(self, "sb_start", "Small Block Depot start block")
     yield UInt32(self, "sb_count")
     yield SECT(self, "db_start", "First block of DIFAT")
     yield UInt32(self, "db_count", "Number of SECTs in DIFAT")
Exemplo n.º 12
0
 def createFields(self):
     yield textHandler(
         UInt32(self, "signature",
                "Placeable Metafiles signature (0x9AC6CDD7)"), hexadecimal)
     yield UInt16(self, "handle")
     yield RECT16(self, "rect")
     yield UInt16(self, "inch")
     yield NullBytes(self, "reserved", 4)
     yield textHandler(UInt16(self, "checksum"), hexadecimal)
Exemplo n.º 13
0
 def createFields(self):
     yield UInt32(self, "version")
     yield UInt8(self, "has_realm")
     yield PascalStringWin32(self, "writer_name", charset="UTF-16-BE")
     yield PascalStringWin32(self, "reader_name", charset="UTF-16-BE")
     yield UInt32(self, "file_version")
     size = (self.size - self.current_size) // 8
     if size:
         yield NullBytes(self, "padding", size)
Exemplo n.º 14
0
 def createFields(self):
     while not self.eof:
         field = FileEntry(self, "file[]")
         if field.isEmpty():
             yield NullBytes(self, "terminator", 512)
             break
         yield field
     if self.current_size < self._size:
         yield self.seekBit(self._size, "end")
Exemplo n.º 15
0
 def createFields(self):
     yield UInt32(self, "inode", "Inode")
     yield UInt16(self, "rec_len", "Record length")
     yield UInt8(self, "name_len", "Name length")
     yield Enum(UInt8(self, "file_type", "File type"), self.file_type)
     yield String(self, "name", self["name_len"].value, "File name")
     size = (self._size - self.current_size) // 8
     if size:
         yield NullBytes(self, "padding", size)
Exemplo n.º 16
0
 def createFields(self):
     # TODO: This structure is normally divided in two parts:
     # _reiserfs_super_block_v1
     # _reiserfs_super_block
     # It will be divided later to easily support older version of the first
     # part
     yield UInt32(self, "block_count", "Number of blocks")
     yield UInt32(self, "free_blocks", "Number of free blocks")
     yield UInt32(self, "root_block", "Root block number")
     yield Journal_params(self, "Journal parameters")
     yield UInt16(self, "blocksize", "Size of a block")
     yield UInt16(self, "oid_maxsize", "Max size of object id array")
     yield UInt16(self, "oid_cursize", "Current size of object id array")
     yield Enum(UInt16(self, "umount_state", "Filesystem umounted or not"),
                self.UMOUNT_STATE)
     yield String(self, "magic", 10, "Magic string", strip="\0")
     # TODO: change the type of s_fs_state in Enum to have more details
     # about this fsck state
     yield UInt16(self, "fs_state", "Rebuilding phase of fsck ")
     yield Enum(
         UInt32(self, "hash_function",
                "Hash function to sort names in a directory"),
         self.HASH_FUNCTIONS)
     yield UInt16(self, "tree_height", "Height of disk tree")
     yield UInt16(
         self, "bmap_nr",
         "Amount of bitmap blocks needed to address each block of file system"
     )
     # TODO: find a good description for this field
     yield UInt16(
         self, "version",
         "Field only reliable on filesystem with non-standard journal")
     yield UInt16(self, "reserved_for_journal",
                  "Size in blocks of journal area on main device")
     # TODO: same as above
     yield UInt32(self, "inode_generation", "No description")
     # TODO: same as above and should be an enum field
     yield UInt32(self, "flags", "No description")
     # TODO: Create a special Type to format this id
     yield RawBytes(self, "uuid", 16, "Filesystem unique identifier")
     yield String(self, "label", 16, "Filesystem volume label", strip="\0")
     yield NullBytes(self, "unused", 88)
     yield NullBytes(self, "Bytes before end of the block",
                     self["blocksize"].value - 204)
Exemplo n.º 17
0
 def createFields(self):
     yield RawBytes(self, "md5", 16)
     while True:
         size = (self.size - self.current_size) // 8
         if size < 77:
             break
         yield EncryptedItem(self, "item[]")
     size = paddingSize(self.current_size // 8, 16)
     if size:
         yield NullBytes(self, "padding_align", size)
Exemplo n.º 18
0
 def createFields(self):
     yield NullBytes(self, "unused", 6)
     yield UInt8(self, "offsetIntSize",
                 "Size (in bytes) of offsets in the offset table")
     yield UInt8(self, "objectRefSize",
                 "Size (in bytes) of object numbers in object references")
     yield UInt64(self, "numObjects", "Number of objects in this file")
     yield UInt64(self, "topObject", "Top-level object reference")
     yield UInt64(self, "offsetTableOffset",
                  "File offset to the offset table")
Exemplo n.º 19
0
    def createFields(self):
        yield UInt16(self, "size", "Node size (in bytes)")
        yield UInt16(self, "data_size")
        yield CString(self, "name", charset="ISO-8859-1")

        size = paddingSize(self.current_size // 8, 4)
        if size:
            yield NullBytes(self, "padding[]", size)
        size = self["data_size"].value
        if size:
            if self["name"].value == "VS_VERSION_INFO":
                yield VersionInfoBinary(self, "value", size=size * 8)
            else:
                yield String(self, "value", size, charset="ISO-8859-1")
        while 12 <= (self.size - self.current_size) // 8:
            yield NE_VersionInfoNode(self, "node[]")
        size = (self.size - self.current_size) // 8
        if size:
            yield NullBytes(self, "padding[]", size)
Exemplo n.º 20
0
    def createFields(self):
        yield UInt32(self, "size")
        yield RawBytes(self, "format", 4, "Data Format (codec)")
        yield NullBytes(self, "reserved[]", 6, "Reserved")
        yield UInt16(self, "data_reference_index")
        handler = findHandler(self)
        if not handler:
            raise ParserError("stsd couldn't find track handler")
        if handler['subtype'].value == 'soun':
            # Audio sample entry
            yield NullBytes(self, "reserved[]", 8)
            yield UInt16(self, "channels", "Number of audio channels")
            yield UInt16(self, "samplesize", "Sample size in bits")
            yield UInt16(self, "unknown")
            yield NullBytes(self, "reserved[]", 2)
            yield QTFloat32(self, "samplerate", "Sample rate in Hz")
        elif handler['subtype'].value == 'vide':
            # Video sample entry
            yield UInt16(self, "version")
            yield UInt16(self, "revision_level")
            yield RawBytes(self, "vendor_id", 4)
            yield UInt32(self, "temporal_quality")
            yield UInt32(self, "spatial_quality")
            yield UInt16(self, "width", "Width (pixels)")
            yield UInt16(self, "height", "Height (pixels)")
            yield QTFloat32(self, "horizontal_resolution",
                            "Horizontal resolution in DPI")
            yield QTFloat32(self, "vertical resolution",
                            "Vertical resolution in DPI")
            yield UInt32(self, "data_size")
            yield UInt16(self, "frame_count")
            yield UInt8(self, "compressor_name_length")
            yield String(self, "compressor_name", 31, strip='\0')
            yield UInt16(self, "depth", "Bit depth of image")
            yield Int16(self, "unknown")
        elif handler['subtype'].value == 'hint':
            # Hint sample entry
            pass

        size = self['size'].value - self.current_size // 8
        if size > 0:
            yield RawBytes(self, "extra_data", size)
Exemplo n.º 21
0
def parseNames(self):
    # Read header
    yield UInt16(self, "format")
    if self["format"].value != 0:
        raise ParserError("TTF (names): Invalid format (%u)" %
                          self["format"].value)
    yield UInt16(self, "count")
    yield UInt16(self, "offset")
    if MAX_NAME_COUNT < self["count"].value:
        raise ParserError("Invalid number of names (%s)" % self["count"].value)

    # Read name index
    entries = []
    for index in range(self["count"].value):
        entry = NameHeader(self, "header[]")
        yield entry
        entries.append(entry)

    # Sort names by their offset
    entries.sort(key=lambda field: field["offset"].value)

    # Read name value
    last = None
    for entry in entries:
        # Skip duplicates values
        new = (entry["offset"].value, entry["length"].value)
        if last and last == new:
            self.warning("Skip duplicate %s %s" % (entry.name, new))
            continue
        last = (entry["offset"].value, entry["length"].value)

        # Skip negative offset
        offset = entry["offset"].value + self["offset"].value
        if offset < self.current_size // 8:
            self.warning("Skip value %s (negative offset)" % entry.name)
            continue

        # Add padding if any
        padding = self.seekByte(offset, relative=True, null=True)
        if padding:
            yield padding

        # Read value
        size = entry["length"].value
        if size:
            yield String(self,
                         "value[]",
                         size,
                         entry.description,
                         charset=entry.getCharset())

    padding = (self.size - self.current_size) // 8
    if padding:
        yield NullBytes(self, "padding_end", padding)
Exemplo n.º 22
0
 def createFields(self):
     yield String(self, "type", 4, "Signature (FORM)", charset="ASCII")
     yield filesizeHandler(UInt32(self, "size"))
     size = self["size"].value
     if size:
         if self._parser:
             yield from self._parser(self)
             if size % 2:
                 yield NullBytes(self, "padding", 1)
         else:
             yield RawBytes(self, "data", size)
Exemplo n.º 23
0
 def createFields(self):
     yield UInt32(self, "num_spaces", "Total number of entries, including blank entries")
     nobj = self['/num_objects'].value
     nspace = self['num_spaces'].value
     for i in range(nobj + 1):
         yield BomTrailerEntry(self, "entry[]")
     yield NullBytes(self, "blank_entries", (nspace - nobj - 1) * (BomTrailerEntry.static_size // 8))
     yield UInt32(self, "num_trail")
     ntrail = self['num_trail'].value
     for i in range(ntrail):
         yield BomTrailerEntry(self, "trail[]")
Exemplo n.º 24
0
 def createFields(self):
     yield UInt8(self, "tag")
     yield UInt24(self, "size", "Content size")
     yield UInt24(self, "timestamp", "Timestamp in millisecond")
     yield NullBytes(self, "reserved", 4)
     size = self["size"].value
     if size:
         if self.parser:
             yield from self.parser(self, size)
         else:
             yield RawBytes(self, "content", size)
Exemplo n.º 25
0
 def createFields(self):
     while self.current_size < self.size:
         next = self.stream.readBytes(
             self.absolute_address + self.current_size, 1)
         if next == '\x00':
             padding = paddingSize(
                 (self.absolute_address + self.current_size) // 8, 512)
             if padding:
                 yield NullBytes(self, "padding[]", padding)
             if self.current_size >= self.size:
                 break
         yield SEPX(self, "sepx[]")
Exemplo n.º 26
0
    def createFields(self):
        yield Bytes(self, "jump", 3, "Intel x86 jump instruction")
        yield String(self, "name", 8)
        yield BiosParameterBlock(self, "bios", "BIOS parameters")

        yield textHandler(UInt8(self, "physical_drive", "(0x80)"), hexadecimal)
        yield NullBytes(self, "current_head", 1)
        yield textHandler(UInt8(self, "ext_boot_sig", "Extended boot signature (0x80)"), hexadecimal)
        yield NullBytes(self, "unused", 1)

        yield UInt64(self, "nb_sectors")
        yield UInt64(self, "mft_cluster", "Cluster location of MFT data")
        yield UInt64(self, "mftmirr_cluster", "Cluster location of copy of MFT")
        yield UInt8(self, "cluster_per_mft", "MFT record size in clusters")
        yield NullBytes(self, "reserved[]", 3)
        yield UInt8(self, "cluster_per_index", "Index block size in clusters")
        yield NullBytes(self, "reserved[]", 3)
        yield textHandler(UInt64(self, "serial_number"), hexadecimal)
        yield textHandler(UInt32(self, "checksum", "Boot sector checksum"), hexadecimal)
        yield Bytes(self, "boot_code", 426)
        yield Bytes(self, "mbr_magic", 2, r"Master boot record magic number (\x55\xAA)")
Exemplo n.º 27
0
    def createFields(self):
        addr = self.absolute_address
        while True:
            # Check empty note
            byte = self.stream.readBits(addr, 8, self.endian)
            if not byte:
                yield NullBytes(self, "terminator", 1)
                return

            note = self.NOTE(self, "note[]")
            yield note
            addr += note.size
Exemplo n.º 28
0
 def createFields(self):
     yield NullBytes(self, "unused[]", 1)
     yield String(self,
                  "system_id",
                  ISO_MAX_SYSTEM_ID,
                  "System identifier",
                  strip=" ")
     yield String(self,
                  "volume_id",
                  ISO_MAX_VOLUME_ID,
                  "Volume identifier",
                  strip=" ")
     yield ISO9660UInt32_LSB_MSB(
         self, "volume_partition_location",
         "Logical Block Number of the first Logical"
         " Block allocated to the Volume Partition"
         " (iso9660 format)")
     yield ISO9660UInt32_LSB_MSB(
         self, "volume_partition_size",
         "Number of Logical Blocks in which the Volume"
         " Partition is recorded (iso9660 format)")
     yield NullBytes(self, "unused[]", 1960)
Exemplo n.º 29
0
    def createFields(self):
        yield UInt8(self, "version", "Version (0 or 1)")
        yield NullBits(self, "flags", 20)
        yield Bit(self, "is_in_poster")
        yield Bit(self, "is_in_preview", "Is this track used when previewing the presentation?")
        yield Bit(self, "is_in_movie", "Is this track used in the presentation?")
        yield Bit(self, "is_enabled", "Is this track enabled?")

        if self['version'].value == 0:
            # 32-bit version
            yield TimestampMac32(self, "creation_date", "Creation time of this track")
            yield TimestampMac32(self, "lastmod_date", "Last modification time of this track")
            yield UInt32(self, "track_id", "Unique nonzero identifier of this track within the presentation")
            yield NullBytes(self, "reserved[]", 4)
            yield UInt32(self, "duration", "Length of track, in movie time-units")
        elif self['version'].value == 1:
            # 64-bit version
            yield TimestampMac64(self, "creation_date", "Creation time of this track")
            yield TimestampMac64(self, "lastmod_date", "Last modification time of this track")
            yield UInt32(self, "track_id", "Unique nonzero identifier of this track within the presentation")
            yield NullBytes(self, "reserved[]", 4)
            yield UInt64(self, "duration", "Length of track, in movie time-units")
        yield NullBytes(self, "reserved[]", 8)
        yield Int16(self, "video_layer", "Middle layer is 0; lower numbers are closer to the viewer")
        yield Int16(self, "alternate_group", "Group ID that this track belongs to (0=no group)")
        yield QTFloat16(self, "volume", "Track relative audio volume (1.0 = full)")
        yield NullBytes(self, "reserved[]", 2)
        yield QTFloat32(self, "geom_a", "Width scale")
        yield QTFloat32(self, "geom_b", "Width rotate")
        yield QTFloat2_30(self, "geom_u", "Width angle")
        yield QTFloat32(self, "geom_c", "Height rotate")
        yield QTFloat32(self, "geom_d", "Height scale")
        yield QTFloat2_30(self, "geom_v", "Height angle")
        yield QTFloat32(self, "geom_x", "Position X")
        yield QTFloat32(self, "geom_y", "Position Y")
        yield QTFloat2_30(self, "geom_w", "Divider scale")
        yield QTFloat32(self, "frame_size_width")
        yield QTFloat32(self, "frame_size_height")
Exemplo n.º 30
0
def parseGraphicControl(parent):
    yield UInt8(parent, "size", "Block size (4)")

    yield Bit(parent, "has_transp", "Has transparency")
    yield Bit(parent, "user_input", "User input")
    yield Enum(Bits(parent, "disposal_method", 3), DISPOSAL_METHOD)
    yield NullBits(parent, "reserved[]", 3)

    if parent["size"].value != 4:
        raise ParserError("Invalid graphic control size")
    yield displayHandler(UInt16(parent, "delay", "Delay time in millisecond"),
                         humanDuration)
    yield UInt8(parent, "transp", "Transparent color index")
    yield NullBytes(parent, "terminator", 1, "Terminator (0)")