def createRawField(parent, size, name="raw[]", description=None):
    if size <= 0:
        raise FieldError("Unable to create raw field of %s bits" % size)
    if (size % 8) == 0:
        return RawBytes(parent, name, size / 8, description)
    else:
        return RawBits(parent, name, size, description)
Exemple #2
0
 def createFields(self):
     yield Bits(self, "quantizer_scale", 5)
     start = self.absolute_address + self.current_size + 3
     pos = self.stream.searchBytes(
         '\0\0\1', start,
         start + 1024 * 1024 * 8)  # seek forward by at most 1MB
     if pos is None: pos = self.root.size
     yield RawBits(self, "data", pos - start + 3)
Exemple #3
0
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")
Exemple #4
0
 def __init__(self, parent, name):
     RawBits.__init__(self, parent, name, 8)
Exemple #5
0
 def __init__(self, parent, name, description=None):
     RawBits.__init__(self, parent, name, 1, description=description)
Exemple #6
0
 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)
Exemple #7
0
 def __init__(self, parent, name):
     RawBits.__init__(self, parent, name, 8)
Exemple #8
0
 def __init__(self, parent, name, description=None):
     RawBits.__init__(self, parent, name, 1, description=description)