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
8 changes: 4 additions & 4 deletions av/codec/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def id(self):
@property
def frame_rates(self):
"""A list of supported frame rates (:class:`fractions.Fraction`), or ``None``."""
out: cython.p_void = cython.NULL
out: cython.pointer[cython.const[cython.void]] = cython.NULL
num: cython.int = 0
lib.avcodec_get_supported_config(
cython.NULL,
Expand All @@ -200,7 +200,7 @@ def frame_rates(self):
@property
def audio_rates(self):
"""A list of supported audio sample rates (``int``), or ``None``."""
out: cython.p_void = cython.NULL
out: cython.pointer[cython.const[cython.void]] = cython.NULL
num: cython.int = 0
lib.avcodec_get_supported_config(
cython.NULL,
Expand All @@ -218,7 +218,7 @@ def audio_rates(self):
@property
def video_formats(self):
"""A list of supported :class:`.VideoFormat`, or ``None``."""
out: cython.p_void = cython.NULL
out: cython.pointer[cython.const[cython.void]] = cython.NULL
num: cython.int = 0
lib.avcodec_get_supported_config(
cython.NULL,
Expand All @@ -236,7 +236,7 @@ def video_formats(self):
@property
def audio_formats(self):
"""A list of supported :class:`.AudioFormat`, or ``None``."""
out: cython.p_void = cython.NULL
out: cython.pointer[cython.const[cython.void]] = cython.NULL
num: cython.int = 0
lib.avcodec_get_supported_config(
cython.NULL,
Expand Down
6 changes: 3 additions & 3 deletions av/codec/hwaccel.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ from av.codec.codec cimport Codec

cdef class HWConfig:
cdef object __weakref__
cdef lib.AVCodecHWConfig *ptr
cdef void _init(self, lib.AVCodecHWConfig *ptr)
cdef const lib.AVCodecHWConfig *ptr
cdef void _init(self, const lib.AVCodecHWConfig *ptr)

cdef HWConfig wrap_hwconfig(lib.AVCodecHWConfig *ptr)
cdef HWConfig wrap_hwconfig(const lib.AVCodecHWConfig *ptr)

cdef class HWAccel:
cdef int _device_type
Expand Down
6 changes: 4 additions & 2 deletions av/codec/hwaccel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class HWConfigMethod(IntEnum):


@cython.cfunc
def wrap_hwconfig(ptr: cython.pointer[lib.AVCodecHWConfig]) -> HWConfig:
def wrap_hwconfig(ptr: cython.pointer[cython.const[lib.AVCodecHWConfig]]) -> HWConfig:
try:
return _singletons[cython.cast(cython.Py_ssize_t, ptr)]
except KeyError:
Expand All @@ -61,7 +61,9 @@ def __init__(self, sentinel):
raise RuntimeError("Cannot instantiate CodecContext")

@cython.cfunc
def _init(self, ptr: cython.pointer[lib.AVCodecHWConfig]) -> cython.void:
def _init(
self, ptr: cython.pointer[cython.const[lib.AVCodecHWConfig]]
) -> cython.void:
self.ptr = ptr

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions av/container/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def __cinit__(
res: cython.int
name_obj: bytes = os.fsencode(self.name)
name: cython.p_char = name_obj
ofmt: cython.pointer[lib.AVOutputFormat]
ofmt: cython.pointer[cython.const[lib.AVOutputFormat]]

if self.writeable:
ofmt = (
Expand Down Expand Up @@ -328,7 +328,7 @@ def __cinit__(
self.ptr.io_close2 = pyav_io_close
self.ptr.flags |= lib.AVFMT_FLAG_CUSTOM_IO

ifmt: cython.pointer[lib.AVInputFormat]
ifmt: cython.pointer[cython.const[lib.AVInputFormat]]
c_options: Dictionary
if not self.writeable:
ifmt = self.format.iptr if self.format else cython.NULL
Expand Down
2 changes: 1 addition & 1 deletion av/container/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __cinit__(self, *args, **kwargs):
py_codec_context: CodecContext
i: cython.uint
stream: cython.pointer[lib.AVStream]
codec: cython.pointer[lib.AVCodec]
codec: cython.pointer[cython.const[lib.AVCodec]]
codec_context: cython.pointer[lib.AVCodecContext]

# If we have either the global `options`, or a `stream_options`, prepare
Expand Down
6 changes: 4 additions & 2 deletions av/container/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def add_stream(self, codec_name, rate=None, options: dict | None = None, **kwarg

# Some sane audio defaults
elif codec.type == lib.AVMEDIA_TYPE_AUDIO:
out: cython.p_void = cython.NULL
out: cython.pointer[cython.const[cython.void]] = cython.NULL
lib.avcodec_get_supported_config(
cython.NULL,
codec,
Expand Down Expand Up @@ -285,7 +285,9 @@ def add_data_stream(self, codec_name=None, options: dict | None = None):
:rtype: The new :class:`~av.data.stream.DataStream`.
"""
codec: cython.pointer[cython.const[lib.AVCodec]] = cython.NULL
codec_descriptor: cython.pointer[lib.AVCodecDescriptor] = cython.NULL
codec_descriptor: cython.pointer[cython.const[lib.AVCodecDescriptor]] = (
cython.NULL
)

if codec_name is not None:
codec = lib.avcodec_find_encoder_by_name(codec_name.encode())
Expand Down
2 changes: 1 addition & 1 deletion av/container/pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def pyio_close_gil(pb: cython.pointer[lib.AVIOContext]) -> cython.int:
try:
return lib.avio_close(pb)
except Exception:
stash_exception()
return stash_exception()


@cython.cfunc
Expand Down
6 changes: 3 additions & 3 deletions av/format.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ cdef class ContainerFormat:

cdef readonly str name

cdef lib.AVInputFormat *iptr
cdef lib.AVOutputFormat *optr
cdef const lib.AVInputFormat *iptr
cdef const lib.AVOutputFormat *optr


cdef ContainerFormat build_container_format(lib.AVInputFormat*, lib.AVOutputFormat*)
cdef ContainerFormat build_container_format(const lib.AVInputFormat*, const lib.AVOutputFormat*)
3 changes: 2 additions & 1 deletion av/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

@cython.cfunc
def build_container_format(
iptr: cython.pointer[lib.AVInputFormat], optr: cython.pointer[lib.AVOutputFormat]
iptr: cython.pointer[cython.const[lib.AVInputFormat]],
optr: cython.pointer[cython.const[lib.AVOutputFormat]],
) -> ContainerFormat:
if not iptr and not optr:
raise ValueError("needs input format or output format")
Expand Down
2 changes: 1 addition & 1 deletion av/video/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def height(self):


names = set()
desc = cython.declare(cython.pointer[lib.AVPixFmtDescriptor], cython.NULL)
desc = cython.declare(cython.pointer[cython.const[lib.AVPixFmtDescriptor]], cython.NULL)
while True:
desc = lib.av_pix_fmt_desc_next(desc)
if not desc:
Expand Down
16 changes: 8 additions & 8 deletions include/avcodec.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,18 @@ cdef extern from "libavcodec/avcodec.h" nogil:
int subtitle_header_size
uint8_t *subtitle_header

cdef AVCodecContext* avcodec_alloc_context3(AVCodec *codec)
cdef AVCodecContext* avcodec_alloc_context3(const AVCodec *codec)
cdef void avcodec_free_context(AVCodecContext **ctx)
cdef AVClass* avcodec_get_class()
cdef AVCodec* avcodec_find_decoder(AVCodecID id)
cdef AVCodec* avcodec_find_encoder(AVCodecID id)
cdef AVCodec* avcodec_find_decoder_by_name(char *name)
cdef AVCodec* avcodec_find_encoder_by_name(char *name)
cdef const AVCodec* avcodec_find_decoder(AVCodecID id)
cdef const AVCodec* avcodec_find_encoder(AVCodecID id)
cdef const AVCodec* avcodec_find_decoder_by_name(char *name)
cdef const AVCodec* avcodec_find_encoder_by_name(char *name)
cdef const AVCodec* av_codec_iterate(void **opaque)
cdef AVCodecDescriptor* avcodec_descriptor_get(AVCodecID id)
cdef AVCodecDescriptor* avcodec_descriptor_get_by_name(char *name)
cdef const AVCodecDescriptor* avcodec_descriptor_get(AVCodecID id)
cdef const AVCodecDescriptor* avcodec_descriptor_get_by_name(char *name)
cdef char* avcodec_get_name(AVCodecID id)
cdef int avcodec_open2(AVCodecContext *ctx, AVCodec *codec, AVDictionary **options)
cdef int avcodec_open2(AVCodecContext *ctx, const AVCodec *codec, AVDictionary **options)
cdef enum AVPacketSideDataType:
pass
cdef struct AVPacketSideData:
Expand Down
14 changes: 7 additions & 7 deletions include/avformat.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ cdef extern from "libavformat/avformat.h" nogil:
int flags
)

cdef AVInputFormat* av_find_input_format(const char *name)
cdef const AVInputFormat* av_find_input_format(const char *name)

# http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html
cdef struct AVFormatContext:
unsigned int nb_streams
AVStream **streams
unsigned int nb_chapters
AVChapter **chapters
AVInputFormat *iformat
AVOutputFormat *oformat
const AVInputFormat *iformat
const AVOutputFormat *oformat
AVIOContext *pb
AVIOInterruptCB interrupt_callback
AVDictionary *metadata
Expand All @@ -170,7 +170,7 @@ cdef extern from "libavformat/avformat.h" nogil:
cdef int avformat_open_input(
AVFormatContext **ctx,
char *filename,
AVInputFormat *format,
const AVInputFormat *format,
AVDictionary **options
)

Expand All @@ -181,7 +181,7 @@ cdef extern from "libavformat/avformat.h" nogil:
cdef int av_write_frame(AVFormatContext *ctx, AVPacket *pkt)
cdef int avio_open(AVIOContext **s, char *url, int flags)
cdef int64_t avio_size(AVIOContext *s)
cdef AVOutputFormat* av_guess_format(
cdef const AVOutputFormat* av_guess_format(
char *short_name, char *filename, char *mime_type
)
cdef int avformat_query_codec(
Expand All @@ -191,10 +191,10 @@ cdef extern from "libavformat/avformat.h" nogil:
cdef int avio_close(AVIOContext *s)
cdef int avio_closep(AVIOContext **s)
cdef int avformat_find_stream_info(AVFormatContext *ctx, AVDictionary **options)
cdef AVStream* avformat_new_stream(AVFormatContext *ctx, AVCodec *c)
cdef AVStream* avformat_new_stream(AVFormatContext *ctx, const AVCodec *c)
cdef int avformat_alloc_output_context2(
AVFormatContext **ctx,
AVOutputFormat *oformat,
const AVOutputFormat *oformat,
char *format_name,
char *filename
)
Expand Down
8 changes: 4 additions & 4 deletions include/avutil.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,12 @@ cdef extern from "libavutil/pixdesc.h" nogil:
uint8_t flags
AVComponentDescriptor comp[4]

cdef AVPixFmtDescriptor* av_pix_fmt_desc_get(AVPixelFormat pix_fmt)
cdef AVPixFmtDescriptor* av_pix_fmt_desc_next(AVPixFmtDescriptor *prev)
cdef const AVPixFmtDescriptor* av_pix_fmt_desc_get(AVPixelFormat pix_fmt)
cdef const AVPixFmtDescriptor* av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
cdef char * av_get_pix_fmt_name(AVPixelFormat pix_fmt)
cdef AVPixelFormat av_get_pix_fmt(char* name)
int av_get_bits_per_pixel(AVPixFmtDescriptor *pixdesc)
int av_get_padded_bits_per_pixel(AVPixFmtDescriptor *pixdesc)
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)

cdef extern from "libavutil/rational.h" nogil:
cdef int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Expand Down
Loading