Skip to content

Commit

Permalink
lavfi: merge start_frame/draw_slice/end_frame
Browse files Browse the repository at this point in the history
Any alleged performance benefits gained from the split are purely
mythological and do not justify added code complexity.
  • Loading branch information
elenril committed Nov 28, 2012
1 parent bb6c67b commit 565e499
Show file tree
Hide file tree
Showing 55 changed files with 632 additions and 1,458 deletions.
6 changes: 3 additions & 3 deletions libavfilter/af_amix.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static int output_frame(AVFilterLink *outlink, int nb_samples)
if (s->next_pts != AV_NOPTS_VALUE)
s->next_pts += nb_samples;

return ff_filter_samples(outlink, out_buf);
return ff_filter_frame(outlink, out_buf);
}

/**
Expand Down Expand Up @@ -455,7 +455,7 @@ static int request_frame(AVFilterLink *outlink)
return output_frame(outlink, available_samples);
}

static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
MixContext *s = ctx->priv;
Expand Down Expand Up @@ -509,7 +509,7 @@ static int init(AVFilterContext *ctx, const char *args)
snprintf(name, sizeof(name), "input%d", i);
pad.type = AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
pad.filter_samples = filter_samples;
pad.filter_frame = filter_frame;

ff_insert_inpad(ctx, i, &pad);
}
Expand Down
7 changes: 4 additions & 3 deletions libavfilter/af_ashowinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "audio.h"
#include "avfilter.h"
#include "internal.h"

typedef struct AShowInfoContext {
/**
Expand Down Expand Up @@ -64,7 +65,7 @@ static void uninit(AVFilterContext *ctx)
av_freep(&s->plane_checksums);
}

static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
AShowInfoContext *s = ctx->priv;
Expand Down Expand Up @@ -103,7 +104,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
av_log(ctx, AV_LOG_INFO, "]\n");

s->frame++;
return ff_filter_samples(inlink->dst->outputs[0], buf);
return ff_filter_frame(inlink->dst->outputs[0], buf);
}

static const AVFilterPad inputs[] = {
Expand All @@ -112,7 +113,7 @@ static const AVFilterPad inputs[] = {
.type = AVMEDIA_TYPE_AUDIO,
.get_audio_buffer = ff_null_get_audio_buffer,
.config_props = config_input,
.filter_samples = filter_samples,
.filter_frame = filter_frame,
.min_perms = AV_PERM_READ,
},
{ NULL },
Expand Down
10 changes: 5 additions & 5 deletions libavfilter/af_asyncts.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct ASyncContext {
float min_delta_sec;
int max_comp;

/* set by filter_samples() to signal an output frame to request_frame() */
/* set by filter_frame() to signal an output frame to request_frame() */
int got_output;
} ASyncContext;

Expand Down Expand Up @@ -141,7 +141,7 @@ static int request_frame(AVFilterLink *link)
}

buf->pts = s->pts;
return ff_filter_samples(link, buf);
return ff_filter_frame(link, buf);
}

return ret;
Expand All @@ -161,7 +161,7 @@ static int64_t get_delay(ASyncContext *s)
return avresample_available(s->avr) + avresample_get_delay(s->avr);
}

static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ASyncContext *s = ctx->priv;
Expand Down Expand Up @@ -217,7 +217,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
av_samples_set_silence(buf_out->extended_data, out_size - delta,
delta, nb_channels, buf->format);
}
ret = ff_filter_samples(outlink, buf_out);
ret = ff_filter_frame(outlink, buf_out);
if (ret < 0)
goto fail;
s->got_output = 1;
Expand All @@ -243,7 +243,7 @@ static const AVFilterPad avfilter_af_asyncts_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = filter_samples
.filter_frame = filter_frame,
},
{ NULL }
};
Expand Down
6 changes: 3 additions & 3 deletions libavfilter/af_channelmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int channelmap_query_formats(AVFilterContext *ctx)
return 0;
}

static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int channelmap_filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
Expand Down Expand Up @@ -355,7 +355,7 @@ static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *bu
memcpy(buf->data, buf->extended_data,
FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));

return ff_filter_samples(outlink, buf);
return ff_filter_frame(outlink, buf);
}

static int channelmap_config_input(AVFilterLink *inlink)
Expand Down Expand Up @@ -389,7 +389,7 @@ static const AVFilterPad avfilter_af_channelmap_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = channelmap_filter_samples,
.filter_frame = channelmap_filter_frame,
.config_props = channelmap_config_input
},
{ NULL }
Expand Down
6 changes: 3 additions & 3 deletions libavfilter/af_channelsplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int query_formats(AVFilterContext *ctx)
return 0;
}

static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
int i, ret = 0;
Expand All @@ -128,7 +128,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
buf_out->audio->channel_layout =
av_channel_layout_extract_channel(buf->audio->channel_layout, i);

