Skip to content

Commit

Permalink
Use cpdef for encode/decode
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Mar 9, 2024
1 parent 23ce2a3 commit 57f1b92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion av/audio/stream.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from av.stream cimport Stream
from av.packet cimport Packet

from .frame cimport AudioFrame

cdef class AudioStream(Stream):
pass
cpdef encode(self, AudioFrame frame=?)
cpdef decode(self, Packet packet=?)
6 changes: 4 additions & 2 deletions av/audio/stream.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from av.packet cimport Packet

from .frame cimport AudioFrame


cdef class AudioStream(Stream):
def __repr__(self):
Expand All @@ -9,7 +11,7 @@ cdef class AudioStream(Stream):
f" {self.layout.name}, {form} at 0x{id(self):x}>"
)

def encode(self, frame=None):
cpdef encode(self, AudioFrame frame=None):
"""
Encode an :class:`.AudioFrame` and return a list of :class:`.Packet`.
Expand All @@ -26,7 +28,7 @@ cdef class AudioStream(Stream):

return packets

def decode(self, packet=None):
cpdef decode(self, Packet packet=None):
"""
Decode a :class:`.Packet` and return a list of :class:`.AudioFrame`.
:return: :class:`list` of :class:`.AudioFrame`
Expand Down
5 changes: 4 additions & 1 deletion av/video/stream.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from av.stream cimport Stream
from .frame cimport VideoFrame
from av.packet cimport Packet


cdef class VideoStream(Stream):
pass
cpdef encode(self, VideoFrame frame=?)
cpdef decode(self, Packet packet=?)
6 changes: 3 additions & 3 deletions av/video/stream.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from av.packet cimport Packet

from .frame cimport VideoFrame

cdef class VideoStream(Stream):
def __repr__(self):
Expand All @@ -9,7 +9,7 @@ cdef class VideoStream(Stream):
f"{self.codec_context.height} at 0x{id(self):x}>"
)

def encode(self, frame=None):
cpdef encode(self, VideoFrame frame=None):
"""
Encode an :class:`.VideoFrame` and return a list of :class:`.Packet`.
Expand All @@ -27,7 +27,7 @@ cdef class VideoStream(Stream):
return packets


def decode(self, packet=None):
cpdef decode(self, Packet packet=None):
"""
Decode a :class:`.Packet` and return a list of :class:`.VideoFrame`.
:return: :class:`list` of :class:`.Frame` subclasses.
Expand Down

0 comments on commit 57f1b92

Please sign in to comment.