From 271ddb116c8a3e0f2a34cedbb906a2883b5289b1 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sun, 12 Aug 2012 10:59:37 +0200 Subject: lavfi: use min_perms and rej_perms for out pads. There are several reasons for doing that: 1. It documents the code for the reader and helps find inconsistencies and bugs. 2. For rej_perms, it guarantees the change will be done even if the output reference can be created by several code paths. 3. It can be used to predict cases where a copy will, or will not happen and optimize buffer allocation (for example not request a rare direct-rendering buffer from a device sink if it will be copied anyway). Note that a filter is still allowed to manage the permissions on its own without using these fields. --- libavfilter/audio.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libavfilter/audio.c') diff --git a/libavfilter/audio.c b/libavfilter/audio.c index 1a201e608b..44d3ab75a6 100644 --- a/libavfilter/audio.c +++ b/libavfilter/audio.c @@ -159,6 +159,7 @@ static int default_filter_samples(AVFilterLink *link, int ff_filter_samples_framed(AVFilterLink *link, AVFilterBufferRef *samplesref) { int (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); + AVFilterPad *src = link->srcpad; AVFilterPad *dst = link->dstpad; int64_t pts; AVFilterBufferRef *buf_out; @@ -169,6 +170,9 @@ int ff_filter_samples_framed(AVFilterLink *link, AVFilterBufferRef *samplesref) if (!(filter_samples = dst->filter_samples)) filter_samples = default_filter_samples; + av_assert1((samplesref->perms & src->min_perms) == src->min_perms); + samplesref->perms &= ~ src->rej_perms; + /* prepare to copy the samples if the buffer has insufficient permissions */ if ((dst->min_perms & samplesref->perms) != dst->min_perms || dst->rej_perms & samplesref->perms) { -- cgit v1.2.3