Esempio n. 1
0
 def createFields(self):
     yield UInt32(self, "size")
     self._size = (self['size'].value + 4) * 8
     yield RawBytes(self, "unknown[]", 10)
     yield AVCHDTimestamp(self, "last_modified")
     yield RawBytes(self, "unknown[]", 2)
     yield PascalString8(self, "date")
Esempio n. 2
0
 def createFields(self):
     yield UInt8(self, "version")
     yield NullBits(self, "flags", 24)
     yield UInt32(self, "unknown")
     yield UInt8(self, "count", description="Number of chapters")
     for i in xrange(self['count'].value):
         yield UInt64(self, "chapter_start[]")
         yield PascalString8(self, "chapter_name[]", charset='UTF-8')
Esempio n. 3
0
def parseMediaPropertiesHeader(self):
    yield UInt16(self, "stream_number", "Stream number")
    yield UInt32(self, "max_bit_rate", "Maximum bit rate")
    yield UInt32(self, "avg_bit_rate", "Average bit rate")
    yield UInt32(self, "max_pkt_size", "Size of largest data packet")
    yield UInt32(self, "avg_pkt_size", "Size of average data packet")
    yield UInt32(self, "stream_start", "Stream start offset in milliseconds")
    yield UInt32(self, "preroll", "Preroll in milliseconds")
    yield UInt32(self, "duration", "Stream duration in milliseconds")
    yield PascalString8(self, "desc", "Stream description", charset="ISO-8859-1")
    yield PascalString8(self, "mime_type", "MIME type string", charset="ASCII")
    yield UInt32(self, "specific_size", "Size of type-specific data")
    size = self['specific_size'].value
    if size:
        if self["mime_type"].value == "logical-fileinfo":
            yield LogicalFileInfo(self, "file_info", size=size * 8)
        else:
            yield RawBytes(self, "specific", size, "Type-specific data")
Esempio n. 4
0
 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")
Esempio n. 5
0
 def createFields(self):
     yield Bytes(self, "signature", 4, r"RealAudio identifier ('.ra\xFD')")
     yield UInt16(self, "version", "Version")
     if self["version"].value == 3:
         yield UInt16(self, "header_size", "Header size")
         yield RawBytes(self, "Unknown1", 10)
         yield UInt32(self, "data_size", "Data size")
         yield Metadata(self, "metadata")
         yield UInt8(self, "Unknown2")
         yield PascalString8(self, "FourCC")
         audio_size = self["data_size"].value
     else:  # version = 4
         yield UInt16(self, "reserved1", "Reserved, should be 0")
         yield String(self, "ra4sig", 4, "'.ra4' signature")
         yield UInt32(self, "filesize", "File size (minus 40 bytes)")
         yield UInt16(self, "version2",
                      "Version 2 (always equal to version)")
         yield UInt32(self, "headersize", "Header size (minus 16)")
         yield UInt16(self, "codec_flavor", "Codec flavor")
         yield UInt32(self, "coded_frame_size", "Coded frame size")
         yield RawBytes(self, "unknown1", 12)
         yield UInt16(self, "subpacketh", "Subpacket h (?)")
         yield UInt16(self, "frame_size", "Frame size")
         yield UInt16(self, "sub_packet_size", "Subpacket size")
         yield UInt16(self, "unknown2", "Unknown")
         yield displayHandler(UInt16(self, "sample_rate", "Sample rate"),
                              humanFrequency)
         yield UInt16(self, "unknown3", "Unknown")
         yield UInt16(self, "sample_size", "Sample size")
         yield UInt16(self, "channels", "Channels")
         yield PascalString8(self, "Interleaving ID String")
         yield PascalString8(self, "FourCC")
         yield RawBytes(self, "unknown4", 3)
         yield Metadata(self, "metadata")
         audio_size = (self["filesize"].value +
                       40) - (self["headersize"].value + 16)
     if 0 < audio_size:
         yield RawBytes(self, "audio_data", audio_size)
Esempio n. 6
0
def parseTextExtension(parent):
    yield UInt8(parent, "block_size", "Block Size")
    yield UInt16(parent, "left", "Text Grid Left")
    yield UInt16(parent, "top", "Text Grid Top")
    yield UInt16(parent, "width", "Text Grid Width")
    yield UInt16(parent, "height", "Text Grid Height")
    yield UInt8(parent, "cell_width", "Character Cell Width")
    yield UInt8(parent, "cell_height", "Character Cell Height")
    yield UInt8(parent, "fg_color", "Foreground Color Index")
    yield UInt8(parent, "bg_color", "Background Color Index")
    while True:
        field = PascalString8(parent, "comment[]", strip=" \0\r\n\t")
        yield field
        if field.length == 0:
            break
Esempio n. 7
0
def parseApplicationExtension(parent):
    yield PascalString8(parent, "app_name", "Application name")
    while True:
        size = UInt8(parent, "size[]")
        if size.value == 0:
            break
        yield size
        if parent["app_name"].value == "NETSCAPE2.0" and size.value == 3:
            yield Enum(UInt8(parent, "netscape_code"), NETSCAPE_CODE)
            if parent["netscape_code"].value == 1:
                yield UInt16(parent, "loop_count")
            else:
                yield RawBytes(parent, "raw[]", 2)
        else:
            yield RawBytes(parent, "raw[]", size.value)
    yield NullBytes(parent, "terminator", 1, "Terminator (0)")
