* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavutil/atomic.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/buffer.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/samplefmt.h"
+#include "libavutil/thread.h"
#define FF_INTERNAL_FIELDS 1
#include "framequeue.h"
av_freep(link);
}
+#if FF_API_FILTER_GET_SET
int avfilter_link_get_channels(AVFilterLink *link)
{
return link->channels;
}
+#endif
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
{
return NULL;
}
+static AVMutex filter_register_mutex = AV_MUTEX_INITIALIZER;
+
int avfilter_register(AVFilter *filter)
{
- AVFilter **f = last_filter;
+ AVFilter **f;
/* the filter must select generic or internal exclusively */
av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != AVFILTER_FLAG_SUPPORT_TIMELINE);
- filter->next = NULL;
+ ff_mutex_lock(&filter_register_mutex);
+ f = last_filter;
- while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
+ while (*f)
f = &(*f)->next;
+ *f = filter;
+ filter->next = NULL;
last_filter = &filter->next;
+ ff_mutex_unlock(&filter_register_mutex);
+
return 0;
}
{ "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
{ .i64 = 0 }, 0, INT_MAX, FLAGS },
+ { "extra_hw_frames", "Number of extra hardware frames to allocate for the user",
+ OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ NULL },
};
{
return &avfilter_class;
}
+
+int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
+ int default_pool_size)
+{
+ AVHWFramesContext *frames;
+
+ // Must already be set by caller.
+ av_assert0(link->hw_frames_ctx);
+
+ frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
+
+ if (frames->initial_pool_size == 0) {
+ // Dynamic allocation is necessarily supported.
+ } else if (avctx->extra_hw_frames >= 0) {
+ frames->initial_pool_size += avctx->extra_hw_frames;
+ } else {
+ frames->initial_pool_size = default_pool_size;
+ }
+
+ return 0;
+}