Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove inheritance from object class, it's not needed #1202

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion av/audio/codeccontext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cimport libav as lib
from av.audio.format cimport AudioFormat, get_audio_format
from av.audio.frame cimport AudioFrame, alloc_audio_frame
from av.audio.layout cimport AudioLayout, get_audio_layout
from av.error cimport err_check
from av.frame cimport Frame
from av.packet cimport Packet

Expand Down
2 changes: 0 additions & 2 deletions av/audio/fifo.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from av.audio.format cimport get_audio_format
from av.audio.frame cimport alloc_audio_frame
from av.audio.layout cimport get_audio_layout
from av.error cimport err_check


Expand Down
2 changes: 1 addition & 1 deletion av/audio/format.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cimport libav as lib


cdef class AudioFormat(object):
cdef class AudioFormat:

cdef lib.AVSampleFormat sample_fmt

Expand Down
2 changes: 1 addition & 1 deletion av/audio/format.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cdef AudioFormat get_audio_format(lib.AVSampleFormat c_format):
return format


cdef class AudioFormat(object):
cdef class AudioFormat:

"""Descriptor of audio formats."""

Expand Down
1 change: 0 additions & 1 deletion av/audio/frame.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ cdef class AudioFrame(Frame):
# Audio filters need AVFrame.channels to match number of channels from layout.
self.ptr.channels = self.layout.nb_channels

cdef size_t buffer_size
if self.layout.channels and nb_samples:

# Cleanup the old buffer.
Expand Down
4 changes: 2 additions & 2 deletions av/audio/layout.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from libc.stdint cimport uint64_t


cdef class AudioLayout(object):
cdef class AudioLayout:

# The layout for FFMpeg; this is essentially a bitmask of channels.
cdef uint64_t layout
Expand All @@ -17,7 +17,7 @@ cdef class AudioLayout(object):
cdef _init(self, uint64_t layout)


cdef class AudioChannel(object):
cdef class AudioChannel:

# The channel for FFmpeg.
cdef uint64_t channel
Expand Down
4 changes: 2 additions & 2 deletions av/audio/layout.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cdef dict channel_descriptions = {
}


cdef class AudioLayout(object):
cdef class AudioLayout:

def __init__(self, layout):

Expand Down Expand Up @@ -105,7 +105,7 @@ cdef class AudioLayout(object):
return <str>out


cdef class AudioChannel(object):
cdef class AudioChannel:

def __cinit__(self, AudioLayout layout, int index):
self.channel = lib.av_channel_layout_extract_channel(layout.layout, index)
Expand Down
2 changes: 0 additions & 2 deletions av/audio/plane.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cimport libav as lib

from av.audio.frame cimport AudioFrame


Expand Down
2 changes: 1 addition & 1 deletion av/audio/resampler.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from av.audio.layout cimport AudioLayout
from av.filter.graph cimport Graph


cdef class AudioResampler(object):
cdef class AudioResampler:

cdef readonly bint is_passthrough

Expand Down
2 changes: 1 addition & 1 deletion av/audio/resampler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import errno
import av.filter


cdef class AudioResampler(object):
cdef class AudioResampler:

"""AudioResampler(format=None, layout=None, rate=None)

Expand Down
2 changes: 1 addition & 1 deletion av/buffer.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cdef class Buffer(object):
cdef class Buffer:

cdef size_t _buffer_size(self)
cdef void* _buffer_ptr(self)
Expand Down
2 changes: 1 addition & 1 deletion av/buffer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from av import deprecation
from av.bytesource cimport ByteSource, bytesource


cdef class Buffer(object):
cdef class Buffer:

"""A base class for PyAV objects which support the buffer protocol, such
as :class:`.Packet` and :class:`.Plane`.
Expand Down
2 changes: 1 addition & 1 deletion av/bytesource.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cpython.buffer cimport Py_buffer


cdef class ByteSource(object):
cdef class ByteSource:

cdef object owner

Expand Down
2 changes: 1 addition & 1 deletion av/bytesource.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from cpython.buffer cimport (
)


