Beispiel #1
0
    def createFields(self):
        yield Bits(self, "version", 4, "Version")
        yield Bits(self, "hdr_size", 4, "Header size divided by 5")

        # Type of service
        yield Enum(Bits(self, "precedence", 3, "Precedence"),
                   self.precedence_name)
        yield Bit(self, "low_delay", "If set, low delay, else normal delay")
        yield Bit(self, "high_throu",
                  "If set, high throughput, else normal throughput")
        yield Bit(self, "high_rel", "If set, high relibility, else normal")
        yield NullBits(self, "reserved[]", 2, "(reserved for future use)")

        yield UInt16(self, "length")
        yield UInt16(self, "id")

        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "df", "Don't fragment")
        yield Bit(self, "more_frag",
                  "There are more fragments? if not set, it's the last one")
        yield Bits(self, "frag_ofst_lo", 5)
        yield UInt8(self, "frag_ofst_hi")
        yield UInt8(self, "ttl", "Type to live")
        yield Enum(UInt8(self, "protocol"), self.PROTOCOL_NAME)
        yield textHandler(UInt16(self, "checksum"), hexadecimal)
        yield IPv4_Address(self, "src")
        yield IPv4_Address(self, "dst")

        size = (self.size - self.current_size) // 8
        if size:
            yield RawBytes(self, "options", size)
Beispiel #2
0
 def createFields(self):
     yield ABCMultinameIndex(self, "name_index")
     yield Enum(Bits(self, "kind", 4), self.TRAIT_KIND)
     yield Enum(Bit(self, "is_final"), {True: 'final', False: 'virtual'})
     yield Enum(Bit(self, "is_override"), {True: 'override', False: 'new'})
     yield Bit(self, "has_metadata")
     yield Bits(self, "unused", 1)
     kind = self["kind"].value
     if kind in (0, 6):  # slot, const
         yield FlashU30(self, "slot_id")
         yield ABCMultinameIndex(self, "type_index")
         ### TODO reference appropriate constant pool using value_kind
         yield FlashU30(self, "value_index")
         if self['value_index'].value != 0:
             yield UInt8(self, "value_kind")
     elif kind in (1, 2, 3):  # method, getter, setter
         yield FlashU30(self, "disp_id")
         yield ABCMethodIndex(self, "method_info")
     elif kind == 4:  # class
         yield FlashU30(self, "disp_id")
         yield FlashU30(self, "class_info")
     elif kind == 5:  # function
         yield FlashU30(self, "disp_id")
         yield ABCMethodIndex(self, "method_info")
     if self['has_metadata'].value:
         yield ABCObjectArray(self, "metadata", FlashU30)
Beispiel #3
0
 def createFields(self):
     for name in ['arctime', 'atime', 'ctime', 'mtime']:
         yield Bits(self, "%s_count" % name, 2, "Number of %s bytes" % name)
         yield Bit(self, "%s_onesec" % name,
                   "Add one second to the timestamp?")
         yield Bit(self, "%s_present" % name,
                   "Is %s extra time present?" % name)
Beispiel #4
0
    def createFields(self):
        if self["/have_debug"].value:
            yield String(self, "signature", 32)
            if not self['signature'].value.startswith("***POIStart"):
                raise ValueError

        yield IntVbe(self, "lat_diff")
        yield IntVbe(self, "lon_diff")
        yield Bits(self, "layer", 4)
        yield Bits(self, "num_tags", 4)

        for i in range(self["num_tags"].value):
            yield UIntVbe(self, "tag_id[]")

        yield Bit(self, "have_name")
        yield Bit(self, "have_house_number")
        yield Bit(self, "have_ele")
        yield PaddingBits(self, "pad[]", 5)

        if self["have_name"].value:
            yield VbeString(self, "name")
        if self["have_house_number"].value:
            yield VbeString(self, "house_number")
        if self["have_ele"].value:
            yield IntVbe(self, "ele")
 def createFields(self):
     yield Bits(self, "start_length", 5)
     length = self["start_length"].value
     lengths = []
     for i in xrange(self.symbols):
         while True:
             bit = Bit(self, "change_length[%i][]" % i,
                       "Should the length be changed for symbol %i?" % i)
             yield bit
             if not bit.value:
                 break
             else:
                 bit = Enum(
                     Bit(self, "length_decrement[%i][]" % i,
                         "Decrement the value?"), {
                             True: "Decrement",
                             False: "Increment"
                         })
                 yield bit
                 if bit.value:
                     length -= 1
                 else:
                     length += 1
         lengths.append(length)
     self.final_length = length
     self.tree = build_tree(lengths)