ret = ff_filter_samples(ctx->outputs[i], buf_out);
ret = ff_filter_frame(ctx->outputs[i], buf_out);
if (ret < 0)
break;
}
Expand All @@ -140,7 +140,7 @@ static const AVFilterPad avfilter_af_channelsplit_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = filter_samples,
.filter_frame = filter_frame,
},
{ NULL }
};
Expand Down
6 changes: 3 additions & 3 deletions libavfilter/af_join.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static const AVClass join_class = {
.version = LIBAVUTIL_VERSION_INT,
};

static int filter_samples(AVFilterLink *link, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *link, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = link->dst;
JoinContext *s = ctx->priv;
Expand Down Expand Up @@ -230,7 +230,7 @@ static int join_init(AVFilterContext *ctx, const char *args)
snprintf(name, sizeof(name), "input%d", i);
pad.type = AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
pad.filter_samples = filter_samples;
pad.filter_frame = filter_frame;

pad.needs_fifo = 1;

Expand Down Expand Up @@ -471,7 +471,7 @@ static int join_request_frame(AVFilterLink *outlink)
priv->nb_in_buffers = ctx->nb_inputs;
buf->buf->priv = priv;

ret = ff_filter_samples(outlink, buf);
ret = ff_filter_frame(outlink, buf);

memset(s->input_frames, 0, sizeof(*s->input_frames) * ctx->nb_inputs);

Expand Down
12 changes: 6 additions & 6 deletions libavfilter/af_resample.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef struct ResampleContext {

int64_t next_pts;

/* set by filter_samples() to signal an output frame to request_frame() */
/* set by filter_frame() to signal an output frame to request_frame() */
int got_output;
} ResampleContext;

Expand Down Expand Up @@ -162,12 +162,12 @@ static int request_frame(AVFilterLink *outlink)
}

buf->pts = s->next_pts;
return ff_filter_samples(outlink, buf);
return ff_filter_frame(outlink, buf);
}
return ret;
}

static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ResampleContext *s = ctx->priv;
Expand Down Expand Up @@ -224,15 +224,15 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)

s->next_pts = buf_out->pts + buf_out->audio->nb_samples;

ret = ff_filter_samples(outlink, buf_out);
ret = ff_filter_frame(outlink, buf_out);
s->got_output = 1;
}

fail:
avfilter_unref_buffer(buf);
} else {
buf->format = outlink->format;
ret = ff_filter_samples(outlink, buf);
ret = ff_filter_frame(outlink, buf);
s->got_output = 1;
}

Expand All @@ -243,7 +243,7 @@ static const AVFilterPad avfilter_af_resample_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = filter_samples,
.filter_frame = filter_frame,
.min_perms = AV_PERM_READ
},
{ NULL }
Expand Down
4 changes: 2 additions & 2 deletions libavfilter/asink_anullsink.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "avfilter.h"
#include "internal.h"

static int null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
static int null_filter_frame(AVFilterLink *link, AVFilterBufferRef *samplesref)
{
avfilter_unref_bufferp(&samplesref);
return 0;
Expand All @@ -30,7 +30,7 @@ static const AVFilterPad avfilter_asink_anullsink_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = null_filter_samples,
.filter_frame = null_filter_frame,
},
{ NULL },
};
Expand Down
47 changes: 0 additions & 47 deletions libavfilter/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,50 +146,3 @@ AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
av_freep(&samples);
return NULL;
}

static int default_filter_samples(AVFilterLink *link,
AVFilterBufferRef *samplesref)
{
return ff_filter_samples(link->dst->outputs[0], samplesref);
}

int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
{
int (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
AVFilterPad *dst = link->dstpad;
AVFilterBufferRef *buf_out;

FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);

if (!(filter_samples = dst->filter_samples))
filter_samples = 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) {
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);

buf_out = ff_default_get_audio_buffer(link, dst->min_perms,
samplesref->audio->nb_samples);
if (!buf_out) {
avfilter_unref_buffer(samplesref);
return AVERROR(ENOMEM);
}
buf_out->pts = samplesref->pts;
buf_out->audio->sample_rate = samplesref->audio->sample_rate;

/* Copy actual data into new samples buffer */
av_samples_copy(buf_out->extended_data, samplesref->extended_data,
0, 0, samplesref->audio->nb_samples,
av_get_channel_layout_nb_channels(link->channel_layout),
link->format);

avfilter_unref_buffer(samplesref);
} else
buf_out = samplesref;

return filter_samples(link, buf_out);
}

13 changes: 0 additions & 13 deletions libavfilter/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,4 @@ AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms,
AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms,
int nb_samples);

/**
* Send a buffer of audio samples to the next filter.
*
* @param link the output link over which the audio samples are being sent
* @param samplesref a reference to the buffer of audio samples being sent. The
* receiving filter will free this reference when it no longer
* needs it or pass it on to the next filter.
*
* @return >= 0 on success, a negative AVERROR on error. The receiving filter
* is responsible for unreferencing samplesref in case of error.
*/
int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);

#endif /* AVFILTER_AUDIO_H */
Loading

0 comments on commit 565e499

Please sign in to comment.