cdef class ByteSource(object):
cdef class ByteSource:

def __cinit__(self, owner):
self.owner = owner
Expand Down
2 changes: 1 addition & 1 deletion av/codec/codec.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cimport libav as lib


cdef class Codec(object):
cdef class Codec:

cdef const lib.AVCodec *ptr
cdef const lib.AVCodecDescriptor *desc
Expand Down
4 changes: 2 additions & 2 deletions av/codec/codec.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from av.audio.format cimport get_audio_format
from av.descriptor cimport wrap_avclass
from av.enum cimport define_enum
from av.utils cimport avrational_to_fraction, flag_in_bitfield
from av.utils cimport avrational_to_fraction
from av.video.format cimport get_video_format


Expand Down Expand Up @@ -138,7 +138,7 @@ class UnknownCodecError(ValueError):
pass


cdef class Codec(object):
cdef class Codec:

"""Codec(name, mode='r')

Expand Down
2 changes: 1 addition & 1 deletion av/codec/context.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from av.frame cimport Frame
from av.packet cimport Packet


cdef class CodecContext(object):
cdef class CodecContext:

cdef lib.AVCodecContext *ptr

Expand Down
4 changes: 2 additions & 2 deletions av/codec/context.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings

from libc.errno cimport EAGAIN
from libc.stdint cimport int64_t, uint8_t
from libc.stdint cimport uint8_t
from libc.string cimport memcpy
cimport libav as lib

Expand Down Expand Up @@ -135,7 +135,7 @@ Flags2 = define_enum('Flags2', __name__, (
), is_flags=True)


cdef class CodecContext(object):
cdef class CodecContext:

@staticmethod
def create(codec, mode=None):
Expand Down
2 changes: 1 addition & 1 deletion av/container/core.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ctypedef struct timeout_info:
double timeout


cdef class Container(object):
cdef class Container:

cdef readonly bint writeable
cdef lib.AVFormatContext *ptr
Expand Down
7 changes: 1 addition & 6 deletions av/container/core.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from cython.operator cimport dereference
from libc.stdint cimport int64_t
from libc.stdlib cimport free, malloc

import os
import time
Expand All @@ -20,9 +19,6 @@ from av.dictionary import Dictionary
from av.logging import Capture as LogCapture


ctypedef int64_t (*seek_func_t)(void *opaque, int64_t offset, int whence) noexcept nogil


cdef object _cinit_sentinel = object()


Expand Down Expand Up @@ -166,7 +162,7 @@ Flags = define_enum('Flags', __name__, (
), is_flags=True)


cdef class Container(object):
cdef class Container:

def __cinit__(self, sentinel, file_, format_name, options,
container_options, stream_options,
Expand Down Expand Up @@ -207,7 +203,6 @@ cdef class Container(object):

cdef bytes name_obj = os.fsencode(self.name)
cdef char *name = name_obj
cdef seek_func_t seek_func = NULL

cdef lib.AVOutputFormat *ofmt
if self.writeable:
Expand Down
2 changes: 1 addition & 1 deletion av/container/input.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ cdef class InputContainer(Container):
codec_context.pkt_timebase = stream.time_base
py_codec_context = wrap_codec_context(codec_context, codec)
else:
# no decoder is available
# no decoder is available
py_codec_context = None
self.streams.add_stream(wrap_stream(self, stream, py_codec_context))

Expand Down
1 change: 0 additions & 1 deletion av/container/output.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from fractions import Fraction
import logging
import os

Expand Down
2 changes: 1 addition & 1 deletion av/container/pyio.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cdef void pyio_close_gil(lib.AVIOContext *pb)
cdef void pyio_close_custom_gil(lib.AVIOContext *pb)


cdef class PyIOFile(object):
cdef class PyIOFile:

# File-like source.
cdef readonly object file
Expand Down
2 changes: 1 addition & 1 deletion av/container/pyio.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from av.error cimport stash_exception
ctypedef int64_t (*seek_func_t)(void *opaque, int64_t offset, int whence) noexcept nogil


cdef class PyIOFile(object):
cdef class PyIOFile:

def __cinit__(self, file, buffer_size, writeable=None):

Expand Down
2 changes: 1 addition & 1 deletion av/container/streams.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from av.stream cimport Stream


cdef class StreamContainer(object):
cdef class StreamContainer:

cdef list _streams

Expand Down
2 changes: 1 addition & 1 deletion av/container/streams.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _flatten(input_):
yield x


cdef class StreamContainer(object):
cdef class StreamContainer:

"""