Beispiel #6
0
 def createFields(self):
     yield Bits(self, "c", 3)
     yield Bit(self, "sync[]")  # =True
     yield Bits(self, "b", 15)
     yield Bit(self, "sync[]")  # =True
     yield Bits(self, "a", 15)
     yield Bit(self, "sync[]")  # =True
Beispiel #7
0
 def createFields(self):
     if self.stream.readBits(self.absolute_address, 2, self.endian) == 1:
         # MPEG version 2
         yield Bits(self, "sync[]", 2)
         yield SCR(self, "scr")
         yield Bit(self, "sync[]")
         yield Bits(self, "scr_ext", 9)
         yield Bit(self, "sync[]")
         yield Bits(self, "mux_rate", 22)
         yield Bits(self, "sync[]", 2)
         yield PaddingBits(self, "reserved", 5, pattern=1)
         yield Bits(self, "stuffing_length", 3)
         count = self["stuffing_length"].value
         if count:
             yield PaddingBytes(self, "stuffing", count, pattern="\xff")
     else:
         # MPEG version 1
         yield Bits(self, "sync[]", 4)
         yield Bits(self, "scr_a", 3)
         yield Bit(self, "sync[]")
         yield Bits(self, "scr_b", 15)
         yield Bit(self, "sync[]")
         yield Bits(self, "scr_c", 15)
         yield Bits(self, "sync[]", 2)
         yield Bits(self, "mux_rate", 22)
         yield Bit(self, "sync[]")
Beispiel #8
0
 def createFields(self):
     yield String(self, "signature", 17, "XM signature", charset="ASCII")
     yield String(self, "title", 20, "XM title", charset="ASCII", strip=' ')
     yield UInt8(self, "marker", "Marker (0x1A)")
     yield String(self,
                  "tracker_name",
                  20,
                  "XM tracker name",
                  charset="ASCII",
                  strip=' ')
     yield UInt8(self, "format_minor")
     yield UInt8(self, "format_major")
     yield filesizeHandler(UInt32(self, "header_size", "Header size (276)"))
     yield UInt16(self, "song_length", "Length in patten order table")
     yield UInt16(self, "restart", "Restart position")
     yield UInt16(self, "channels",
                  "Number of channels (2,4,6,8,10,...,32)")
     yield UInt16(self, "patterns", "Number of patterns (max 256)")
     yield UInt16(self, "instruments", "Number of instruments (max 128)")
     yield Bit(self, "amiga_ftable", "Amiga frequency table")
     yield Bit(self, "linear_ftable", "Linear frequency table")
     yield Bits(self, "unused", 14)
     yield UInt16(self, "tempo", "Default tempo")
     yield UInt16(self, "bpm", "Default BPM")
     yield GenericVector(self, "pattern_order", 256, UInt8, "order")
Beispiel #9
0
 def createFields(self):
     yield Bits(self, "unused", 2)
     yield Bit(self, "is_tonable")
     yield Bit(self, "16bits")
     yield Bit(self, "loop_bidir")
     yield Bit(self, "loop")
     yield Enum(Bits(self, "origin", 2), self.TYPES)
