Skip to content
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
4 changes: 3 additions & 1 deletion av/audio/codeccontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
@cython.cclass
class AudioCodecContext(CodecContext):
@cython.cfunc
def _prepare_frames_for_encode(self, input_frame: Frame | None) -> list:
def _prepare_frames_for_encode(
self, input_frame: Frame | None
) -> list[Frame | None]:
frame: AudioFrame | None = input_frame
allow_var_frame_size: cython.bint = (
self.ptr.codec.capabilities & lib.AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Expand Down
2 changes: 1 addition & 1 deletion av/audio/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def read_many(self, samples: cython.int, partial: cython.bint = False):
"""

frame: AudioFrame
frames: list = []
frames: list[AudioFrame] = []
while True:
frame = self.read(samples, partial=partial)
if frame is not None:
Expand Down
2 changes: 1 addition & 1 deletion av/audio/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def channels(self):
buf: cython.char[16]
buf2: cython.char[128]

results: list = []
results: list[AudioChannel] = []
for index in range(self.layout.nb_channels):
size = lib.av_channel_name(
buf,
Expand Down
2 changes: 1 addition & 1 deletion av/audio/resampler.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ cdef class AudioResampler:
cdef readonly dict options

cdef Graph graph
cpdef list resample(self, AudioFrame)
cpdef list[AudioFrame] resample(self, AudioFrame)
4 changes: 2 additions & 2 deletions av/audio/resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __cinit__(
self.graph = None

@cython.ccall
def resample(self, frame: AudioFrame | None) -> list:
def resample(self, frame: AudioFrame | None) -> list[AudioFrame]:
"""resample(frame)

Convert the ``sample_rate``, ``channel_layout`` and/or ``format`` of
Expand Down Expand Up @@ -126,7 +126,7 @@ def resample(self, frame: AudioFrame | None) -> list:

self.graph.push(frame)

output: list = []
output: list[AudioFrame] = []
while True:
try:
output.append(self.graph.pull())
Expand Down
6 changes: 3 additions & 3 deletions av/bitstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def filter(self, packet: Packet | None = None):
)
err_check(res)

output: list = []
output: list[Packet] = []
while True:
new_packet = Packet()
with cython.nogil:
Expand All @@ -115,8 +115,8 @@ def flush(self):


@cython.cfunc
def get_filter_names() -> set:
names: set = set()
def get_filter_names() -> set[str]:
names: set[str] = set()
ptr: cython.pointer[cython.const[lib.AVBitStreamFilter]]
opaque: cython.p_void = cython.NULL
while True:
Expand Down
4 changes: 3 additions & 1 deletion av/codec/codec.pxd
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cimport libav as lib

from av.codec.hwaccel cimport HWConfig


cdef class Codec:

cdef const lib.AVCodec *ptr
cdef const lib.AVCodecDescriptor *desc
cdef readonly bint is_encoder

cdef tuple _hardware_configs
cdef tuple[HWConfig, ...] _hardware_configs

cdef _init(self, name=?)

Expand Down
4 changes: 2 additions & 2 deletions av/codec/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import cython
from cython.cimports import libav as lib
from cython.cimports.av.audio.format import get_audio_format
from cython.cimports.av.codec.hwaccel import wrap_hwconfig
from cython.cimports.av.codec.hwaccel import HWConfig, wrap_hwconfig
from cython.cimports.av.rational import from_avrational
from cython.cimports.av.utils import avrational_to_fraction
from cython.cimports.av.video.format import VideoFormat, get_pix_fmt, get_video_format
Expand Down Expand Up @@ -268,7 +268,7 @@ def audio_formats(self):
def hardware_configs(self):
if self._hardware_configs:
return self._hardware_configs
ret: list = []
ret: list[HWConfig] = []
i: cython.int = 0
ptr: cython.pointer[cython.const[lib.AVCodecHWConfig]]
while True:
Expand Down
2 changes: 1 addition & 1 deletion av/codec/context.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cdef class CodecContext:
# are bogus). It should take all info it needs from the context and/or stream.
cdef _prepare_and_time_rebase_frames_for_encode(self, Frame frame)
cdef void _setup_encode_hwframes(self)
cdef list _prepare_frames_for_encode(self, Frame frame)
cdef list[Frame | None] _prepare_frames_for_encode(self, Frame frame)
cdef _setup_encoded_packet(self, Packet)
cdef _setup_decoded_frame(self, Frame, Packet)