Expand Down
4 changes: 2 additions & 2 deletions av/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MethodDeprecationWarning(AVDeprecationWarning):
warnings.filterwarnings("default", "", AVDeprecationWarning)


class renamed_attr(object):
class renamed_attr:

"""Proxy for renamed attributes (or methods) on classes.
Getting and setting values will be redirected to the provided name,
Expand Down Expand Up @@ -68,7 +68,7 @@ def __set__(self, instance, value):
setattr(instance, self.new_name, value)


class method(object):
class method:
def __init__(self, func):
functools.update_wrapper(self, func, ("__name__", "__doc__"))
self.func = func
Expand Down
2 changes: 1 addition & 1 deletion av/descriptor.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cimport libav as lib


cdef class Descriptor(object):
cdef class Descriptor:

# These are present as:
# - AVCodecContext.av_class (same as avcodec_get_class())
Expand Down
2 changes: 1 addition & 1 deletion av/descriptor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cdef Descriptor wrap_avclass(const lib.AVClass *ptr):
return obj


cdef class Descriptor(object):
cdef class Descriptor:

def __cinit__(self, sentinel):
if sentinel is not _cinit_sentinel:
Expand Down
2 changes: 1 addition & 1 deletion av/dictionary.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cimport libav as lib


cdef class _Dictionary(object):
cdef class _Dictionary:

cdef lib.AVDictionary *ptr

Expand Down
2 changes: 1 addition & 1 deletion av/dictionary.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from collections.abc import MutableMapping
from av.error cimport err_check


cdef class _Dictionary(object):
cdef class _Dictionary:

def __cinit__(self, *args, **kwargs):
for arg in args:
Expand Down
6 changes: 2 additions & 4 deletions av/enum.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ integers for names and values respectively.

"""

from collections import OrderedDict
import copyreg
import sys


cdef sentinel = object()
Expand Down Expand Up @@ -135,7 +133,7 @@ def _unpickle(mod_name, cls_name, item_name):
copyreg.constructor(_unpickle)


cdef class EnumItem(object):
cdef class EnumItem:

"""
Enumerations are when an attribute may only take on a single value at once, and
Expand Down Expand Up @@ -322,7 +320,7 @@ cdef class EnumFlag(EnumItem):
return bool(self.value)


cdef class EnumProperty(object):
cdef class EnumProperty:

cdef object enum
cdef object fget
Expand Down
2 changes: 1 addition & 1 deletion av/filter/context.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from av.filter.filter cimport Filter
from av.filter.graph cimport Graph


cdef class FilterContext(object):
cdef class FilterContext:

cdef lib.AVFilterContext *ptr
cdef readonly Graph graph
Expand Down
8 changes: 3 additions & 5 deletions av/filter/context.pyx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from libc.string cimport memcpy

from av.audio.frame cimport AudioFrame, alloc_audio_frame
from av.audio.frame cimport alloc_audio_frame
from av.dictionary cimport _Dictionary
from av.dictionary import Dictionary
from av.error cimport err_check
from av.filter.pad cimport alloc_filter_pads
from av.frame cimport Frame
from av.utils cimport avrational_to_fraction
from av.video.frame cimport VideoFrame, alloc_video_frame
from av.video.frame cimport alloc_video_frame


cdef object _cinit_sentinel = object()
Expand All @@ -21,7 +19,7 @@ cdef FilterContext wrap_filter_context(Graph graph, Filter filter, lib.AVFilterC
return self


cdef class FilterContext(object):
cdef class FilterContext:

def __cinit__(self, sentinel):
if sentinel is not _cinit_sentinel:
Expand Down
Loading