Beispiel #10
0
 def createFields(self):
     yield UInt16(self, "TriggerSize")
     yield UInt16(self, "Reserved[]")
     yield UInt16(self, "BeginYear")
     yield UInt16(self, "BeginMonth")
     yield UInt16(self, "BeginDay")
     yield UInt16(self, "EndYear")
     yield UInt16(self, "EndMonth")
     yield UInt16(self, "EndDay")
     yield UInt16(self, "StartHour")
     yield UInt16(self, "StartMinute")
     yield UInt32(self, "MinutesDuration")
     yield UInt32(self, "MinutesInterval",
                  "Time period between repeated trigger firings.")
     yield Bit(self, "HasEndDate", "Can task stop at some point in time?")
     yield Bit(self, "KillAtDurationEnd",
               "Can task be stopped at the end of the repetition period?")
     yield Bit(self, "TriggerDisabled", "Is this trigger disabled?")
     yield RawBits(self, "Unused[]", 29)
     yield Enum(UInt32(self, "TriggerType"), self.TRIGGER_TYPE)
     yield UInt16(self, "TriggerSpecific0")
     yield UInt16(self, "TriggerSpecific1")
     yield UInt16(self, "TriggerSpecific2")
     yield UInt16(self, "Padding")
     yield UInt16(self, "Reserved[]")
     yield UInt16(self, "Reserved[]")
Beispiel #11
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, "block_size")
            if size.value == 0:
                break
            block = CustomFragment(self, "image_block[]", None, GifImageBlock,
                                   "GIF Image Block", group)
            group = block.group
            yield block
        yield NullBytes(self, "terminator", 1, "Terminator (0)")
    def createFields(self):
        # Header
        yield PaddingBits(self,
                          "sync",
                          11,
                          "Synchronize bits (set to 1)",
                          pattern=1)
        yield Enum(Bits(self, "version", 2, "MPEG audio version"),
                   self.VERSION_NAME)
        yield Enum(Bits(self, "layer", 2, "MPEG audio layer"), self.LAYER_NAME)
        yield Bit(self, "crc16", "No CRC16 protection?")

        # Rates and padding
        yield Bits(self, "bit_rate", 4, "Bit rate")
        yield Bits(self, "sampling_rate", 2, "Sampling rate")
        yield Bit(self, "use_padding", "Stream field use padding?")
        yield Bit(self, "extension", "Extension")

        # Channel mode, mode extension, copyright, ...
        yield Enum(Bits(self, "channel_mode", 2, "Channel mode"),
                   self.CHANNEL_MODE_NAME)
        yield Bits(self, "mode_ext", 2, "Mode extension")
        yield Bit(self, "copyright", "Is copyrighted?")
        yield Bit(self, "original", "Is original?")
        yield Enum(Bits(self, "emphasis", 2, "Emphasis"), self.EMPHASIS_NAME)

        size = (self.size - self.current_size) / 8
        if size:
            yield RawBytes(self, "data", size)
Beispiel #13
0
    def createFields(self):
        # Signature + version
        yield String(self, "header", 3, "Header (ID3)", charset="ASCII")
        yield UInt8(self, "ver_major", "Version (major)")
        yield UInt8(self, "ver_minor", "Version (minor)")

        # Check format
        if self["header"].value != "ID3":
            raise MatchError("Signature error, should be \"ID3\".")
        if self["ver_major"].value not in self.VALID_MAJOR_VERSIONS \
        or self["ver_minor"].value != 0:
            raise MatchError(
                "Unknown ID3 metadata version (2.%u.%u)"
                % (self["ver_major"].value, self["ver_minor"].value))

        # Flags
        yield Bit(self, "unsync", "Unsynchronisation is used?")
        yield Bit(self, "ext", "Extended header is used?")
        yield Bit(self, "exp", "Experimental indicator")
        yield NullBits(self, "padding[]", 5)

        # Size
        yield ID3_Size(self, "size")

        # All tags
        while self.current_size < self._size:
            field = ID3_Chunk(self, "field[]")
            yield field
            if field["size"].value == 0:
                break

        # Search first byte of the MPEG file
        padding = self.seekBit(self._size)
        if padding:
            yield padding