Expand Down
14 changes: 7 additions & 7 deletions av/codec/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ def _get_option_default(

@cython.cfunc
def _get_supported_options(obj: cython.p_void):
options: list = []
options: list[CodecOption] = []
ptr: cython.pointer[cython.const[lib.AVOption]] = lib.av_opt_next(obj, cython.NULL)
choice_ptr: cython.pointer[cython.const[lib.AVOption]]
option_type: object

while ptr != cython.NULL:
if ptr.type != lib.AV_OPT_TYPE_CONST:
choices: list = []
choices: list[CodecOptionChoice] = []
if ptr.unit != cython.NULL:
choice_ptr = lib.av_opt_next(obj, cython.NULL)
while choice_ptr != cython.NULL:
Expand Down Expand Up @@ -257,7 +257,7 @@ def supported_options(self):
self.codec.ptr
)
child: cython.p_void
private: list = []
private: list[CodecOption] = []
if ctx == cython.NULL:
raise MemoryError("Cannot allocate codec context")
try:
Expand Down Expand Up @@ -471,7 +471,7 @@ def parse(self, raw_input=None):
out_size: cython.int
consumed: cython.int
packet: Packet = None
packets: list = []
packets: list[Packet] = []

while True:
with cython.nogil:
Expand Down Expand Up @@ -603,7 +603,7 @@ def _setup_encode_hwframes(self) -> cython.void:
self.ptr.pix_fmt = hw_format

@cython.cfunc
def _prepare_frames_for_encode(self, frame: Frame | None) -> list:
def _prepare_frames_for_encode(self, frame: Frame | None) -> list[Frame | None]:
return [frame]

@cython.cfunc
Expand Down Expand Up @@ -738,7 +738,7 @@ def _decode(self, packet: Packet | None):
)
err_check(res, "avcodec_send_packet()")

out: list = []
out: list[Frame] = []
while True:
try:
frame = self._recv_frame()
Expand Down Expand Up @@ -789,7 +789,7 @@ def profiles(self):

