From 43c1702579e1bf2c39be103b1d373b2dc1faee1d Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Wed, 1 Mar 2023 22:25:17 +0300
Subject: [PATCH] Fix build in pluginfclient.C with ffmpeg 6.0

---
 cinelerra-5.1/cinelerra/pluginfclient.C | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/pluginfclient.C b/cinelerra-5.1/cinelerra/pluginfclient.C
index d188eb39..afb88c7a 100644
--- a/cinelerra-5.1/cinelerra/pluginfclient.C
+++ b/cinelerra-5.1/cinelerra/pluginfclient.C
@@ -37,6 +37,8 @@
 #include "vframe.h"
 #include "filexml.h"
 
+#include "libavfilter/version.h"
+
 #ifdef FFMPEG3
 #define av_filter_iterate(p) ((*(const AVFilter**)(p))=avfilter_next(*(const AVFilter **)(p)))
 #endif
@@ -660,13 +662,22 @@ PluginFClient::~PluginFClient()
 }
 
 bool PluginFClient::is_audio(const AVFilter *fp)
+
 {
 	if( !fp->outputs ) return 0;
+#if LIBAVFILTER_VERSION_MINOR > 2
+	if( avfilter_filter_pad_count(fp, 1) > 1 ) return 0;
+#else
 	if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
+#endif
 	if( !avfilter_pad_get_name(fp->outputs, 0) ) return 0;
 	if( avfilter_pad_get_type(fp->outputs, 0) != AVMEDIA_TYPE_AUDIO ) return 0;
 	if( !fp->inputs ) return 1;
+#if LIBAVFILTER_VERSION_MINOR > 2
+	if( avfilter_filter_pad_count(fp, 0) > 1 ) return 0;
+#else
 	if( avfilter_pad_count(fp->inputs) > 1 ) return 0;
+#endif
 	if( !avfilter_pad_get_name(fp->inputs, 0) ) return 0;
 	if( avfilter_pad_get_type(fp->inputs, 0) != AVMEDIA_TYPE_AUDIO ) return 0;
 	return 1;
@@ -674,11 +685,19 @@ bool PluginFClient::is_audio(const AVFilter *fp)
 bool PluginFClient::is_video(const AVFilter *fp)
 {
 	if( !fp->outputs ) return 0;
+#if LIBAVFILTER_VERSION_MINOR > 2
+	if( avfilter_filter_pad_count(fp, 1) > 1 ) return 0;
+#else
 	if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
+#endif
 	if( !avfilter_pad_get_name(fp->outputs, 0) ) return 0;
 	if( avfilter_pad_get_type(fp->outputs, 0) != AVMEDIA_TYPE_VIDEO ) return 0;
 	if( !fp->inputs ) return 1;
+#if LIBAVFILTER_VERSION_MINOR > 2
+	if( avfilter_filter_pad_count(fp, 0) > 1 ) return 0;
+#else
 	if( avfilter_pad_count(fp->inputs) > 1 ) return 0;
+#endif
 	if( !avfilter_pad_get_name(fp->inputs, 0) ) return 0;
 	if( avfilter_pad_get_type(fp->inputs, 0) != AVMEDIA_TYPE_VIDEO ) return 0;
 	return 1;
-- 
2.39.2

