Skip to content

Commit d1bbbc9

Browse files
committed
AvFilter: Map and use av_buffersrc_add_frame instead of av_vsrc_buffer_add_frame with libavfilter version 3.
1 parent 0a71337 commit d1bbbc9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/DllAvFilter.h

+16
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ class DllAvFilterInterface
7474
virtual void avfilter_inout_free(AVFilterInOut **inout)=0;
7575
virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)=0;
7676
virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)=0;
77+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
7778
virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0;
79+
#else
80+
virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0;
81+
#endif
7882
virtual void avfilter_unref_buffer(AVFilterBufferRef *ref)=0;
7983
virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)=0;
8084
virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags)=0;
@@ -130,7 +134,11 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
130134
{
131135
return ::avfilter_graph_config(graphctx, log_ctx);
132136
}
137+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
133138
virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, flags); }
139+
#else
140+
virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame, int flags) { return ::av_buffersrc_add_frame(buffer_filter, frame, flags); }
141+
#endif
134142
virtual void avfilter_unref_buffer(AVFilterBufferRef *ref) { ::avfilter_unref_buffer(ref); }
135143
virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { return ::avfilter_link(src, srcpad, dst, dstpad); }
136144
virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags) { return ::av_buffersink_get_buffer_ref(buffer_sink, bufref, flags); }
@@ -162,7 +170,11 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
162170
DEFINE_METHOD1(void, avfilter_inout_free_dont_call, (AVFilterInOut **p1))
163171
DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *)
164172
DEFINE_FUNC_ALIGNED2(int, __cdecl, avfilter_graph_config_dont_call, AVFilterGraph *, void *)
173+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
165174
DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3))
175+
#else
176+
DEFINE_METHOD3(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3))
177+
#endif
166178
DEFINE_METHOD1(void, avfilter_unref_buffer, (AVFilterBufferRef *p1))
167179
DEFINE_METHOD4(int, avfilter_link, (AVFilterContext *p1, unsigned p2, AVFilterContext *p3, unsigned p4))
168180
DEFINE_FUNC_ALIGNED3(int , __cdecl, av_buffersink_get_buffer_ref, AVFilterContext *, AVFilterBufferRef **, int);
@@ -181,7 +193,11 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
181193
RESOLVE_METHOD_RENAME(avfilter_inout_free, avfilter_inout_free_dont_call)
182194
RESOLVE_METHOD_RENAME(avfilter_graph_parse, avfilter_graph_parse_dont_call)
183195
RESOLVE_METHOD_RENAME(avfilter_graph_config, avfilter_graph_config_dont_call)
196+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
184197
RESOLVE_METHOD(av_vsrc_buffer_add_frame)
198+
#else
199+
RESOLVE_METHOD(av_buffersrc_add_frame)
200+
#endif
185201
RESOLVE_METHOD(avfilter_unref_buffer)
186202
RESOLVE_METHOD(avfilter_link)
187203
RESOLVE_METHOD(av_buffersink_get_buffer_ref)

xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,18 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame)
776776

777777
if (frame)
778778
{
779+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
779780
result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, 0);
781+
#else
782+
result = m_dllAvFilter.av_buffersrc_add_frame(m_pFilterIn, frame, 0);
783+
#endif
780784
if (result < 0)
781785
{
786+
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0)
782787
CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_vsrc_buffer_add_frame");
788+
#else
789+
CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersrc_add_frame");
790+
#endif
783791
return VC_ERROR;
784792
}
785793
}

0 commit comments

Comments
 (0)