:type: list[str]
"""
ret: list = []
ret: list[str] = []
if not self.ptr.codec or not self.codec.desc or not self.codec.desc.profiles:
return ret

Expand Down
2 changes: 1 addition & 1 deletion av/codec/hwaccel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def is_supported(self):
def hwdevices_available():
"""Return the names of the hardware device types FFmpeg was built with,
e.g. ``["cuda", "videotoolbox"]``."""
result: list = []
result: list[str] = []
x: lib.AVHWDeviceType = lib.AV_HWDEVICE_TYPE_NONE
while True:
x = lib.av_hwdevice_iterate_types(x)
Expand Down
2 changes: 1 addition & 1 deletion av/container/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def metadata(self) -> dict:

def chapters(self):
self._assert_open()
result: list = []
result: list[dict] = []
i: cython.Py_ssize_t
for i in range(self.ptr.nb_chapters):
ch = self.ptr.chapters[i]
Expand Down
2 changes: 1 addition & 1 deletion av/container/output.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from av.stream cimport Stream
cdef class OutputContainer(Container):
cdef lib.AVPacket *packet_ptr
cdef dict _extradata_bsfs
cdef list _buffered_packets
cdef list[Packet] _buffered_packets
cdef _mux_one(self, Packet packet)
cdef _buffer_for_extradata(self, Packet packet)
cdef _try_extract_extradata(self, Packet packet)
Expand Down
8 changes: 4 additions & 4 deletions av/container/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _set_codecpar_extradata(
@cython.cfunc
def close_output(self: OutputContainer):
if self.packet_ptr != cython.NULL and self._buffered_packets:
buffered: list = self._buffered_packets
buffered: list[Packet] = self._buffered_packets
self._buffered_packets = []
packet: Packet
for packet in buffered:
Expand Down Expand Up @@ -492,7 +492,7 @@ def start_encoding(self):

# TODO: This does NOT handle options coming from 3 sources.
# This is only a rough approximation of what would be cool to do.
used_options: set = set()
used_options: set[str] = set()
stream: Stream

# Finalize and open all streams.
Expand Down Expand Up @@ -554,7 +554,7 @@ def supported_codecs(self):
"""
Returns a set of all codecs this format supports.
"""
result: set = set()
result: set[str] = set()
codec: cython.pointer[cython.const[lib.AVCodec]] = cython.NULL
opaque: cython.p_void = cython.NULL

Expand Down Expand Up @@ -665,7 +665,7 @@ def _buffer_for_extradata(self, packet: Packet):
return True # Still waiting on some stream's extradata.

# All extradata is resolved: write the header and flush buffered packets.
buffered: list = self._buffered_packets
buffered: list[Packet] = self._buffered_packets
self._buffered_packets = []
buffered_packet: Packet
for buffered_packet in buffered:
Expand Down
2 changes: 1 addition & 1 deletion av/container/streams.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ from av.stream cimport Stream


cdef class StreamContainer:
cdef list _streams
cdef list[Stream] _streams
cdef void add_stream(self, Stream stream)
8 changes: 5 additions & 3 deletions av/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def __repr__(self) -> str:


@cython.cfunc
def _build_device_list(device_list: cython.pointer[lib.AVDeviceInfoList]) -> list:
devices: list = []
def _build_device_list(
device_list: cython.pointer[lib.AVDeviceInfoList],
) -> list[DeviceInfo]:
devices: list[DeviceInfo] = []
i: cython.int
j: cython.int
device_info: cython.pointer[lib.AVDeviceInfo]
Expand All @@ -50,7 +52,7 @@ def _build_device_list(device_list: cython.pointer[lib.AVDeviceInfoList]) -> lis
for i in range(device_list.nb_devices):
device_info = device_list.devices[i]

media_types: list = []
media_types: list[str] = []
for j in range(device_info.nb_media_types):
mt = device_info.media_types[j]
s = lib.av_get_media_type_string(mt)
Expand Down
4 changes: 2 additions & 2 deletions av/filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def outputs(self):


@cython.cfunc
def get_filter_names() -> set:
names: set = set()
def get_filter_names() -> set[str]:
names: set[str] = set()
ptr: cython.pointer[cython.const[lib.AVFilter]]
opaque: cython.p_void = cython.NULL
while True:
Expand Down
2 changes: 1 addition & 1 deletion av/filter/link.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cdef class FilterContextPad(FilterPad):
cdef FilterLink _link


cdef tuple alloc_filter_pads(Filter, const lib.AVFilterPad *ptr, bint is_input, FilterContext context=?)
cdef tuple[FilterPad, ...] alloc_filter_pads(Filter, const lib.AVFilterPad *ptr, bint is_input, FilterContext context=?)
4 changes: 2 additions & 2 deletions av/filter/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def alloc_filter_pads(
ptr: cython.pointer[cython.const[lib.AVFilterPad]],
is_input: cython.bint,
context: FilterContext | None = None,
) -> tuple:
) -> tuple[FilterPad, ...]:
if not ptr:
return ()

pads: list = []
pads: list[FilterPad] = []

# We need to be careful and check our bounds if we know what they are,
# since the arrays on a AVFilterContext are not NULL terminated.
Expand Down
10 changes: 5 additions & 5 deletions av/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def long_name(self):

@property
def extensions(self):
exts: set = set()
exts: set[str] = set()
if self.iptr and self.iptr.extensions:
exts.update(self.iptr.extensions.split(","))
if self.optr and self.optr.extensions:
Expand All @@ -137,8 +137,8 @@ def no_file(self):


@cython.cfunc
def get_output_format_names() -> set:
names: set = set()
def get_output_format_names() -> set[str]:
names: set[str] = set()
ptr: cython.pointer[cython.const[lib.AVOutputFormat]]
opaque: cython.p_void = cython.NULL
while True:
Expand All @@ -151,8 +151,8 @@ def get_output_format_names() -> set:


@cython.cfunc
def get_input_format_names() -> set:
names: set = set()
def get_input_format_names() -> set[str]:
names: set[str] = set()
ptr: cython.pointer[cython.const[lib.AVInputFormat]]
opaque: cython.p_void = cython.NULL
while True:
Expand Down
2 changes: 1 addition & 1 deletion av/sidedata/sidedata.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ cdef int get_display_rotation(Frame frame)

cdef class _SideDataContainer:
cdef Frame frame
cdef list _by_index
cdef list[SideData] _by_index
cdef dict _by_type
2 changes: 1 addition & 1 deletion av/sidedata/sidedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def type(self):
class _SideDataContainer:
def __init__(self, frame: Frame):
self.frame = frame
self._by_index: list = []
self._by_index: list[SideData] = []
self._by_type: dict = {}

i: cython.int
Expand Down
2 changes: 1 addition & 1 deletion av/video/codeccontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _encode_upload_frame(self, vframe: VideoFrame) -> VideoFrame:
return hwframe

@cython.cfunc
def _prepare_frames_for_encode(self, input: Frame | None) -> list:
def _prepare_frames_for_encode(self, input: Frame | None) -> list[Frame | None]:
if input is None or not input:
return [None]

Expand Down
Loading