aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-05-07 11:21:38 +0200
committerAnton Khirnov <anton@khirnov.net>2012-05-09 20:32:49 +0200
commit0b45334a5880d6e2a4b3642adcd5feab8a27a150 (patch)
treefce910431912967b4cdeabb80c200aaf17ca90fb /libavfilter/avfilter.c
parent472fb3bbfaf6fddb33d45688046184e7684c9f71 (diff)
downloadffmpeg-0b45334a5880d6e2a4b3642adcd5feab8a27a150.tar.gz
lavfi: move audio-related functions to a separate file.
This is easier to follow than having them randomly scattered in avfilter.c and defaults.c.
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c127
1 files changed, 1 insertions, 126 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 6a530f8fd6..bd898e37ab 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -27,7 +27,6 @@
#include "libavutil/imgutils.h"
#include "libavcodec/avcodec.h"
-#include "audio.h"
#include "avfilter.h"
#include "internal.h"
@@ -277,7 +276,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
av_dlog(ctx, "]%s", end ? "\n" : "");
}
-static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
+void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
{
if (link->type == AVMEDIA_TYPE_VIDEO) {
av_dlog(ctx,
@@ -301,8 +300,6 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
}
}
-#define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
-
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
AVFilterBufferRef *ret = NULL;
@@ -368,91 +365,6 @@ fail:
return NULL;
}
-AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms,
- int nb_samples)
-{
- AVFilterBufferRef *ret = NULL;
-
- if (link->dstpad->get_audio_buffer)
- ret = link->dstpad->get_audio_buffer(link, perms, nb_samples);
-
- if (!ret)
- ret = ff_default_get_audio_buffer(link, perms, nb_samples);
-
- if (ret)
- ret->type = AVMEDIA_TYPE_AUDIO;
-
- return ret;
-}
-
-AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
- int linesize, int perms,
- int nb_samples,
- enum AVSampleFormat sample_fmt,
- uint64_t channel_layout)
-{
- int planes;
- AVFilterBuffer *samples = av_mallocz(sizeof(*samples));
- AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref));
-
- if (!samples || !samplesref)
- goto fail;
-
- samplesref->buf = samples;
- samplesref->buf->free = ff_avfilter_default_free_buffer;
- if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio))))
- goto fail;
-
- samplesref->audio->nb_samples = nb_samples;
- samplesref->audio->channel_layout = channel_layout;
- samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt);
-
- planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1;
-
- /* make sure the buffer gets read permission or it's useless for output */
- samplesref->perms = perms | AV_PERM_READ;
-
- samples->refcount = 1;
- samplesref->type = AVMEDIA_TYPE_AUDIO;
- samplesref->format = sample_fmt;
-
- memcpy(samples->data, data,
- FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0]));
- memcpy(samplesref->data, samples->data, sizeof(samples->data));
-
- samples->linesize[0] = samplesref->linesize[0] = linesize;
-
- if (planes > FF_ARRAY_ELEMS(samples->data)) {
- samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) *
- planes);
- samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) *
- planes);
-
- if (!samples->extended_data || !samplesref->extended_data)
- goto fail;
-
- memcpy(samples-> extended_data, data, sizeof(*data)*planes);
- memcpy(samplesref->extended_data, data, sizeof(*data)*planes);
- } else {
- samples->extended_data = samples->data;
- samplesref->extended_data = samplesref->data;
- }
-
- return samplesref;
-
-fail:
- if (samples && samples->extended_data != samples->data)
- av_freep(&samples->extended_data);
- if (samplesref) {
- av_freep(&samplesref->audio);
- if (samplesref->extended_data != samplesref->data)
- av_freep(&samplesref->extended_data);
- }
- av_freep(&samplesref);
- av_freep(&samples);
- return NULL;
-}
-
int avfilter_request_frame(AVFilterLink *link)
{
FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1);
@@ -572,43 +484,6 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
draw_slice(link, y, h, slice_dir);
}
-void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
-{
- void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
- AVFilterPad *dst = link->dstpad;
-
- FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
-
- if (!(filter_samples = dst->filter_samples))
- filter_samples = ff_default_filter_samples;
-
- /* 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) {
- int i, planar = av_sample_fmt_is_planar(samplesref->format);
- int planes = !planar ? 1:
- av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
-
- av_log(link->dst, AV_LOG_DEBUG,
- "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
- samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
-
- link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms,
- samplesref->audio->nb_samples);
- link->cur_buf->pts = samplesref->pts;
- link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
-
- /* Copy actual data into new samples buffer */
- for (i = 0; i < planes; i++)
- memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]);
-
- avfilter_unref_buffer(samplesref);
- } else
- link->cur_buf = samplesref;
-
- filter_samples(link, link->cur_buf);
-}
-
#define MAX_REGISTERED_AVFILTERS_NB 64
static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];