Beispiel #14
0
    def createFields(self):
        yield Unsigned(self, 'track')
        yield Int16(self, 'timecode')

        if self.parent._name == 'Block':
            yield NullBits(self, 'reserved[]', 4)
            yield Bit(self, 'invisible')
            yield self.lacing()
            yield NullBits(self, 'reserved[]', 1)
        elif self.parent._name == 'SimpleBlock[]':
            yield Bit(self, 'keyframe')
            yield NullBits(self, 'reserved', 3)
            yield Bit(self, 'invisible')
            yield self.lacing()
            yield Bit(self, 'discardable')
        else:
            yield NullBits(self, 'reserved', 8)
            return

        size = (self._size - self.current_size) / 8
        lacing = self['lacing'].value
        if lacing:
            yield GenericInteger(self, 'n_frames', False, 8, \
                text_handler = lambda chunk: str(chunk.value+1))
            yield Lace(self, lacing - 1, size - 1)
        else:
            yield RawBytes(self, 'frame', size)
Beispiel #15
0
 def createFields(self):
     yield Bit(self, "negative")
     yield FloatExponent(self, "exponent", exponent_bits)
     if 64 <= mantissa_bits:
         yield Bit(self, "one")
         yield FloatMantissa(self, "mantissa", mantissa_bits - 1)
     else:
         yield FloatMantissa(self, "mantissa", mantissa_bits)
Beispiel #16
0
 def createFields(self):
     yield textHandler(Bits(self, "unused[]", 8, "Unused flag bits"),
                       hexadecimal)
     yield Bit(self, "has_added_size",
               "Additional field indicating additional size")
     yield Bit(
         self, "is_ignorable",
         "Old versions of RAR should ignore this block when copying data")
     yield Bits(self, "unused[]", 6)
Beispiel #17
0
 def createFields(self):
     yield Bits(self, "sync", 14, "Sync code: 11111111111110")
     yield Bit(self, "reserved[]")
     yield Bit(self, "blocking_strategy")
     yield Bits(self, "block_size", 4)
     yield Enum(Bits(self, "sample_rate", 4), self.SAMPLE_RATES)
     yield Bits(self, "channel_assign", 4)
     yield Bits(self, "sample_size", 3)
     yield Bit(self, "reserved[]")
Beispiel #18
0
 def createFields(self):
     if self.root.endian == BIG_ENDIAN:
         yield NullBits(self, "padding[]", 29)
         for fld, desc in self.FLAGS:
             yield Bit(self, fld, "Segment is " + desc)
     else:
         for fld, desc in reversed(self.FLAGS):
             yield Bit(self, fld, "Segment is " + desc)
         yield NullBits(self, "padding[]", 29)
Beispiel #19
0
 def createFields(self):
     yield UInt16(self, "width", "Width")
     yield UInt16(self, "height", "Height")
     yield Bits(self, "bpp", 3, "Bits per pixel minus one")
     yield Bit(self, "reserved", "(reserved)")
     yield Bits(self, "color_res", 3, "Color resolution minus one")
     yield Bit(self, "global_map", "Has global map?")
     yield UInt8(self, "background", "Background color")
     yield UInt8(self, "pixel_aspect_ratio", "Pixel Aspect Ratio")
Beispiel #20
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")
Beispiel #21
0
 def createFields(self):
     yield Bit(self, "drop_frame")
     yield Bits(self, "time_hh", 5)
     yield Bits(self, "time_mm", 6)
     yield PaddingBits(self, "time_pad[]", 1)
     yield Bits(self, "time_ss", 6)
     yield Bits(self, "time_ff", 6)
     yield Bit(self, "closed_group")
     yield Bit(self, "broken_group")
     yield PaddingBits(self, "pad[]", 5)
Beispiel #22
0
    def createFields(self):
        yield Bit(self, "has_private")
        yield Bit(self, "has_pack_lgth")
        yield Bit(self, "has_pack_seq")
        yield Bit(self, "has_pstd_buffer")
        yield Bits(self, "sync[]", 3)  # =7
        yield Bit(self, "has_extension2")

        if self["has_private"].value:
            yield RawBytes(self, "private", 16)

        if self["has_pack_lgth"].value:
            yield UInt8(self, "pack_lgth")

        if self["has_pack_seq"].value:
            yield Bit(self, "sync[]")  # =True
            yield Bits(self, "pack_seq_counter", 7)
            yield Bit(self, "sync[]")  # =True
            yield Bit(self, "mpeg12_id")
            yield Bits(self, "orig_stuffing_length", 6)

        if self["has_pstd_buffer"].value:
            yield Bits(self, "sync[]", 2)  # =1
            yield Enum(Bit(self, "pstd_buffer_scale"), {
                True: "128 bytes",
                False: "1024 bytes"
            })
            yield Bits(self, "pstd_size", 13)
