diff --git a/av/audio/codeccontext.py b/av/audio/codeccontext.py index 8174ba26d..4e7118d34 100644 --- a/av/audio/codeccontext.py +++ b/av/audio/codeccontext.py @@ -7,6 +7,7 @@ from cython.cimports.av.packet import Packet +@cython.final @cython.cclass class AudioCodecContext(CodecContext): @cython.cfunc diff --git a/av/audio/fifo.py b/av/audio/fifo.py index ebd68adb8..0fd128ee7 100644 --- a/av/audio/fifo.py +++ b/av/audio/fifo.py @@ -3,6 +3,7 @@ from cython.cimports.av.error import err_check +@cython.final @cython.cclass class AudioFifo: """A simple audio sample FIFO (First In First Out) buffer.""" diff --git a/av/audio/format.py b/av/audio/format.py index 97e1b59a2..d398f6924 100644 --- a/av/audio/format.py +++ b/av/audio/format.py @@ -20,6 +20,7 @@ def get_audio_format(c_format: lib.AVSampleFormat) -> AudioFormat: return format +@cython.final @cython.cclass class AudioFormat: """Descriptor of audio formats.""" diff --git a/av/audio/frame.py b/av/audio/frame.py index 0ff969475..c843c9efd 100644 --- a/av/audio/frame.py +++ b/av/audio/frame.py @@ -27,6 +27,7 @@ def alloc_audio_frame() -> AudioFrame: } +@cython.final @cython.cclass class AudioFrame(Frame): """A frame of audio.""" diff --git a/av/audio/layout.py b/av/audio/layout.py index e7163e33b..344efa220 100644 --- a/av/audio/layout.py +++ b/av/audio/layout.py @@ -25,6 +25,7 @@ def get_audio_layout(c_layout: lib.AVChannelLayout) -> AudioLayout: return layout +@cython.final @cython.cclass class AudioLayout: def __cinit__(self, layout): diff --git a/av/audio/plane.py b/av/audio/plane.py index bdaf15708..e68b5403e 100644 --- a/av/audio/plane.py +++ b/av/audio/plane.py @@ -2,6 +2,7 @@ from cython.cimports.av.audio.frame import AudioFrame +@cython.final @cython.cclass class AudioPlane(Plane): def __cinit__(self, frame: AudioFrame, index: cython.int): diff --git a/av/audio/resampler.py b/av/audio/resampler.py index b0572607f..fb6d98910 100644 --- a/av/audio/resampler.py +++ b/av/audio/resampler.py @@ -6,6 +6,7 @@ from av.error import FFmpegError +@cython.final @cython.cclass class AudioResampler: """AudioResampler(format=None, layout=None, rate=None) diff --git a/av/audio/stream.py b/av/audio/stream.py index e32f7f759..38009db19 100644 --- a/av/audio/stream.py +++ b/av/audio/stream.py @@ -3,6 +3,7 @@ from cython.cimports.av.packet import Packet +@cython.final @cython.cclass class AudioStream(Stream): def __repr__(self): diff --git a/av/bitstream.py b/av/bitstream.py index 3c0bff1bd..db808ab35 100644 --- a/av/bitstream.py +++ b/av/bitstream.py @@ -6,6 +6,7 @@ from cython.cimports.libc.errno import EAGAIN +@cython.final @cython.cclass class BitStreamFilterContext: """ diff --git a/av/buffer.py b/av/buffer.py index 5b179f322..3fefceee4 100644 --- a/av/buffer.py +++ b/av/buffer.py @@ -9,6 +9,7 @@ from cython.cimports.libc.string import memcpy +@cython.final @cython.cclass class ByteSource: def __cinit__(self, owner): diff --git a/av/codec/codec.py b/av/codec/codec.py index 552af8284..681e8cd1d 100644 --- a/av/codec/codec.py +++ b/av/codec/codec.py @@ -59,6 +59,7 @@ class UnknownCodecError(ValueError): pass +@cython.final @cython.cclass class Codec: """Codec(name, mode='r') diff --git a/av/codec/hwaccel.py b/av/codec/hwaccel.py index 0155bdae4..69f742b29 100644 --- a/av/codec/hwaccel.py +++ b/av/codec/hwaccel.py @@ -54,6 +54,7 @@ def wrap_hwconfig(ptr: cython.pointer[cython.const[lib.AVCodecHWConfig]]) -> HWC return config +@cython.final @cython.cclass class HWConfig: def __init__(self, sentinel): @@ -103,6 +104,7 @@ def hwdevices_available(): return result +@cython.final @cython.cclass class HWAccel: def __init__( diff --git a/av/container/input.py b/av/container/input.py index 63792e02a..f5fc52547 100644 --- a/av/container/input.py +++ b/av/container/input.py @@ -6,7 +6,7 @@ from cython.cimports.av.packet import Packet from cython.cimports.av.stream import Stream, wrap_stream from cython.cimports.av.utils import avdict_to_dict -from cython.cimports.libc.stdint import int64_t +from cython.cimports.libc.stdint import int64_t, uint8_t from cython.cimports.libc.stdlib import free, malloc @@ -20,6 +20,7 @@ def close_input(self: InputContainer): self._myflag &= ~2 # enum.input_was_opened = False +@cython.final @cython.cclass class InputContainer(Container): def __cinit__(self, *args, **kwargs): @@ -153,9 +154,9 @@ def demux(self, *args, **kwargs): streams: list[Stream] = self.streams.get(*args, **kwargs) if self.ptr.nb_streams == 0: return - include_stream: cython.pointer[cython.bint] = cython.cast( - cython.pointer[cython.bint], - malloc(self.ptr.nb_streams * cython.sizeof(bint)), + include_stream: cython.pointer[uint8_t] = cython.cast( + cython.pointer[uint8_t], + malloc(self.ptr.nb_streams * cython.sizeof(uint8_t)), ) if include_stream == cython.NULL: raise MemoryError() @@ -168,12 +169,12 @@ def demux(self, *args, **kwargs): self.set_timeout(self.read_timeout) try: for i in range(self.ptr.nb_streams): - include_stream[i] = False + include_stream[i] = 0 for stream in streams: i = stream.index if i >= self.ptr.nb_streams: raise ValueError(f"stream index {i} out of range") - include_stream[i] = True + include_stream[i] = 1 # Pre-allocate a AVPacket that is reused as the read buffer. with cython.nogil: diff --git a/av/container/output.py b/av/container/output.py index 4e868d60c..239e550f2 100644 --- a/av/container/output.py +++ b/av/container/output.py @@ -32,6 +32,7 @@ def close_output(self: OutputContainer): self._myflag |= 8 # enum.done = True +@cython.final @cython.cclass class OutputContainer(Container): def __cinit__(self, *args, **kwargs): diff --git a/av/container/pyio.py b/av/container/pyio.py index 6c248ba13..d5c420ea4 100644 --- a/av/container/pyio.py +++ b/av/container/pyio.py @@ -14,6 +14,7 @@ ) +@cython.final @cython.cclass class PyIOFile: def __cinit__(self, file, buffer_size, writeable=None): diff --git a/av/container/streams.py b/av/container/streams.py index a84e88792..e588694b4 100644 --- a/av/container/streams.py +++ b/av/container/streams.py @@ -40,6 +40,7 @@ def _get_best_stream_index( return stream_index +@cython.final @cython.cclass class StreamContainer: """ diff --git a/av/descriptor.py b/av/descriptor.py index 20cd1a787..faaa0f57c 100644 --- a/av/descriptor.py +++ b/av/descriptor.py @@ -19,6 +19,7 @@ def wrap_avclass(ptr: cython.pointer[cython.const[lib.AVClass]]) -> Descriptor | return obj +@cython.final @cython.cclass class Descriptor: def __cinit__(self, sentinel): diff --git a/av/dictionary.py b/av/dictionary.py index bdd02d055..c9bd76acb 100644 --- a/av/dictionary.py +++ b/av/dictionary.py @@ -2,6 +2,7 @@ from cython.cimports.av.error import err_check +@cython.final @cython.cclass class Dictionary: def __cinit__(self, *args, **kwargs): diff --git a/av/filter/context.py b/av/filter/context.py index bb2068ae9..4873b3ff5 100644 --- a/av/filter/context.py +++ b/av/filter/context.py @@ -24,6 +24,7 @@ def wrap_filter_context( return self +@cython.final @cython.cclass class FilterContext: def __cinit__(self, sentinel): diff --git a/av/filter/filter.py b/av/filter/filter.py index b348dd3e0..bd4d21896 100644 --- a/av/filter/filter.py +++ b/av/filter/filter.py @@ -13,6 +13,7 @@ def wrap_filter(ptr: cython.pointer[cython.const[lib.AVFilter]]) -> Filter: return filter_ +@cython.final @cython.cclass class Filter: def __cinit__(self, name): diff --git a/av/filter/graph.py b/av/filter/graph.py index 507fbf015..c1b61eb20 100644 --- a/av/filter/graph.py +++ b/av/filter/graph.py @@ -12,6 +12,7 @@ from cython.cimports.av.video.frame import VideoFrame +@cython.final @cython.cclass class Graph: def __cinit__(self): diff --git a/av/filter/link.py b/av/filter/link.py index 7914ba2b1..09a078d5a 100644 --- a/av/filter/link.py +++ b/av/filter/link.py @@ -5,6 +5,7 @@ _cinit_sentinel = cython.declare(object, object()) +@cython.final @cython.cclass class FilterLink: def __cinit__(self, sentinel): @@ -78,6 +79,7 @@ def name(self): return lib.avfilter_pad_get_name(self.base_ptr, self.index) +@cython.final @cython.cclass class FilterContextPad(FilterPad): def __repr__(self): diff --git a/av/format.py b/av/format.py index aad23050d..a8222577b 100644 --- a/av/format.py +++ b/av/format.py @@ -46,6 +46,7 @@ class Flags(Flag): # fmt: on +@cython.final @cython.cclass class ContainerFormat: """Descriptor of a container format. diff --git a/av/index.py b/av/index.py index 504da9576..b652bfdc1 100644 --- a/av/index.py +++ b/av/index.py @@ -12,6 +12,7 @@ def wrap_index_entry(ptr: cython.pointer[cython.const[lib.AVIndexEntry]]) -> Ind return obj +@cython.final @cython.cclass class IndexEntry: """A single entry from a stream's index. @@ -71,6 +72,7 @@ def wrap_index_entries(ptr: cython.pointer[lib.AVStream]) -> IndexEntries: return obj +@cython.final @cython.cclass class IndexEntries: """A sequence-like view of FFmpeg's per-stream index entries. diff --git a/av/logging.py b/av/logging.py index dbd247d56..2b565b9e8 100644 --- a/av/logging.py +++ b/av/logging.py @@ -170,6 +170,7 @@ def get_last_error(): thread_captures = cython.declare(dict, {}) +@cython.final @cython.cclass class Capture: """A context manager for capturing logs. diff --git a/av/opaque.py b/av/opaque.py index bd25fd61f..3a57989e4 100644 --- a/av/opaque.py +++ b/av/opaque.py @@ -17,6 +17,7 @@ def key_free(opaque: cython.p_void, data: u8ptr) -> cython.void: opaque_container.pop(name) +@cython.final @cython.cclass class OpaqueContainer: def __cinit__(self): diff --git a/av/option.py b/av/option.py index 6a20af14f..8ed3c8fb1 100644 --- a/av/option.py +++ b/av/option.py @@ -124,6 +124,7 @@ def is_filtering_param(self): return flag_in_bitfield(self.ptr.flags, lib.AV_OPT_FLAG_FILTERING_PARAM) +@cython.final @cython.cclass class Option(BaseOption): @property @@ -186,6 +187,7 @@ def wrap_option_choice( return obj +@cython.final @cython.cclass class OptionChoice(BaseOption): """ diff --git a/av/packet.py b/av/packet.py index b25f61c93..a69cf38c1 100644 --- a/av/packet.py +++ b/av/packet.py @@ -65,6 +65,7 @@ def packet_sidedata_type_from_literal(dtype: PktSideDataT) -> lib.AVPacketSideDa return get_args(PktSideDataT).index(dtype) +@cython.final @cython.cclass class PacketSideData(Buffer): @staticmethod @@ -207,6 +208,7 @@ def _python_free( Py_DECREF(cython.cast(object, opaque)) +@cython.final @cython.cclass class Packet(Buffer): """A packet of encoded data within a :class:`~av.format.Stream`. diff --git a/av/sidedata/encparams.py b/av/sidedata/encparams.py index 399189a6b..d0e78e8a1 100644 --- a/av/sidedata/encparams.py +++ b/av/sidedata/encparams.py @@ -13,6 +13,7 @@ class VideoEncParamsType(IntEnum): MPEG2 = lib.AV_VIDEO_ENC_PARAMS_MPEG2 +@cython.final @cython.cclass class VideoEncParams(SideData): def __repr__(self): @@ -129,6 +130,7 @@ def qp_map(self): return map +@cython.final @cython.cclass class VideoBlockParams: def __init__(self, video_enc_params: VideoEncParams, idx: cython.int) -> None: diff --git a/av/sidedata/motionvectors.py b/av/sidedata/motionvectors.py index dcf0e9913..369832ba6 100644 --- a/av/sidedata/motionvectors.py +++ b/av/sidedata/motionvectors.py @@ -6,6 +6,7 @@ _cinit_bypass_sentinel = cython.declare(object, object()) +@cython.final @cython.cclass class MotionVectors(SideData): def __init__(self, sentinel, frame: Frame, index: cython.int): @@ -70,6 +71,7 @@ def to_ndarray(self): ) +@cython.final @cython.cclass class MotionVector: """ diff --git a/av/stream.py b/av/stream.py index a1a615aae..23749e699 100644 --- a/av/stream.py +++ b/av/stream.py @@ -279,6 +279,7 @@ def type(self): return "unknown" if media_type == cython.NULL else media_type +@cython.final @cython.cclass class DataStream(Stream): def __repr__(self): @@ -297,6 +298,7 @@ def name(self): return desc.name +@cython.final @cython.cclass class AttachmentStream(Stream): """ diff --git a/av/subtitles/codeccontext.py b/av/subtitles/codeccontext.py index c2a9fb4ae..acad69fb7 100644 --- a/av/subtitles/codeccontext.py +++ b/av/subtitles/codeccontext.py @@ -9,6 +9,7 @@ from cython.cimports.libc.string import memcpy +@cython.final @cython.cclass class SubtitleCodecContext(CodecContext): @property diff --git a/av/subtitles/stream.py b/av/subtitles/stream.py index 525440e9d..484eff5be 100644 --- a/av/subtitles/stream.py +++ b/av/subtitles/stream.py @@ -3,6 +3,7 @@ from cython.cimports.av.stream import Stream +@cython.final @cython.cclass class SubtitleStream(Stream): def __getattr__(self, name): diff --git a/av/subtitles/subtitle.py b/av/subtitles/subtitle.py index 91a8aa142..24bf8cbe5 100644 --- a/av/subtitles/subtitle.py +++ b/av/subtitles/subtitle.py @@ -3,6 +3,7 @@ from cython.cimports.libc.string import memcpy +@cython.final @cython.cclass class SubtitleProxy: def __dealloc__(self): @@ -12,6 +13,7 @@ def __dealloc__(self): _cinit_bypass_sentinel = cython.declare(object, object()) +@cython.final @cython.cclass class SubtitleSet: """ @@ -204,6 +206,7 @@ def __repr__(self): return f"" +@cython.final @cython.cclass class BitmapSubtitle(Subtitle): def __cinit__(self, subtitle: SubtitleSet, index: cython.int): @@ -247,6 +250,7 @@ def __getitem__(self, i): return self.planes[i] +@cython.final @cython.cclass class BitmapSubtitlePlane: def __cinit__(self, subtitle: BitmapSubtitle, index: cython.int): @@ -265,6 +269,7 @@ def __getbuffer__(self, view: cython.pointer[Py_buffer], flags: cython.int): PyBuffer_FillInfo(view, self, self._buffer, self.buffer_size, 0, flags) +@cython.final @cython.cclass class AssSubtitle(Subtitle): """ diff --git a/av/video/codeccontext.py b/av/video/codeccontext.py index c9ac25788..eb1c9a365 100644 --- a/av/video/codeccontext.py +++ b/av/video/codeccontext.py @@ -37,6 +37,7 @@ def _get_hw_format( ) +@cython.final @cython.cclass class VideoCodecContext(CodecContext): @cython.cfunc diff --git a/av/video/format.py b/av/video/format.py index 4b6291e71..ce2246836 100644 --- a/av/video/format.py +++ b/av/video/format.py @@ -27,6 +27,7 @@ def get_pix_fmt(name: cython.p_const_char) -> lib.AVPixelFormat: return pix_fmt +@cython.final @cython.cclass class VideoFormat: """ @@ -139,6 +140,7 @@ def chroma_height(self, luma_height: cython.int = 0): return -((-luma_height) >> self.ptr.log2_chroma_h) if luma_height else 0 +@cython.final @cython.cclass class VideoFormatComponent: def __cinit__(self, format: VideoFormat, index: cython.size_t): diff --git a/av/video/frame.py b/av/video/frame.py index 1f345d365..605ec9a9c 100644 --- a/av/video/frame.py +++ b/av/video/frame.py @@ -19,6 +19,7 @@ from cython.cimports.libc.stdint import int64_t, uint8_t +@cython.final @cython.cclass class CudaContext: def __cinit__(self, device_id: cython.int = 0, primary_ctx: cython.bint = True): @@ -466,6 +467,7 @@ def check_ndarray_shape(array: object, ok: cython.bint): raise ValueError(f"Unexpected numpy array shape `{array.shape}`") +@cython.final @cython.cclass class VideoFrame(Frame): def __cinit__(self, width=0, height=0, format="yuv420p"): diff --git a/av/video/plane.py b/av/video/plane.py index 99c159652..0652f108f 100644 --- a/av/video/plane.py +++ b/av/video/plane.py @@ -17,6 +17,7 @@ from cython.cimports.libc.stdlib import free, malloc +@cython.final @cython.cclass class VideoPlane(Plane): def __cinit__(self, frame: VideoFrame, index: cython.int): diff --git a/av/video/reformatter.py b/av/video/reformatter.py index 67f4bd0ad..5778711d8 100644 --- a/av/video/reformatter.py +++ b/av/video/reformatter.py @@ -141,6 +141,7 @@ def _set_frame_colorspace( frame.colorspace = lib.AVCOL_SPC_SMPTE240M +@cython.final @cython.cclass class VideoReformatter: """An object for reformatting size and pixel format of :class:`.VideoFrame`. diff --git a/av/video/stream.py b/av/video/stream.py index d5b2c106d..c37f45a3e 100644 --- a/av/video/stream.py +++ b/av/video/stream.py @@ -5,6 +5,7 @@ from cython.cimports.av.video.frame import VideoFrame +@cython.final @cython.cclass class VideoStream(Stream): def __repr__(self):