def createFields(self): yield Enum(Bits(self, "ext_type", 4), self.EXT_TYPE) ext_type = self['ext_type'].value if ext_type == 1: # Sequence extension yield Bits(self, 'profile_and_level', 8) yield Bit(self, 'progressive_sequence') yield Bits(self, 'chroma_format', 2) yield Bits(self, 'horiz_size_ext', 2) yield Bits(self, 'vert_size_ext', 2) yield Bits(self, 'bit_rate_ext', 12) yield Bits(self, 'pad[]', 1) yield Bits(self, 'vbv_buffer_size_ext', 8) yield Bit(self, 'low_delay') yield Bits(self, 'frame_rate_ext_n', 2) yield Bits(self, 'frame_rate_ext_d', 5) elif ext_type == 2: # Sequence Display extension yield Bits(self, 'video_format', 3) yield Bit(self, 'color_desc_present') if self['color_desc_present'].value: yield UInt8(self, 'color_primaries') yield UInt8(self, 'transfer_characteristics') yield UInt8(self, 'matrix_coeffs') yield Bits(self, 'display_horiz_size', 14) yield Bits(self, 'pad[]', 1) yield Bits(self, 'display_vert_size', 14) yield NullBits(self, 'pad[]', 3) elif ext_type == 8: yield Bits(self, 'f_code[0][0]', 4, description="forward horizontal") yield Bits(self, 'f_code[0][1]', 4, description="forward vertical") yield Bits(self, 'f_code[1][0]', 4, description="backward horizontal") yield Bits(self, 'f_code[1][1]', 4, description="backward vertical") yield Bits(self, 'intra_dc_precision', 2) yield Bits(self, 'picture_structure', 2) yield Bit(self, 'top_field_first') yield Bit(self, 'frame_pred_frame_dct') yield Bit(self, 'concealment_motion_vectors') yield Bit(self, 'q_scale_type') yield Bit(self, 'intra_vlc_format') yield Bit(self, 'alternate_scan') yield Bit(self, 'repeat_first_field') yield Bit(self, 'chroma_420_type') yield Bit(self, 'progressive_frame') yield Bit(self, 'composite_display') if self['composite_display'].value: yield Bit(self, 'v_axis') yield Bits(self, 'field_sequence', 3) yield Bit(self, 'sub_carrier') yield Bits(self, 'burst_amplitude', 7) yield Bits(self, 'sub_carrier_phase', 8) yield NullBits(self, 'pad[]', 2) else: yield NullBits(self, 'pad[]', 6) else: yield RawBits(self, "raw[]", 4)
def createFields(self): field_thunks = ( lambda: Bit(self, "is_writable", "Section contains writable data?" ), lambda: Bit(self, "is_alloc", "Section occupies memory?"), lambda: Bit(self, "is_exec", "Section contains executable instructions?"), lambda: NullBits(self, "reserved[]", 1), lambda: Bit(self, "is_merged", "Section might be merged to eliminate duplication?"), lambda: Bit(self, "is_strings", "Section contains nul terminated strings?"), lambda: Bit( self, "is_info_link", "sh_info field of this section header holds section header table index?" ), lambda: Bit(self, "preserve_link_order", "Section requires special ordering for linker?"), lambda: Bit(self, "os_nonconforming", "Section rqeuires OS-specific processing?"), lambda: Bit(self, "is_group", "Section is a member of a section group?"), lambda: Bit(self, "is_tls", "Section contains TLS data?"), lambda: Bit(self, "is_compressed", "Section contains compressed data?"), lambda: NullBits(self, "reserved[]", 8), lambda: RawBits(self, "os_specific", 8, "OS specific flags"), lambda: RawBits(self, "processor_specific", 4, "Processor specific flags"), ) if self.root.endian == BIG_ENDIAN: if self.root.is64bit: yield RawBits(self, "reserved[]", 32) for t in reversed(field_thunks): yield t() else: for t in field_thunks: yield t() if self.root.is64bit: yield RawBits(self, "reserved[]", 32)
def parseSMPTEOffset(parser, size): yield RawBits(parser, "padding", 1) yield Enum(Bits(parser, "frame_rate", 2), { 0: "24 fps", 1: "25 fps", 2: "30 fps (drop frame)", 3: "30 fps" }) yield Bits(parser, "hour", 5) yield UInt8(parser, "minute") yield UInt8(parser, "second") yield UInt8(parser, "frame") yield UInt8(parser, "subframe", "100 subframes per frame")
def parseFileProperties(self): 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, "num_pkts", "Number of data packets") yield UInt32(self, "duration", "File duration in milliseconds") yield UInt32(self, "preroll", "Suggested preroll in milliseconds") yield textHandler(UInt32(self, "index_offset", "Absolute offset of first index chunk"), hexadecimal) yield textHandler(UInt32(self, "data_offset", "Absolute offset of first data chunk"), hexadecimal) yield UInt16(self, "stream_count", "Number of streams in the file") yield RawBits(self, "reserved", 13) yield Bit(self, "is_live", "Whether file is a live broadcast") yield Bit(self, "is_perfect_play", "Whether PerfectPlay can be used") yield Bit(self, "is_saveable", "Whether file can be saved")
def __init__(self, parent, name): RawBits.__init__(self, parent, name, 8)
def __init__(self, parent, name, description=None): RawBits.__init__(self, parent, name, 1, description=description)