Beispiel #23
0
    def createFields(self):
        # Access flags (16 bits)
        yield NullBits(self, "reserved[]", 4)
        yield Bit(self, "strict")
        yield Bit(self, "abstract")
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "native")
        yield NullBits(self, "reserved[]", 2)
        yield Bit(self, "synchronized")
        yield Bit(self, "final")
        yield Bit(self, "static")
        yield Bit(self, "protected")
        yield Bit(self, "private")
        yield Bit(self, "public")

        yield CPIndex(self, "name_index", "Method name", target_types="Utf8")
        yield CPIndex(self,
                      "descriptor_index",
                      "Method descriptor",
                      target_types="Utf8",
                      target_text_handler=parse_method_descriptor)
        yield UInt16(self, "attributes_count", "Number of method attributes")
        if self["attributes_count"].value > 0:
            yield FieldArray(self, "attributes", AttributeInfo,
                             self["attributes_count"].value)
Beispiel #24
0
def headerParse(parent):
    yield UInt32(parent, "width", "Width (pixels)")
    yield UInt32(parent, "height", "Height (pixels)")
    yield UInt8(parent, "bit_depth", "Bit depth")
    yield NullBits(parent, "reserved", 5)
    yield Bit(parent, "has_alpha", "Has alpha channel?")
    yield Bit(parent, "color", "Color used?")
    yield Bit(parent, "has_palette", "Has a color palette?")
    yield Enum(UInt8(parent, "compression", "Compression method"), COMPRESSION_NAME)
    yield UInt8(parent, "filter", "Filter method")
    yield UInt8(parent, "interlace", "Interlace method")
Beispiel #25
0
    def createFields(self):
        yield Bytes(self, "signature", 2, "New executable signature (NE)")
        yield UInt8(self, "link_ver", "Linker version number")
        yield UInt8(self, "link_rev", "Linker revision number")
        yield UInt16(self, "entry_table_ofst", "Offset to the entry table")
        yield UInt16(self, "entry_table_size", "Length (in bytes) of the entry table")
        yield PaddingBytes(self, "reserved[]", 4)

        yield Bit(self, "is_dll", "Is a dynamic-link library (DLL)?")
        yield Bit(self, "is_win_app", "Is a Windows application?")
        yield PaddingBits(self, "reserved[]", 9)
        yield Bit(self, "first_seg_code", "First segment contains code that loads the application?")
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "link_error", "Load even if linker detects errors?")
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "is_lib", "Is a library module?")

        yield UInt16(self, "auto_data_seg", "Automatic data segment number")
        yield filesizeHandler(UInt16(self, "local_heap_size", "Initial size (in bytes) of the local heap"))
        yield filesizeHandler(UInt16(self, "stack_size", "Initial size (in bytes) of the stack"))
        yield textHandler(UInt32(self, "cs_ip", "Value of CS:IP"), hexadecimal)
        yield textHandler(UInt32(self, "ss_sp", "Value of SS:SP"), hexadecimal)

        yield UInt16(self, "nb_entry_seg_tab", "Number of entries in the segment table")
        yield UInt16(self, "nb_entry_modref_tab", "Number of entries in the module-reference table")
        yield filesizeHandler(UInt16(self, "size_nonres_name_tab", "Number of bytes in the nonresident-name table"))
        yield UInt16(self, "seg_tab_ofs", "Segment table offset")
        yield UInt16(self, "rsrc_ofs", "Resource offset")

        yield UInt16(self, "res_name_tab_ofs", "Resident-name table offset")
        yield UInt16(self, "mod_ref_tab_ofs", "Module-reference table offset")
        yield UInt16(self, "import_tab_ofs", "Imported-name table offset")

        yield UInt32(self, "non_res_name_tab_ofs", "Nonresident-name table offset")
        yield UInt16(self, "nb_mov_ent_pt", "Number of movable entry points")
        yield UInt16(self, "log2_sector_size", "Log2 of the segment sector size")
        yield UInt16(self, "nb_rsrc_seg", "Number of resource segments")

        yield Bit(self, "unknown_os_format", "Operating system format is unknown")
        yield PaddingBits(self, "reserved[]", 1)
        yield Bit(self, "os_windows", "Operating system is Microsoft Windows")
        yield NullBits(self, "reserved[]", 6)
        yield Bit(self, "is_win20_prot", "Is Windows 2.x application running in version 3.x protected mode")
        yield Bit(self, "is_win20_font", "Is Windows 2.x application supporting proportional fonts")
        yield Bit(self, "fast_load", "Contains a fast-load area?")
        yield NullBits(self, "reserved[]", 4)

        yield UInt16(self, "fastload_ofs", "Fast-load area offset (in sector)")
        yield UInt16(self, "fastload_size", "Fast-load area length (in sector)")

        yield NullBytes(self, "reserved[]", 2)
        yield textHandler(UInt16(self, "win_version", "Expected Windows version number"), hexadecimal)
