def createFields(self): # Type yield Enum(UInt8(self, "type"), self.type_desc) type = self["type"].value # Code field = UInt8(self, "code") if type == 3: field = Enum(field, self.reject_reason) yield field # Options yield textHandler(UInt16(self, "checksum"), hexadecimal) if type in (self.PING, self.PONG): # and self["code"].value == 0: yield UInt16(self, "id") yield UInt16(self, "seq_num") # follow: ping data elif type == self.REJECT: yield NullBytes(self, "empty", 2) yield UInt16(self, "hop_mtu", "Next-Hop MTU")
def createFields(self): yield String(self, "jfif", 5, "JFIF string", charset="ASCII") if self["jfif"].value != "JFIF\0": raise ParserError( "Stream doesn't look like JPEG chunk (wrong JFIF signature)") yield UInt8(self, "ver_maj", "Major version") yield UInt8(self, "ver_min", "Minor version") yield Enum(UInt8(self, "units", "Units"), self.UNIT_NAME) if self["units"].value == 0: yield UInt16(self, "aspect_x", "Aspect ratio (X)") yield UInt16(self, "aspect_y", "Aspect ratio (Y)") else: yield UInt16(self, "x_density", "X density") yield UInt16(self, "y_density", "Y density") yield UInt8(self, "thumb_w", "Thumbnail width") yield UInt8(self, "thumb_h", "Thumbnail height") thumb_size = self["thumb_w"].value * self["thumb_h"].value if thumb_size != 0: yield PaletteRGB(self, "thumb_palette", 256) yield RawBytes(self, "thumb_data", thumb_size, "Thumbnail data")
def createFields(self): if self.stream.readBytes(self.absolute_address, 5) != "Adobe": yield RawBytes(self, "raw", self.size//8, "Raw data") return yield String(self, "adobe", 5, "\"Adobe\" string", charset="ASCII") yield UInt16(self, "version", "DCT encoder version") yield Enum(Bit(self, "flag00"), {False: "Chop down or subsampling", True: "Blend"}) yield NullBits(self, "flags0_reserved", 15) yield NullBytes(self, "flags1", 2) yield Enum(UInt8(self, "color_transform", "Colorspace transformation code"), self.COLORSPACE_TRANSFORMATION)
def createFields(self): # Header yield UInt24(self, "size") yield Enum(UInt8(self, "type"), EFI_SECTION_TYPE) section_type = self["type"].value if section_type == EFI_SECTION_COMPRESSION: yield UInt32(self, "uncomp_len") yield Enum(UInt8(self, "comp_type"), self.COMPRESSION_TYPE) elif section_type == EFI_SECTION_FREEFORM_SUBTYPE_GUID: yield GUID(self, "sub_type_guid") elif section_type == EFI_SECTION_GUID_DEFINED: yield GUID(self, "section_definition_guid") yield UInt16(self, "data_offset") yield UInt16(self, "attributes") elif section_type == EFI_SECTION_USER_INTERFACE: yield CString(self, "file_name", charset="UTF-16-LE") elif section_type == EFI_SECTION_VERSION: yield UInt16(self, "build_number") yield CString(self, "version", charset="UTF-16-LE") # Content content_size = (self.size - self.current_size) // 8 if content_size == 0: return if section_type == EFI_SECTION_COMPRESSION: compression_type = self["comp_type"].value if compression_type == 1: while not self.eof: yield RawBytes(self, "compressed_content", content_size) else: while not self.eof: yield FileSection(self, "section[]") elif section_type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE: yield FirmwareVolume(self, "firmware_volume") else: yield RawBytes( self, "content", content_size, EFI_SECTION_TYPE.get(self["type"].value, "Unknown Section Type"))
def createFields(self): yield Enum(UInt8(self, "tag"), self.root.CONSTANT_TYPES) if self["tag"].value not in self.root.CONSTANT_TYPES: raise ParserError("Java: unknown constant type (%s)" % self["tag"].value) self.constant_type = self.root.CONSTANT_TYPES[self["tag"].value] if self.constant_type == "Utf8": yield PascalString16(self, "bytes", charset="UTF-8") elif self.constant_type == "Integer": yield Int32(self, "bytes") elif self.constant_type == "Float": yield Float32(self, "bytes") elif self.constant_type == "Long": yield Int64(self, "bytes") elif self.constant_type == "Double": yield Float64(self, "bytes") elif self.constant_type == "Class": yield CPIndex(self, "name_index", "Class or interface name", target_types="Utf8") elif self.constant_type == "String": yield CPIndex(self, "string_index", target_types="Utf8") elif self.constant_type == "Fieldref": yield CPIndex(self, "class_index", "Field class or interface name", target_types="Class") yield CPIndex(self, "name_and_type_index", target_types="NameAndType") elif self.constant_type == "Methodref": yield CPIndex(self, "class_index", "Method class name", target_types="Class") yield CPIndex(self, "name_and_type_index", target_types="NameAndType") elif self.constant_type == "InterfaceMethodref": yield CPIndex(self, "class_index", "Method interface name", target_types="Class") yield CPIndex(self, "name_and_type_index", target_types="NameAndType") elif self.constant_type == "NameAndType": yield CPIndex(self, "name_index", target_types="Utf8") yield CPIndex(self, "descriptor_index", target_types="Utf8") else: raise ParserError("Not a valid constant pool element type: " + self["tag"].value)
def createFields(self): yield String(self, 'capture_pattern', 4, charset="ASCII") if self['capture_pattern'].value != self.MAGIC: self.warning( 'Invalid signature. An Ogg page must start with "%s".' % self.MAGIC) yield UInt8(self, 'stream_structure_version') yield Bit(self, 'continued_packet') yield Bit(self, 'first_page') yield Bit(self, 'last_page') yield NullBits(self, 'unused', 5) yield UInt64(self, 'abs_granule_pos') yield textHandler(UInt32(self, 'serial'), hexadecimal) yield UInt32(self, 'page') yield textHandler(UInt32(self, 'checksum'), hexadecimal) yield UInt8(self, 'lacing_size') if self.lacing_size: yield Lacing(self, "lacing", size=self.lacing_size * 8) yield Segments(self, "segments", size=self._size - self._current_size)
def createFields(self): yield UInt8(self, "version", "Version") yield NullBits(self, "flags", 24) yield String(self, "creator", 4) yield String(self, "subtype", 4) yield String(self, "manufacturer", 4) yield UInt32(self, "res_flags") yield UInt32(self, "res_flags_mask") if self.root.is_mpeg4: yield CString(self, "name", charset="UTF-8") else: yield PascalString8(self, "name")
def createFields(self): yield UInt8(self, "bootable", "Bootable flag (true if equals to 0x80)") if self["bootable"].value not in (0x00, 0x80): self.warning( "Stream doesn't look like master boot record (partition bootable error)!" ) yield UInt8(self, "start_head", "Starting head number of the partition") yield Bits(self, "start_sector", 6, "Starting sector number of the partition") yield CylinderNumber(self, "start_cylinder", "Starting cylinder number of the partition") yield Enum(UInt8(self, "system", "System indicator"), self.system_name) yield UInt8(self, "end_head", "Ending head number of the partition") yield Bits(self, "end_sector", 6, "Ending sector number of the partition") yield CylinderNumber(self, "end_cylinder", "Ending cylinder number of the partition") yield UInt32(self, "LBA", "LBA (number of sectors before this partition)") yield UInt32(self, "size", "Size (block count)")
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: for field in self.parser(self, size): yield field else: yield RawBytes(self, "content", size)
def createFields(self): # This tag has too many variant forms. if '/tags/' in self.path: yield UInt32(self, "count") for i in xrange(self['count'].value): yield METATAG(self, "tag[]") elif self.stream.readBits(self.absolute_address, 32, self.endian) == 0: yield UInt8(self, "version") yield Bits(self, "flags", 24) yield AtomList(self, "tags") else: yield AtomList(self, "tags")
def specialHeader(s, is_file): yield filesizeHandler( UInt32(s, "compressed_size", "Compressed size (bytes)")) yield filesizeHandler( UInt32(s, "uncompressed_size", "Uncompressed size (bytes)")) yield Enum(UInt8(s, "host_os", "Operating system used for archiving"), OS_NAME) yield textHandler(UInt32(s, "crc32", "File CRC32"), hexadecimal) yield TimeDateMSDOS32(s, "ftime", "Date and time (MS DOS format)") yield textHandler( UInt8(s, "version", "RAR version needed to extract file"), formatRARVersion) yield Enum(UInt8(s, "method", "Packing method"), COMPRESSION_NAME) yield filesizeHandler(UInt16(s, "filename_length", "File name size")) if s["host_os"].value in (OS_MSDOS, OS_WIN32): yield MSDOSFileAttr32(s, "file_attr", "File attributes") else: yield textHandler(UInt32(s, "file_attr", "File attributes"), hexadecimal) # Start additional field from unrar if s["flags/is_large"].value: yield filesizeHandler( UInt64(s, "large_size", "Extended 64bits filesize")) # End additional field size = s["filename_length"].value if size > 0: if s["flags/is_unicode"].value: charset = "UTF-8" else: charset = "ISO-8859-15" yield String(s, "filename", size, "Filename", charset=charset) # Start additional fields from unrar - file only if is_file: if s["flags/has_salt"].value: yield RawBytes(s, "salt", 8, "Encryption salt to increase security") if s["flags/has_ext_time"].value: yield ExtTime(s, "extra_time")
def createFields(self): yield UInt8(self, "version") yield NullBits(self, "flags", 24) yield UInt32(self, "count", description="Total entries in sample time table") for i in xrange(self['count'].value): yield UInt32(self, "sample_count[]", "Number of consecutive samples with this offset") yield UInt32( self, "sample_offset[]", "Difference between decode time and composition time of this sample, in time-units" )
def createFields(self): if self.isEMF(): yield EMF_Header(self, "emf_header") else: if self.isAPM(): yield PlaceableHeader(self, "amf_header") yield Enum(UInt16(self, "file_type"), self.FILE_TYPE) yield UInt16(self, "header_size", "Size of header in 16-bit words (always 9)") yield UInt8(self, "win_ver_min", "Minor version of Microsoft Windows") yield UInt8(self, "win_ver_maj", "Major version of Microsoft Windows") yield UInt32(self, "file_size", "Total size of the metafile in 16-bit words") yield UInt16(self, "nb_obj", "Number of objects in the file") yield UInt32(self, "max_record_size", "The size of largest record in 16-bit words") yield UInt16(self, "nb_params", "Not Used (always 0)") while not (self.eof): yield Function(self, "func[]")
def createFields(self): yield Bits(self, "sync[]", 2) # =2 if self["sync[0]"].value != 2: raise ParserError("Unknown video elementary data") yield Bits(self, "is_scrambled", 2) yield Bits(self, "priority", 1) yield Bit(self, "alignment") yield Bit(self, "is_copyrighted") yield Bit(self, "is_original") yield Bit(self, "has_pts", "Presentation Time Stamp") yield Bit(self, "has_dts", "Decode Time Stamp") yield Bit(self, "has_escr", "Elementary Stream Clock Reference") yield Bit(self, "has_es_rate", "Elementary Stream rate") yield Bit(self, "dsm_trick_mode") yield Bit(self, "has_copy_info") yield Bit(self, "has_prev_crc", "If True, previous PES packet CRC follows") yield Bit(self, "has_extension") yield UInt8(self, "size") # Time stamps if self["has_pts"].value: yield Bits(self, "sync[]", 4) # =2, or 3 if has_dts=True yield Timestamp(self, "pts") if self["has_dts"].value: if not (self["has_pts"].value): raise ParserError("Invalid PTS/DTS values") yield Bits(self, "sync[]", 4) # =1 yield Timestamp(self, "dts") if self["has_escr"].value: yield Bits(self, "sync[]", 2) # =0 yield SCR(self, "escr") if self["has_es_rate"].value: yield Bit(self, "sync[]") # =True yield Bits(self, "es_rate", 14) # in units of 50 bytes/second yield Bit(self, "sync[]") # =True if self["has_copy_info"].value: yield Bit(self, "sync[]") # =True yield Bits(self, "copy_info", 7) if self["has_prev_crc"].value: yield textHandler(UInt16(self, "prev_crc"), hexadecimal) # --- Extension --- if self["has_extension"].value: yield VideoExtension1(self, "extension") if self["extension/has_extension2"].value: yield VideoExtension2(self, "extension2")
def createFields(self): yield Enum(textHandler(UInt32(self, "type"), hexadecimal), self.ATTR_NAME) yield UInt32(self, "size") yield UInt8(self, "non_resident", "Non-resident flag") yield UInt8(self, "name_length", "Name length in bytes") yield UInt16(self, "name_offset", "Name offset") yield UInt16(self, "flags") yield textHandler(UInt16(self, "attribute_id"), hexadecimal) yield UInt32(self, "length_attr", "Length of the Attribute") yield UInt16(self, "offset_attr", "Offset of the Attribute") yield UInt8(self, "indexed_flag") yield NullBytes(self, "padding", 1) if self._parser: for field in self._parser(self): yield field else: size = self["length_attr"].value if size: yield RawBytes(self, "data", size) size = (self.size - self.current_size) // 8 if size: yield PaddingBytes(self, "end_padding", size)
def createFields(self): yield String(self, "signature", 3, "FLV format signature", charset="ASCII") yield UInt8(self, "version") yield NullBits(self, "reserved[]", 5) yield Bit(self, "type_flags_audio") yield NullBits(self, "reserved[]", 1) yield Bit(self, "type_flags_video") yield UInt32(self, "data_offset")
def createFields(self): yield Integer(self, "time", "Delta time in ticks") next = self.stream.readBits(self.absolute_address + self.current_size, 8, self.root.endian) if next & 0x80 == 0: # "Running Status" command if self.prev_command is None: raise ParserError( "Running Status command not preceded by another command.") self.command = self.prev_command.command else: yield Enum(textHandler(UInt8(self, "command"), hexadecimal), self.COMMAND_DESC) self.command = self["command"].value if self.command == 0xFF: yield Enum(textHandler(UInt8(self, "meta_command"), hexadecimal), self.META_COMMAND_DESC) yield UInt8(self, "data_len") size = self["data_len"].value if size: command = self["meta_command"].value if command in self.META_COMMAND_PARSER: parser = self.META_COMMAND_PARSER[command] else: parser = None if parser: for field in parser(self, size): yield field else: yield RawBytes(self, "data", size) else: if self.command not in self.COMMAND_PARSER: raise ParserError("Unknown command: %s" % self["command"].display) parser = self.COMMAND_PARSER[self.command] for field in parser(self): yield field
def createFields(self): yield Enum(UInt8(self, "id"), ID_INFO) # Wait for synch for field in waitForID(self, ID_FOLDER, "folder_marker"): yield field yield SZUInt64(self, "num_folders") # Get generic info num = self["num_folders"].value self.info("%u folders" % num) yield UInt8(self, "is_external") # Read folder items for folder_index in xrange(num): yield FolderItem(self, "folder_item[]") # Get unpack sizes for each coder of each folder for field in waitForID(self, ID_CODERS_UNPACK_SIZE, "coders_unpsize_marker"): yield field for folder_index in xrange(num): folder_item = self["folder_item[%u]" % folder_index] for index in xrange(folder_item.out_streams): #yield UInt8(self, "unpack_size[]") yield SZUInt64(self, "unpack_size[]") # Extract digests while not self.eof: addr = self.absolute_address + self.current_size uid = self.stream.readBits(addr, 8, LITTLE_ENDIAN) if uid == ID_END: yield Enum(UInt8(self, "end_marker"), ID_INFO) break elif uid == ID_CRC: yield HashDigest(self, "hash_digest", num) else: yield SkippedData(self, "skip_data")
def createFields(self): yield Bytes(self, "signature", 4, r"RPM file signature (\xED\xAB\xEE\xDB)") yield UInt8(self, "major_ver", "Major version") yield UInt8(self, "minor_ver", "Minor version") yield Enum(UInt16(self, "type", "RPM type"), RpmFile.TYPE_NAME) yield UInt16(self, "architecture", "Architecture") yield String(self, "name", 66, "Archive name", strip="\0", charset="ASCII") yield UInt16(self, "os", "OS") yield UInt16(self, "signature_type", "Type of signature") yield NullBytes(self, "reserved", 16, "Reserved") yield PropertySet(self, "checksum", "Checksum (signature)") yield PropertySet(self, "header", "Header") if self._size is None: # TODO: is it possible to handle piped input? raise NotImplementedError size = (self._size - self.current_size) // 8 if size: if 3 <= size and self.stream.readBytes(self.current_size, 3) == "BZh": yield SubFile(self, "content", size, "bzip2 content", parser=Bzip2Parser) else: yield SubFile(self, "content", size, "gzip content", parser=GzipParser)
def createFields(self): yield Enum(UInt8(self, "id"), ID_INFO) # Very important, helps determine where the data is yield SZUInt64(self, "pack_pos", "Position of the packs") num = SZUInt64(self, "num_pack_streams") yield num num = num.value for field in waitForID(self, ID_SIZE, "size_marker"): yield field for size in xrange(num): yield SZUInt64(self, "pack_size[]") while not self.eof: addr = self.absolute_address + self.current_size uid = self.stream.readBits(addr, 8, LITTLE_ENDIAN) if uid == ID_END: yield Enum(UInt8(self, "end_marker"), ID_INFO) break elif uid == ID_CRC: yield HashDigest(self, "hash_digest", size) else: yield SkippedData(self, "skipped_data")
def createFields(self): yield PropID(self, "id") yield SZUInt64(self, "size") definearr = SevenZipBitVector(self, "defined", self['../num_files'].value, has_all_byte=True) yield definearr yield UInt8(self, "is_external") if self['is_external'].value: yield SZUInt64(self, "folder_data_offset", "Offset to folder data within data stream") else: for index in definearr.value: yield MSDOSFileAttr32(self, "attributes[%d]" % index)
def createFields(self): yield String(self, "header_id", 4, "Playlist Header Markup (\"mhyp\")", charset="ISO-8859-1") yield UInt32(self, "header_length", "Header Length") yield UInt32(self, "entry_length", "Entry Length") yield UInt32(self, "data_object_child_count", "Number of Child Data Objects") yield UInt32(self, "playlist_count", "Number of Playlist Items") yield Enum(UInt8(self, "type", "Normal or master playlist?"), self.is_master_pl_name) yield UInt8(self, "XXX1", "XXX1") yield UInt8(self, "XXX2", "XXX2") yield UInt8(self, "XXX3", "XXX3") yield TimestampMac32(self, "creation_date", "Date when the playlist was created") yield UInt64(self, "playlistid", "Persistent Playlist ID") yield UInt32(self, "unk3", "unk3") yield UInt16(self, "string_mhod_count", "Number of string MHODs for this playlist") yield Enum(UInt16(self, "is_podcast", "Playlist or Podcast List?"), self.is_podcast_name) yield Enum(UInt32(self, "sort_order", "Playlist Sort Order"), self.list_sort_order_name) padding = self.seekByte(self["header_length"].value, "entry padding") if padding: yield padding for i in xrange(self["data_object_child_count"].value): yield DataObject(self, "mhod[]") for i in xrange(self["playlist_count"].value): yield PlaylistItem(self, "playlist_item[]")
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, "bpp", 3, "Bits / pixel minus one") yield NullBits(self, "nul", 2) yield Bit(self, "sorted", "Sorted??") 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["bpp"].value) yield PaletteRGB(self, "local_map", nb_color, "Local color map") yield UInt8(self, "code_size", "LZW Minimum Code Size") while True: blen = UInt8(self, "block_len[]", "Block Length") yield blen if blen.value != 0: yield RawBytes(self, "data[]", blen.value, "Image Data") else: break
def createFields(self): yield Enum(UInt8(self, "kind"), self.MULTINAME_KIND) kind = self["kind"].value if kind in (7, 13): # Qname yield FlashU30(self, "namespace_index") yield ABCStringIndex(self, "name_index") elif kind in (9, 14): # Multiname yield ABCStringIndex(self, "name_index") yield FlashU30(self, "namespace_set_index") elif kind in (15, 16): # RTQname yield ABCStringIndex(self, "name_index") elif kind == 27: # MultinameL yield FlashU30(self, "namespace_set_index") elif kind in (17, 18): # RTQnameL pass
def createFields(self): yield String(self, "signature", 3, "IDv1 signature (\"TAG\")", charset="ASCII") if self["signature"].value != "TAG": raise MatchError("Stream doesn't look like ID3v1 (wrong signature)!") # TODO: Charset of below strings? yield String(self, "song", 30, "Song title", strip=" \0", charset="ISO-8859-1") yield String(self, "author", 30, "Author", strip=" \0", charset="ISO-8859-1") yield String(self, "album", 30, "Album title", strip=" \0", charset="ISO-8859-1") yield String(self, "year", 4, "Year", strip=" \0", charset="ISO-8859-1") # TODO: Write better algorithm to guess ID3v1 version version = self.getVersion() if version in ("v1.1", "v1.1b"): if version == "v1.1b": # ID3 v1.1b yield String(self, "comment", 29, "Comment", strip=" \0", charset="ISO-8859-1") yield UInt8(self, "track_nb", "Track number") else: # ID3 v1.1 yield String(self, "comment", 30, "Comment", strip=" \0", charset="ISO-8859-1") yield Enum(UInt8(self, "genre", "Genre"), self.GENRE_NAME) else: # ID3 v1.0 yield String(self, "comment", 31, "Comment", strip=" \0", charset="ISO-8859-1")
def createFields(self): yield textHandler(UInt8(self, "sync", 8), hexadecimal) if self["sync"].value != 0x47: raise ParserError("MPEG-2 TS: Invalid synchronization byte") yield Bit(self, "has_error") yield Bit(self, "payload_unit_start") yield Bit(self, "priority") yield Enum( textHandler(Bits(self, "pid", 13, "Program identifier"), hexadecimal), self.PID) yield Bits(self, "scrambling_control", 2) yield Bit(self, "has_adaptation") yield Bit(self, "has_payload") yield Bits(self, "counter", 4) yield RawBytes(self, "payload", 184) if self["has_error"].value: yield RawBytes(self, "error_correction", 16)
def createFields(self): yield UInt8(self, "version", "Version (0 or 1)") yield NullBits(self, "flags", 24) if self['version'].value == 0: # 32-bit version yield TimestampMac32(self, "creation_date", "Creation time of this presentation") yield TimestampMac32( self, "lastmod_date", "Last modification time of this presentation") yield UInt32(self, "time_scale", "Number of time-units per second") yield UInt32(self, "duration", "Length of presentation, in time-units") elif self['version'].value == 1: # 64-bit version yield TimestampMac64(self, "creation_date", "Creation time of this presentation") yield TimestampMac64( self, "lastmod_date", "Last modification time of this presentation") yield UInt32(self, "time_scale", "Number of time-units per second") yield UInt64(self, "duration", "Length of presentation, in time-units") yield QTFloat32(self, "play_speed", "Preferred playback speed (1.0 = normal)") yield QTFloat16(self, "volume", "Preferred playback volume (1.0 = full)") yield NullBytes(self, "reserved[]", 10) 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 UInt32(self, "preview_start") yield UInt32(self, "preview_length") yield UInt32(self, "still_poster") yield UInt32(self, "sel_start") yield UInt32(self, "sel_length") yield UInt32(self, "current_time") yield UInt32(self, "next_track_ID", "Value to use as the track ID for the next track added")
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)
def createFields(self): yield UInt8(self, "version", "Version (0 or 1)") yield NullBits(self, "flags", 24) yield UInt32(self, "count") version = self['version'].value if version == 0: UInt, Int = UInt32, Int32 elif version == 1: UInt, Int = UInt64, Int64 else: raise ParserError("elst version %d not supported" % version) for i in xrange(self['count'].value): yield UInt(self, "duration[]", "Duration of this edit segment") yield Int( self, "time[]", "Starting time of this edit segment within the media (-1 = empty edit)" ) yield QTFloat32( self, "play_speed[]", "Playback rate (0 = dwell edit, 1 = normal playback)")
def createFields(self): yield UInt8(self, "version", "Version (0 or 1)") yield NullBits(self, "flags", 24) if self['version'].value == 0: # 32-bit version yield TimestampMac32(self, "creation_date", "Creation time of this media") yield TimestampMac32(self, "lastmod_date", "Last modification time of this media") yield UInt32(self, "time_scale", "Number of time-units per second") yield UInt32(self, "duration", "Length of media, in time-units") elif self['version'].value == 1: # 64-bit version yield TimestampMac64(self, "creation_date", "Creation time of this media") yield TimestampMac64(self, "lastmod_date", "Last modification time of this media") yield UInt32(self, "time_scale", "Number of time-units per second") yield UInt64(self, "duration", "Length of media, in time-units") yield LanguageCode(self, "language") yield Int16(self, "quality")
def createValue(self): val = UInt8.createValue(self) return (val != 0)