From b7eafe82be8b021821cebcf2e961fbec28e723b9 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Tue, 3 Feb 2026 20:37:02 -0500 Subject: [PATCH] Remove unused c defs --- av/logging.pxd | 4 +++ av/logging.py | 6 ++-- include/libavcodec/bsf.pxd | 28 +++------------ include/libavutil/avutil.pxd | 54 ++--------------------------- include/libavutil/dict.pxd | 30 +++------------- include/libavutil/error.pxd | 13 ------- include/libavutil/hwcontext.pxd | 1 - include/libavutil/motion_vector.pxd | 1 - include/libavutil/samplefmt.pxd | 15 +++----- 9 files changed, 22 insertions(+), 130 deletions(-) diff --git a/av/logging.pxd b/av/logging.pxd index a886a0f20..8bd9fb730 100644 --- a/av/logging.pxd +++ b/av/logging.pxd @@ -1,2 +1,6 @@ +cdef extern from "Python.h" nogil: + void PyErr_PrintEx(int set_sys_last_vars) + int Py_IsInitialized() + void PyErr_Display(object, object, object) cpdef get_last_error() diff --git a/av/logging.py b/av/logging.py index ade74c954..a937b26a2 100644 --- a/av/logging.py +++ b/av/logging.py @@ -328,7 +328,7 @@ def log_callback( format: cython.p_const_char, args: lib.va_list, ) -> cython.void: - inited: cython.bint = lib.Py_IsInitialized() + inited: cython.bint = Py_IsInitialized() if not inited: return @@ -361,9 +361,9 @@ def log_callback( level, message, ) - # For some reason lib.PyErr_PrintEx(0) won't work. + # For some reason PyErr_PrintEx(0) won't work. exc, type_, tb = sys.exc_info() - lib.PyErr_Display(exc, type_, tb) + PyErr_Display(exc, type_, tb) @cython.cfunc diff --git a/include/libavcodec/bsf.pxd b/include/libavcodec/bsf.pxd index 4a558b478..b4c41f7f4 100644 --- a/include/libavcodec/bsf.pxd +++ b/include/libavcodec/bsf.pxd @@ -1,6 +1,4 @@ - cdef extern from "libavcodec/bsf.h" nogil: - cdef struct AVBitStreamFilter: const char *name AVCodecID *codec_ids @@ -13,28 +11,10 @@ cdef extern from "libavcodec/bsf.h" nogil: const AVCodecParameters *par_in const AVCodecParameters *par_out - cdef const AVBitStreamFilter* av_bsf_get_by_name(const char *name) - - cdef int av_bsf_list_parse_str( - const char *str, - AVBSFContext **bsf - ) - + cdef int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf) cdef int av_bsf_init(AVBSFContext *ctx) cdef void av_bsf_free(AVBSFContext **ctx) - cdef AVBitStreamFilter* av_bsf_iterate(void **opaque) - - cdef int av_bsf_send_packet( - AVBSFContext *ctx, - AVPacket *pkt - ) - - cdef int av_bsf_receive_packet( - AVBSFContext *ctx, - AVPacket *pkt - ) - - cdef void av_bsf_flush( - AVBSFContext *ctx - ) + cdef int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) + cdef int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt) + cdef void av_bsf_flush(AVBSFContext *ctx) diff --git a/include/libavutil/avutil.pxd b/include/libavutil/avutil.pxd index 790469ff7..23b4fa6fc 100644 --- a/include/libavutil/avutil.pxd +++ b/include/libavutil/avutil.pxd @@ -1,9 +1,6 @@ from libc.stdint cimport int64_t, uint8_t, uint64_t, int32_t -cdef extern from "libavutil/mathematics.h" nogil: - pass - cdef extern from "libavutil/display.h" nogil: cdef double av_display_rotation_get(const int32_t matrix[9]) @@ -12,7 +9,7 @@ cdef extern from "libavutil/rational.h" nogil: cdef extern from "libavutil/avutil.h" nogil: cdef const char* av_version_info() - cdef int avutil_version() + cdef int avutil_version() cdef char* avutil_configuration() cdef char* avutil_license() @@ -34,15 +31,6 @@ cdef extern from "libavutil/avutil.h" nogil: PIX_FMT_RGB24 PIX_FMT_RGBA - cdef enum AVRounding: - AV_ROUND_ZERO - AV_ROUND_INF - AV_ROUND_DOWN - AV_ROUND_UP - AV_ROUND_NEAR_INF - # This is nice, but only in FFMpeg: - # AV_ROUND_PASS_MINMAX - cdef enum AVColorSpace: AVCOL_SPC_RGB AVCOL_SPC_BT709 @@ -83,37 +71,14 @@ cdef extern from "libavutil/avutil.h" nogil: AVCOL_PRI_NB cdef enum AVColorTransferCharacteristic: - AVCOL_TRC_RESERVED0 - AVCOL_TRC_BT709 - AVCOL_TRC_UNSPECIFIED - AVCOL_TRC_RESERVED - AVCOL_TRC_GAMMA22 - AVCOL_TRC_GAMMA28 - AVCOL_TRC_SMPTE170M - AVCOL_TRC_SMPTE240M - AVCOL_TRC_LINEAR - AVCOL_TRC_LOG - AVCOL_TRC_LOG_SQRT - AVCOL_TRC_IEC61966_2_4 - AVCOL_TRC_BT1361_ECG - AVCOL_TRC_IEC61966_2_1 - AVCOL_TRC_BT2020_10 - AVCOL_TRC_BT2020_12 - AVCOL_TRC_SMPTE2084 - AVCOL_TRC_SMPTEST2084 - AVCOL_TRC_SMPTE428 - AVCOL_TRC_SMPTEST428_1 - AVCOL_TRC_ARIB_STD_B67 - AVCOL_TRC_NB + pass cdef void* av_malloc(size_t size) cdef void* av_mallocz(size_t size) cdef void* av_realloc(void *ptr, size_t size) cdef void av_free(void *ptr) cdef void av_freep(void *ptr) - cdef int av_get_bytes_per_sample(AVSampleFormat sample_fmt) - cdef int av_samples_get_buffer_size( int *linesize, int nb_channels, @@ -124,7 +89,6 @@ cdef extern from "libavutil/avutil.h" nogil: ctypedef struct AVRational: int num int den - cdef AVRational AV_TIME_BASE_Q cdef int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) cdef int64_t av_rescale(int64_t a, int64_t b, int64_t c) cdef const char* av_get_media_type_string(AVMediaType media_type) @@ -142,13 +106,9 @@ cdef extern from "libavutil/pixdesc.h" nogil: AV_PIX_FMT_FLAG_BE AV_PIX_FMT_FLAG_PAL AV_PIX_FMT_FLAG_BITSTREAM - AV_PIX_FMT_FLAG_HWACCEL AV_PIX_FMT_FLAG_PLANAR AV_PIX_FMT_FLAG_RGB - AV_PIX_FMT_FLAG_PSEUDOPAL - AV_PIX_FMT_FLAG_ALPHA AV_PIX_FMT_FLAG_BAYER - AV_PIX_FMT_FLAG_FLOAT # See: http://ffmpeg.org/doxygen/trunk/structAVPixFmtDescriptor.html cdef struct AVPixFmtDescriptor: @@ -161,10 +121,8 @@ cdef extern from "libavutil/pixdesc.h" nogil: cdef AVPixFmtDescriptor* av_pix_fmt_desc_get(AVPixelFormat pix_fmt) cdef AVPixFmtDescriptor* av_pix_fmt_desc_next(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) @@ -186,14 +144,6 @@ cdef extern from "stdarg.h" nogil: ctypedef struct va_list: pass - -cdef extern from "Python.h" nogil: - cdef int Py_AddPendingCall(void *, void *) - void PyErr_PrintEx(int set_sys_last_vars) - int Py_IsInitialized() - void PyErr_Display(object, object, object) - - cdef extern from "libavutil/opt.h" nogil: cdef enum AVOptionType: AV_OPT_TYPE_FLAGS diff --git a/include/libavutil/dict.pxd b/include/libavutil/dict.pxd index c2b141101..19b0d9086 100644 --- a/include/libavutil/dict.pxd +++ b/include/libavutil/dict.pxd @@ -1,38 +1,18 @@ cdef extern from "libavutil/dict.h" nogil: - # See: http://ffmpeg.org/doxygen/trunk/structAVDictionary.html ctypedef struct AVDictionary: pass - - cdef void av_dict_free(AVDictionary **) - # See: http://ffmpeg.org/doxygen/trunk/structAVDictionaryEntry.html ctypedef struct AVDictionaryEntry: char *key char *value - cdef int AV_DICT_IGNORE_SUFFIX - + cdef void av_dict_free(AVDictionary **) cdef AVDictionaryEntry* av_dict_get( - AVDictionary *dict, - char *key, - AVDictionaryEntry *prev, - int flags, + AVDictionary *dict, char *key, AVDictionaryEntry *prev, int flags ) - cdef int av_dict_set( - AVDictionary **pm, - const char *key, - const char *value, - int flags - ) - - cdef int av_dict_count( - AVDictionary *m - ) - - cdef int av_dict_copy( - AVDictionary **dst, - AVDictionary *src, - int flags + AVDictionary **pm, const char *key, const char *value, int flags ) + cdef int av_dict_count(AVDictionary *m) + cdef int av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags) diff --git a/include/libavutil/error.pxd b/include/libavutil/error.pxd index 2122772e3..17aad3fd9 100644 --- a/include/libavutil/error.pxd +++ b/include/libavutil/error.pxd @@ -1,9 +1,4 @@ cdef extern from "libavutil/error.h" nogil: - - # Not actually from here, but whatever. - cdef int ENOMEM - cdef int EAGAIN - cdef int AVERROR_BSF_NOT_FOUND cdef int AVERROR_BUG cdef int AVERROR_BUFFER_TOO_SMALL @@ -23,21 +18,13 @@ cdef extern from "libavutil/error.h" nogil: cdef int AVERROR_EXPERIMENTAL cdef int AVERROR_INPUT_CHANGED cdef int AVERROR_OUTPUT_CHANGED - cdef int AVERROR_HTTP_BAD_REQUEST cdef int AVERROR_HTTP_UNAUTHORIZED cdef int AVERROR_HTTP_FORBIDDEN cdef int AVERROR_HTTP_NOT_FOUND cdef int AVERROR_HTTP_OTHER_4XX cdef int AVERROR_HTTP_SERVER_ERROR - - cdef int AVERROR_NOMEM "AVERROR(ENOMEM)" - - # cdef int FFERRTAG(int, int, int, int) - cdef int AVERROR(int error) - cdef int AV_ERROR_MAX_STRING_SIZE - cdef int av_strerror(int errno, char *output, size_t output_size) cdef char* av_err2str(int errnum) diff --git a/include/libavutil/hwcontext.pxd b/include/libavutil/hwcontext.pxd index beda15a2c..dc6402a6d 100644 --- a/include/libavutil/hwcontext.pxd +++ b/include/libavutil/hwcontext.pxd @@ -1,5 +1,4 @@ cdef extern from "libavutil/hwcontext.h" nogil: - enum AVHWDeviceType: AV_HWDEVICE_TYPE_NONE AV_HWDEVICE_TYPE_VDPAU diff --git a/include/libavutil/motion_vector.pxd b/include/libavutil/motion_vector.pxd index 457d7149e..4938a5dff 100644 --- a/include/libavutil/motion_vector.pxd +++ b/include/libavutil/motion_vector.pxd @@ -2,7 +2,6 @@ from libc.stdint cimport int16_t, int32_t, uint8_t, uint16_t, uint64_t cdef extern from "libavutil/motion_vector.h" nogil: - cdef struct AVMotionVector: int32_t source uint8_t w diff --git a/include/libavutil/samplefmt.pxd b/include/libavutil/samplefmt.pxd index c70272936..5ee25dafd 100644 --- a/include/libavutil/samplefmt.pxd +++ b/include/libavutil/samplefmt.pxd @@ -1,5 +1,4 @@ cdef extern from "libavutil/samplefmt.h" nogil: - cdef enum AVSampleFormat: AV_SAMPLE_FMT_NONE AV_SAMPLE_FMT_U8 @@ -12,20 +11,14 @@ cdef extern from "libavutil/samplefmt.h" nogil: AV_SAMPLE_FMT_S32P AV_SAMPLE_FMT_FLTP AV_SAMPLE_FMT_DBLP - AV_SAMPLE_FMT_NB # Number. + AV_SAMPLE_FMT_NB - # Find by name. cdef AVSampleFormat av_get_sample_fmt(char* name) - - # Inspection. - cdef char * av_get_sample_fmt_name(AVSampleFormat sample_fmt) - cdef int av_get_bytes_per_sample(AVSampleFormat sample_fmt) - cdef int av_sample_fmt_is_planar(AVSampleFormat sample_fmt) - - # Alternative forms. + cdef char *av_get_sample_fmt_name(AVSampleFormat sample_fmt) + cdef int av_get_bytes_per_sample(AVSampleFormat sample_fmt) + cdef int av_sample_fmt_is_planar(AVSampleFormat sample_fmt) cdef AVSampleFormat av_get_packed_sample_fmt(AVSampleFormat sample_fmt) cdef AVSampleFormat av_get_planar_sample_fmt(AVSampleFormat sample_fmt) - cdef int av_samples_get_buffer_size( int *linesize, int nb_channels,