Beispiel #26
0
def parseTry(parent, size):
    yield Bits(parent, "reserved", 5)
    catchInReg = Bit(parent, "catch_in_register")
    yield catchInReg
    yield Bit(parent, "finally")
    yield Bit(parent, "catch")
    yield UInt8(parent, "try_size")
    yield UInt8(parent, "catch_size")
    yield UInt8(parent, "finally_size")
    if catchInReg.value:
        yield CString(parent, "name")
    else:
        yield UInt8(parent, "register")
Beispiel #27
0
 def createFields(self):
     yield Bits(self, "temporal_ref", 10)
     yield Enum(Bits(self, "coding_type", 3), self.CODING_TYPE)
     yield Bits(self, "vbv_delay", 16)
     if self['coding_type'].value in (2, 3):
         # predictive coding
         yield Bit(self, 'full_pel_fwd_vector')
         yield Bits(self, 'forward_f_code', 3)
     if self['coding_type'].value == 3:
         # bidi predictive coding
         yield Bit(self, 'full_pel_back_vector')
         yield Bits(self, 'backward_f_code', 3)
     yield Bits(self, "padding", 8 - (self.current_size % 8))
Beispiel #28
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)")
Beispiel #29
0
def parseAudio(parent, size):
    yield Enum(Bits(parent, "codec", 4, "Audio codec"), AUDIO_CODEC_NAME)
    yield Enum(Bits(parent, "sampling_rate", 2, "Sampling rate"),
               SAMPLING_RATE_TEXT)
    yield Bit(parent, "is_16bit", "16-bit or 8-bit per sample")
    yield Bit(parent, "is_stereo", "Stereo or mono channel")

    size -= 1
    if 0 < size:
        if parent["codec"].value == AUDIO_CODEC_MP3:
            yield Frame(parent, "music_data", size=size * 8)
        else:
            yield RawBytes(parent, "music_data", size)
Beispiel #30
0
 def createFields(self):
     yield GUID(self, "guid")
     yield filesizeHandler(UInt64(self, "file_size"))
     yield TimestampWin64(self, "creation_date")
     yield UInt64(self, "pckt_count")
     yield TimedeltaWin64(self, "play_duration")
     yield TimedeltaWin64(self, "send_duration")
     yield UInt64(self, "preroll")
     yield Bit(self, "broadcast", "Is broadcast?")
     yield Bit(self, "seekable", "Seekable stream?")
     yield PaddingBits(self, "reserved[]", 30)
     yield filesizeHandler(UInt32(self, "min_pckt_size"))
     yield filesizeHandler(UInt32(self, "max_pckt_size"))
     yield displayHandler(UInt32(self, "max_bitrate"), humanBitRate)
Beispiel #31
0
 def __init__(self, parent, name, nb_block):
     """@param nb_block: Number of the block concerned"""
     Bit.__init__(self, parent, name)
     self.block_nb = self.__class__.block_nb
     self.__class__.block_nb += 1
Beispiel #32
0
 def createDisplay(self):
     return self.STATE[Bit.createValue(self)]