diff --git a/filter.go b/filter.go index 512899b..86b7342 100644 --- a/filter.go +++ b/filter.go @@ -25,6 +25,11 @@ func FindFilterByName(n string) *Filter { return newFilterFromC(C.avfilter_get_by_name(cn)) } +// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a632c76418742ad4f4dccbd4db40badd0 +func (f *Filter) Flags() FilterFlags { + return FilterFlags(f.c.flags) +} + // https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a28a4776f344f91055f42a4c2a1b15c0c func (f *Filter) Name() string { return C.GoString(f.c.name) diff --git a/filter_flag.go b/filter_flag.go new file mode 100644 index 0000000..83eccb3 --- /dev/null +++ b/filter_flag.go @@ -0,0 +1,18 @@ +package astiav + +//#include +import "C" + +// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gae6ed6c10a03508829bdf17560e3e10e5 +type FilterFlag int64 + +const ( + FilterFlagDynamicInputs = FilterFlag(C.AVFILTER_FLAG_DYNAMIC_INPUTS) + FilterFlagDynamicOutputs = FilterFlag(C.AVFILTER_FLAG_DYNAMIC_OUTPUTS) + FilterFlagSliceThreads = FilterFlag(C.AVFILTER_FLAG_SLICE_THREADS) + FilterFlagMetadataOnly = FilterFlag(C.AVFILTER_FLAG_METADATA_ONLY) + FilterFlagHardwareDevice = FilterFlag(C.AVFILTER_FLAG_HWDEVICE) + FilterFlagSupportTimelineGeneric = FilterFlag(C.AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC) + FilterFlagSupportTimelineInternal = FilterFlag(C.AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL) + FilterFlagSupportTimeline = FilterFlag(C.AVFILTER_FLAG_SUPPORT_TIMELINE) +) diff --git a/filter_test.go b/filter_test.go index 82c7e50..63a2478 100644 --- a/filter_test.go +++ b/filter_test.go @@ -11,4 +11,5 @@ func TestFilter(t *testing.T) { require.NotNil(t, f) require.Equal(t, "format", f.Name()) require.Equal(t, "format", f.String()) + require.True(t, f.Flags().Has(FilterFlagMetadataOnly)) } diff --git a/flags.go b/flags.go index 30cd6c9..8d64cf2 100644 --- a/flags.go +++ b/flags.go @@ -125,6 +125,26 @@ func (fs DictionaryFlags) Del(f DictionaryFlag) DictionaryFlags { func (fs DictionaryFlags) Has(f DictionaryFlag) bool { return astikit.BitFlags(fs).Has(uint64(f)) } +type FilterFlags astikit.BitFlags + +func NewFilterFlags(fs ...FilterFlag) FilterFlags { + o := FilterFlags(0) + for _, f := range fs { + o = o.Add(f) + } + return o +} + +func (fs FilterFlags) Add(f FilterFlag) FilterFlags { + return FilterFlags(astikit.BitFlags(fs).Add(uint64(f))) +} + +func (fs FilterFlags) Del(f FilterFlag) FilterFlags { + return FilterFlags(astikit.BitFlags(fs).Del(uint64(f))) +} + +func (fs FilterFlags) Has(f FilterFlag) bool { return astikit.BitFlags(fs).Has(uint64(f)) } + type FilterCommandFlags astikit.BitFlags func NewFilterCommandFlags(fs ...FilterCommandFlag) FilterCommandFlags { diff --git a/flags_test.go b/flags_test.go index 2aaa75c..ce93e69 100644 --- a/flags_test.go +++ b/flags_test.go @@ -60,6 +60,15 @@ func TestDictionaryFlags(t *testing.T) { require.False(t, fs.Has(DictionaryFlag(2))) } +func TestFilterFlags(t *testing.T) { + fs := NewFilterFlags(FilterFlag(1)) + require.True(t, fs.Has(FilterFlag(1))) + fs = fs.Add(FilterFlag(2)) + require.True(t, fs.Has(FilterFlag(2))) + fs = fs.Del(FilterFlag(2)) + require.False(t, fs.Has(FilterFlag(2))) +} + func TestFilterCommandFlags(t *testing.T) { fs := NewFilterCommandFlags(FilterCommandFlag(1)) require.True(t, fs.Has(FilterCommandFlag(1))) diff --git a/internal/cmd/flags/main.go b/internal/cmd/flags/main.go index 72172c6..b710a45 100644 --- a/internal/cmd/flags/main.go +++ b/internal/cmd/flags/main.go @@ -20,6 +20,7 @@ var list = []listItem{ {Name: "CodecContext", Suffix: "2"}, {Name: "CodecHardwareConfigMethod"}, {Name: "Dictionary"}, + {Name: "Filter"}, {Name: "FilterCommand"}, {Name: "FormatContext"}, {Name: "FormatContextCtx"},