Esempio n. 8
0
def markerHeader(self):
    yield String(self, "signature", 7, "Signature")
    yield UInt8(self, "ver_extract", "Version needed to extract archive")
    yield UInt8(self, "ver_created", "Version used to create archive")
    yield Enum(UInt8(self, "host_os", "OS where the files were compressed"),
               HOST_OS)
    yield UInt8(self, "vol_num", "Volume number")
    yield TimeDateMSDOS32(self, "time", "Date and time (MS DOS format)")
    yield Bits(self, "reserved", 64, "Reserved size for future extensions")
    flags = self["flags"]
    if flags["has_av_string"].value:
        yield PascalString8(self, "av_string", "AV String")
    if flags["has_comment"].value:
        size = filesizeHandler(UInt16(self, "comment_size", "Comment size"))
        yield size
        if size.value > 0:
            yield RawBytes(self, "compressed_comment", size.value, \
                           "Compressed comment")
Esempio n. 9
0
def ESDescriptor(self):
    yield UInt16(self, "ES_ID")
    yield Bit(self, "streamDependenceFlag")
    yield Bit(self, "URL_Flag")
    yield Bit(self, "OCRstreamFlag")
    yield Bits(self, "streamPriority", 5)
    if self["streamDependenceFlag"].value:
        yield UInt16(self, "dependsOn_ES_ID")
    if self["URL_Flag"].value:
        yield PascalString8(self, "URL")
    if self["OCRstreamFlag"].value:
        yield UInt16(self, "OCR_ES_Id")

    yield Descriptor(self, "decConfigDescr", restrict=DecoderConfigDescriptor)

    # TODO
    while not self.eof:
        yield Descriptor(self, "descr[]")
Esempio n. 10
0
 def createFields(self):
     yield String(self, "signature", 4, "8BIM signature", charset="ASCII")
     if self["signature"].value != "8BIM":
         raise ParserError(
             "Stream doesn't look like 8BIM item (wrong signature)!")
     yield textHandler(UInt16(self, "tag"), hexadecimal)
     if self.stream.readBytes(self.absolute_address + self.current_size, 4) != b"\0\0\0\0":
         yield PascalString8(self, "name")
         size = 2 + (self["name"].size // 8) % 2
         yield NullBytes(self, "name_padding", size)
     else:
         yield String(self, "name", 4, strip="\0")
     yield UInt16(self, "size")
     size = alignValue(self["size"].value, 2)
     if not size:
         return
     if self.handler:
         if issubclass(self.handler, FieldSet):
             yield self.handler(self, "content", size=size * 8)
         else:
             yield self.handler(self, "content")
     else:
         yield RawBytes(self, "content", size)
Esempio n. 11
0
 def createFields(self):
     if self.stream.readBytes(self.absolute_address, 2) == b"\xff\xff":
         yield Int16(self, "utf16_marker", "If this field is present, the Sttbf contains UTF-16 data.")
         self.is_utf16 = True
     else:
         self.is_utf16 = False
     yield UInt16(self, "count", "Number of strings in this Sttbf")
     extra_data_field = UInt16(
         self, "extra_data_len", "Size of optional extra data after each string")
     yield extra_data_field
     extra_data_len = extra_data_field.value
     for i in range(self["count"].value):
         if self.name == "SttbfAssoc":
             desc = self.SttbfAssocDESC.get(i, None)
         else:
             desc = None
         if self.name == "Sttbfffn":
             yield TableParsers.Ffn(self, "string[]", desc)
         elif self.is_utf16:
             yield WidePascalString16(self, "string[]", desc)
         else:
             yield PascalString8(self, "string[]", desc)
         if extra_data_len:
             yield RawBytes(self, "extra[]", extra_data_len)
Esempio n. 12
0
def parseComplex(parent):
    yield PascalString8(parent, "real")
    yield PascalString8(parent, "complex")
Esempio n. 13
0
def parseFloat(parent):
    yield PascalString8(parent, "value")
Esempio n. 14
0
 def createFields(self):
     yield UInt32(self, "size")
     yield UInt16(self, "obj_version")
     yield PascalString8(self, "name", charset="ASCII")
     yield UInt32(self, "type")
     yield PascalString16(self, "value", charset="ISO-8859-1", strip=" \0")
Esempio n. 15
0
 def createFields(self):
     yield PascalString8(self, "title", charset="ISO-8859-1")
     yield PascalString8(self, "author", charset="ISO-8859-1")
     yield PascalString8(self, "copyright", charset="ISO-8859-1")
     yield PascalString8(self, "comment", charset="ISO-8859-1")
Esempio n. 16
0
def parseComments(parent):
    while True:
        field = PascalString8(parent, "comment[]", strip=" \0\r\n\t")
        yield field
        if field.length == 0:
            break
Esempio n. 17
0
 def createFields(self):
     yield PascalString8(self, "name", charset="MacRoman")
     yield UInt32(self, "block")
Esempio n. 18
0
 def createFields(self):
     yield RawBytes(self, "unknown[]", 10)
     yield AVCHDTimestamp(self, "date")
     yield RawBytes(self, "unknown[]", 1)
     yield PascalString8(self, "date")