From: Federico Tomassetti <[email protected]>
Bug-Id: CID 1224282
---
libavfilter/avfiltergraph.c | 4 ++--
libavfilter/formats.c | 13 +++++++++++++
libavfilter/formats.h | 6 ++++--
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 64a8d4e..a5b68dd 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -372,13 +372,13 @@ static int query_formats(AVFilterGraph *graph, AVClass
*log_ctx)
if (inlink->type == AVMEDIA_TYPE_AUDIO &&
(!ff_mergeable_samplerates(inlink->in_samplerates,
inlink->out_samplerates) ||
- !ff_merge_channel_layouts(inlink->in_channel_layouts,
+ !ff_mergeable_channel_layouts(inlink->in_channel_layouts,
inlink->out_channel_layouts)))
ret |= AVERROR(ENOSYS);
if (outlink->type == AVMEDIA_TYPE_AUDIO &&
(!ff_mergeable_samplerates(outlink->in_samplerates,
outlink->out_samplerates) ||
- !ff_merge_channel_layouts(outlink->in_channel_layouts,
+ !ff_mergeable_channel_layouts(outlink->in_channel_layouts,
outlink->out_channel_layouts)))
ret |= AVERROR(ENOSYS);
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 13dd648..0b8c7c8 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -176,6 +176,19 @@ fail:
return NULL;
}
+int ff_mergeable_channel_layouts(AVFilterChannelLayouts *a,
+ AVFilterChannelLayouts *b)
+{
+ AVFilterChannelLayouts *merged_channels = ff_merge_channel_layouts(a, b);
+ if (merged_channels) {
+ av_freep(&merged_channels->refs);
+ av_freep(&merged_channels->channel_layouts);
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
int ff_fmt_is_in(int fmt, const int *fmts)
{
const int *p;
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 8e9a8a8..8e81f1e 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -91,13 +91,15 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats *a,
AVFilterFormats *b);
/**
- * Verify if a channel samplerates list contains the intersection of
- * the samplerates of a and b. Also, all the references of a, all the
+ * Verify if a channel layouts/samplerates list contains the intersection of
+ * the layouts/samplerates of a and b. Also, all the references of a, all the
* references of b, and a and b themselves will be deallocated.
*
* If a and b do not share any common elements, neither is modified, and false
* is returned, otherwise true is returned.
*/
+int ff_mergeable_channel_layouts(AVFilterChannelLayouts *a,
+ AVFilterChannelLayouts *b);
int ff_mergeable_samplerates(AVFilterFormats *a, AVFilterFormats *b);
/**
--
2.2.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel