<commit_before>from libc.stdint cimport uint8_t

cdef class Packet(object):

    """A packet of encoded data within a :class:`~av.format.Stream`.

    This may, or may not include a complete object within a stream.
    :meth:`decode` must be called to extract encoded data.

    """
    def __init__(self):
        with nogil:
            lib.av_init_packet(&self.struct)
            self.struct.data = NULL
            self.struct.size = 0

    def __dealloc__(self):
        with nogil: lib.av_free_packet(&self.struct)

    def __repr__(self):
        return '<av.%s of #%d, dts=%s, pts=%s at 0x%x>' % (
            self.__class__.__name__,
            self.stream.index,
            self.dts,
            self.pts,
            id(self),
        )

    def decode(self):
        """Decode the data in this packet into a list of Frames."""
        return self.stream.decode(self)

    # Looks circular, but isn't. Silly Cython.
    property stream:
        def __get__(self):
            return self.stream
        def __set__(self, Stream value):
            self.stream = value
            self.struct.stream_index = value.index

    property pts:
        def __get__(self): return None if self.struct.pts == lib.AV_NOPTS_VALUE else self.struct.pts
    property dts:
        def __get__(self):
            return None if self.struct.dts == lib.AV_NOPTS_VALUE else self.struct.dts
        def __set__(self, v):
            if v is None:
                self.struct.dts = lib.AV_NOPTS_VALUE
            else:
                self.struct.dts = v

    property payload:
        def __set__(self,uint8_t[::1] payload):
            self.struct.data = &payload[0]
            self.struct.size = len(payload)


    property pos:
        def __get__(self): return None if self.struct.pos == -1 else self.struct.pos
    property size:
        def __get__(self): return self.struct.size
    property duration:
        def __get__(self): return None if self.struct.duration == lib.AV_NOPTS_VALUE else self.struct.duration
<commit_msg>make pts writable<commit_after>from libc.stdint cimport uint8_t

cdef class Packet(object):

    """A packet of encoded data within a :class:`~av.format.Stream`.

    This may, or may not include a complete object within a stream.
    :meth:`decode` must be called to extract encoded data.

    """
    def __init__(self):
        with nogil:
            lib.av_init_packet(&self.struct)
            self.struct.data = NULL
            self.struct.size = 0

    def __dealloc__(self):
        with nogil: lib.av_free_packet(&self.struct)

    def __repr__(self):
        return '<av.%s of #%d, dts=%s, pts=%s at 0x%x>' % (
            self.__class__.__name__,
            self.stream.index,
            self.dts,
            self.pts,
            id(self),
        )

    def decode(self):
        """Decode the data in this packet into a list of Frames."""
        return self.stream.decode(self)

    # Looks circular, but isn't. Silly Cython.
    property stream:
        def __get__(self):
            return self.stream
        def __set__(self, Stream value):
            self.stream = value
            self.struct.stream_index = value.index

    property pts:
        def __get__(self):
            return None if self.struct.pts == lib.AV_NOPTS_VALUE else self.struct.pts
        def __set__(self,int v):
            if v is None:
                self.struct.pts = lib.AV_NOPTS_VALUE
            else:
                self.struct.pts = v
    property dts:
        def __get__(self):
            return None if self.struct.dts == lib.AV_NOPTS_VALUE else self.struct.dts
        def __set__(self,int v):
            if v is None:
                self.struct.dts = lib.AV_NOPTS_VALUE
            else:
                self.struct.dts = v

    property payload:
        def __set__(self,uint8_t[::1] payload):
            self.struct.data = &payload[0]
            self.struct.size = len(payload)


    property pos:
        def __get__(self): return None if self.struct.pos == -1 else self.struct.pos
        def __set__(self,pos): self.struct.pos = pos

    property size:
        def __get__(self): return self.struct.size
    property duration:
        def __get__(self): return None if self.struct.duration == lib.AV_NOPTS_VALUE else self.struct.duration

{'fraction_non_alphanumeric': 0.09927755767886273, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 1.955922865013774, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7005396', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1262, 'n_words': 358}