lavfi: replace AVFilterContext.input/output_count with nb_inputs/outputs

This is more consistent with naming in the rest of Libav.
pull/59/head
Anton Khirnov 13 years ago
parent 9d0bfc5052
commit 9baeff9506
  1. 4
      doc/APIchanges
  2. 6
      libavfilter/af_amix.c
  3. 4
      libavfilter/af_channelsplit.c
  4. 2
      libavfilter/audio.c
  5. 58
      libavfilter/avfilter.c
  6. 11
      libavfilter/avfilter.h
  7. 34
      libavfilter/avfiltergraph.c
  8. 4
      libavfilter/formats.c
  9. 4
      libavfilter/graphparser.c
  10. 10
      libavfilter/internal.h
  11. 10
      libavfilter/split.c
  12. 5
      libavfilter/version.h
  13. 6
      libavfilter/video.c

@ -13,6 +13,10 @@ libavutil: 2011-04-18
API changes, most recent first:
2012-xx-xx - xxxxxxx - lavfi 2.23.0 - avfilter.h
Add AVFilterContext.nb_inputs/outputs. Deprecate
AVFilterContext.input/output_count.
2012-xx-xx - xxxxxxx - lavfi 2.22.0 - avfilter.h
Add avfilter_pad_get_type() and avfilter_pad_get_name(). Those
should now be used instead of accessing AVFilterPad members

@ -454,10 +454,10 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
AVFilterLink *outlink = ctx->outputs[0];
int i;
for (i = 0; i < ctx->input_count; i++)
for (i = 0; i < ctx->nb_inputs; i++)
if (ctx->inputs[i] == inlink)
break;
if (i >= ctx->input_count) {
if (i >= ctx->nb_inputs) {
av_log(ctx, AV_LOG_ERROR, "unknown input link\n");
return;
}
@ -518,7 +518,7 @@ static void uninit(AVFilterContext *ctx)
av_freep(&s->input_state);
av_freep(&s->input_scale);
for (i = 0; i < ctx->input_count; i++)
for (i = 0; i < ctx->nb_inputs; i++)
av_freep(&ctx->input_pads[i].name);
}

@ -99,7 +99,7 @@ static int query_formats(AVFilterContext *ctx)
ff_add_channel_layout(&in_layouts, s->channel_layout);
ff_channel_layouts_ref(in_layouts, &ctx->inputs[0]->out_channel_layouts);
for (i = 0; i < ctx->output_count; i++) {
for (i = 0; i < ctx->nb_outputs; i++) {
AVFilterChannelLayouts *out_layouts = NULL;
uint64_t channel = av_channel_layout_extract_channel(s->channel_layout, i);
@ -115,7 +115,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
AVFilterContext *ctx = inlink->dst;
int i;
for (i = 0; i < ctx->output_count; i++) {
for (i = 0; i < ctx->nb_outputs; i++) {
AVFilterBufferRef *buf_out = avfilter_ref_buffer(buf, ~AV_PERM_WRITE);
if (!buf_out)

@ -156,7 +156,7 @@ void ff_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesr
{
AVFilterLink *outlink = NULL;
if (inlink->dst->output_count)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
if (outlink) {

@ -70,8 +70,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
{
AVFilterLink *link;
if (src->output_count <= srcpad || dst->input_count <= dstpad ||
src->outputs[srcpad] || dst->inputs[dstpad])
if (src->nb_outputs <= srcpad || dst->nb_inputs <= dstpad ||
src->outputs[srcpad] || dst->inputs[dstpad])
return -1;
if (src->output_pads[srcpad].type != dst->input_pads[dstpad].type) {
@ -138,7 +138,7 @@ int avfilter_config_links(AVFilterContext *filter)
unsigned i;
int ret;
for (i = 0; i < filter->input_count; i ++) {
for (i = 0; i < filter->nb_inputs; i ++) {
AVFilterLink *link = filter->inputs[i];
if (!link) continue;
@ -156,7 +156,7 @@ int avfilter_config_links(AVFilterContext *filter)
return ret;
if (!(config_link = link->srcpad->config_props)) {
if (link->src->input_count != 1) {
if (link->src->nb_inputs != 1) {
av_log(link->src, AV_LOG_ERROR, "Source filters and filters "
"with more than one input "
"must set config_props() "
@ -171,15 +171,15 @@ int avfilter_config_links(AVFilterContext *filter)
}
if (link->time_base.num == 0 && link->time_base.den == 0)
link->time_base = link->src && link->src->input_count ?
link->time_base = link->src && link->src->nb_inputs ?
link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
if (link->type == AVMEDIA_TYPE_VIDEO) {
if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den)
link->sample_aspect_ratio = link->src->input_count ?
link->sample_aspect_ratio = link->src->nb_inputs ?
link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
if (link->src->input_count) {
if (link->src->nb_inputs) {
if (!link->w)
link->w = link->src->inputs[0]->w;
if (!link->h)
@ -249,7 +249,7 @@ int ff_poll_frame(AVFilterLink *link)
if (link->srcpad->poll_frame)
return link->srcpad->poll_frame(link);
for (i = 0; i < link->src->input_count; i++) {
for (i = 0; i < link->src->nb_inputs; i++) {
int val;
if (!link->src->inputs[i])
return -1;
@ -339,27 +339,31 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in
goto err;
}
ret->input_count = pad_count(filter->inputs);
if (ret->input_count) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
ret->nb_inputs = pad_count(filter->inputs);
if (ret->nb_inputs ) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs);
if (!ret->input_pads)
goto err;
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->nb_inputs);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->nb_inputs);
if (!ret->inputs)
goto err;
}
ret->output_count = pad_count(filter->outputs);
if (ret->output_count) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
ret->nb_outputs = pad_count(filter->outputs);
if (ret->nb_outputs) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_outputs);
if (!ret->output_pads)
goto err;
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->nb_outputs);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->nb_outputs);
if (!ret->outputs)
goto err;
}
#if FF_API_FOO_COUNT
ret->output_count = ret->nb_outputs;
ret->input_count = ret->nb_inputs;
#endif
*filter_ctx = ret;
return 0;
@ -367,10 +371,10 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in
err:
av_freep(&ret->inputs);
av_freep(&ret->input_pads);
ret->input_count = 0;
ret->nb_inputs = 0;
av_freep(&ret->outputs);
av_freep(&ret->output_pads);
ret->output_count = 0;
ret->nb_outputs = 0;
av_freep(&ret->priv);
av_free(ret);
return AVERROR(ENOMEM);
@ -384,7 +388,7 @@ void avfilter_free(AVFilterContext *filter)
if (filter->filter->uninit)
filter->filter->uninit(filter);
for (i = 0; i < filter->input_count; i++) {
for (i = 0; i < filter->nb_inputs; i++) {
if ((link = filter->inputs[i])) {
if (link->src)
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
@ -397,7 +401,7 @@ void avfilter_free(AVFilterContext *filter)
}
av_freep(&link);
}
for (i = 0; i < filter->output_count; i++) {
for (i = 0; i < filter->nb_outputs; i++) {
if ((link = filter->outputs[i])) {
if (link->dst)
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
@ -453,14 +457,20 @@ void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
AVFilterPad *p)
{
ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
ff_insert_pad(index, &f->nb_inputs, offsetof(AVFilterLink, dstpad),
&f->input_pads, &f->inputs, p);
#if FF_API_FOO_COUNT
f->input_count = f->nb_inputs;
#endif
}
void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
AVFilterPad *p)
{
ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
ff_insert_pad(index, &f->nb_outputs, offsetof(AVFilterLink, srcpad),
&f->output_pads, &f->outputs, p);
#if FF_API_FOO_COUNT
f->output_count = f->nb_outputs;
#endif
}
int avfilter_poll_frame(AVFilterLink *link)
{

@ -488,15 +488,22 @@ struct AVFilterContext {
char *name; ///< name of this filter instance
unsigned input_count; ///< number of input pads
#if FF_API_FOO_COUNT
unsigned input_count; ///< @deprecated use nb_inputs
#endif
AVFilterPad *input_pads; ///< array of input pads
AVFilterLink **inputs; ///< array of pointers to input links
unsigned output_count; ///< number of output pads
#if FF_API_FOO_COUNT
unsigned output_count; ///< @deprecated use nb_outputs
#endif
AVFilterPad *output_pads; ///< array of output pads
AVFilterLink **outputs; ///< array of pointers to output links
void *priv; ///< private data for use by the filter
unsigned nb_inputs; ///< number of input pads
unsigned nb_outputs; ///< number of output pads
};
/**

@ -109,7 +109,7 @@ static int graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
for (i = 0; i < graph->filter_count; i++) {
filt = graph->filters[i];
for (j = 0; j < filt->input_count; j++) {
for (j = 0; j < filt->nb_inputs; j++) {
if (!filt->inputs[j] || !filt->inputs[j]->src) {
av_log(log_ctx, AV_LOG_ERROR,
"Input pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any source\n",
@ -118,7 +118,7 @@ static int graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
}
}
for (j = 0; j < filt->output_count; j++) {
for (j = 0; j < filt->nb_outputs; j++) {
if (!filt->outputs[j] || !filt->outputs[j]->dst) {
av_log(log_ctx, AV_LOG_ERROR,
"Output pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any destination\n",
@ -144,7 +144,7 @@ static int graph_config_links(AVFilterGraph *graph, AVClass *log_ctx)
for (i=0; i < graph->filter_count; i++) {
filt = graph->filters[i];
if (!filt->output_count) {
if (!filt->nb_outputs) {
if ((ret = avfilter_config_links(filt)))
return ret;
}
@ -181,7 +181,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
for (i = 0; i < graph->filter_count; i++) {
AVFilterContext *filter = graph->filters[i];
for (j = 0; j < filter->input_count; j++) {
for (j = 0; j < filter->nb_inputs; j++) {
AVFilterLink *link = filter->inputs[j];
int convert_needed = 0;
@ -315,7 +315,7 @@ static int pick_format(AVFilterLink *link)
#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
do { \
for (i = 0; i < filter->input_count; i++) { \
for (i = 0; i < filter->nb_inputs; i++) { \
AVFilterLink *link = filter->inputs[i]; \
fmt_type fmt; \
\
@ -323,7 +323,7 @@ do { \
continue; \
fmt = link->out_ ## list->var[0]; \
\
for (j = 0; j < filter->output_count; j++) { \
for (j = 0; j < filter->nb_outputs; j++) { \
AVFilterLink *out_link = filter->outputs[j]; \
list_type *fmts; \
\
@ -380,19 +380,19 @@ static void swap_samplerates_on_filter(AVFilterContext *filter)
int sample_rate;
int i, j;
for (i = 0; i < filter->input_count; i++) {
for (i = 0; i < filter->nb_inputs; i++) {
link = filter->inputs[i];
if (link->type == AVMEDIA_TYPE_AUDIO &&
link->out_samplerates->format_count == 1)
break;
}
if (i == filter->input_count)
if (i == filter->nb_inputs)
return;
sample_rate = link->out_samplerates->formats[0];
for (i = 0; i < filter->output_count; i++) {
for (i = 0; i < filter->nb_outputs; i++) {
AVFilterLink *outlink = filter->outputs[i];
int best_idx, best_diff = INT_MAX;
@ -427,19 +427,19 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter)
uint64_t chlayout;
int i, j;
for (i = 0; i < filter->input_count; i++) {
for (i = 0; i < filter->nb_inputs; i++) {
link = filter->inputs[i];
if (link->type == AVMEDIA_TYPE_AUDIO &&
link->out_channel_layouts->nb_channel_layouts == 1)
break;
}
if (i == filter->input_count)
if (i == filter->nb_inputs)
return;
chlayout = link->out_channel_layouts->channel_layouts[0];
for (i = 0; i < filter->output_count; i++) {
for (i = 0; i < filter->nb_outputs; i++) {
AVFilterLink *outlink = filter->outputs[i];
int best_idx, best_score = INT_MIN;
@ -480,20 +480,20 @@ static void swap_sample_fmts_on_filter(AVFilterContext *filter)
int format, bps;
int i, j;
for (i = 0; i < filter->input_count; i++) {
for (i = 0; i < filter->nb_inputs; i++) {
link = filter->inputs[i];
if (link->type == AVMEDIA_TYPE_AUDIO &&
link->out_formats->format_count == 1)
break;
}
if (i == filter->input_count)
if (i == filter->nb_inputs)
return;
format = link->out_formats->formats[0];
bps = av_get_bytes_per_sample(format);
for (i = 0; i < filter->output_count; i++) {
for (i = 0; i < filter->nb_outputs; i++) {
AVFilterLink *outlink = filter->outputs[i];
int best_idx, best_score = INT_MIN;
@ -549,10 +549,10 @@ static int pick_formats(AVFilterGraph *graph)
for (i = 0; i < graph->filter_count; i++) {
AVFilterContext *filter = graph->filters[i];
for (j = 0; j < filter->input_count; j++)
for (j = 0; j < filter->nb_inputs; j++)
if ((ret = pick_format(filter->inputs[j])) < 0)
return ret;
for (j = 0; j < filter->output_count; j++)
for (j = 0; j < filter->nb_outputs; j++)
if ((ret = pick_format(filter->outputs[j])) < 0)
return ret;
}

@ -330,13 +330,13 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref)
{ \
int count = 0, i; \
\
for (i = 0; i < ctx->input_count; i++) { \
for (i = 0; i < ctx->nb_inputs; i++) { \
if (ctx->inputs[i]) { \
ref(fmts, &ctx->inputs[i]->out_fmts); \
count++; \
} \
} \
for (i = 0; i < ctx->output_count; i++) { \
for (i = 0; i < ctx->nb_outputs; i++) { \
if (ctx->outputs[i]) { \
ref(fmts, &ctx->outputs[i]->in_fmts); \
count++; \

@ -226,7 +226,7 @@ static int link_filter_inouts(AVFilterContext *filt_ctx,
{
int pad, ret;
for (pad = 0; pad < filt_ctx->input_count; pad++) {
for (pad = 0; pad < filt_ctx->nb_inputs; pad++) {
AVFilterInOut *p = *curr_inputs;
if (p) {
@ -254,7 +254,7 @@ static int link_filter_inouts(AVFilterContext *filt_ctx,
return AVERROR(EINVAL);
}
pad = filt_ctx->output_count;
pad = filt_ctx->nb_outputs;
while (pad--) {
AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut));
if (!currlinkn)

@ -183,16 +183,22 @@ void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
AVFilterPad *p)
{
ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
ff_insert_pad(index, &f->nb_inputs, offsetof(AVFilterLink, dstpad),
&f->input_pads, &f->inputs, p);
#if FF_API_FOO_COUNT
f->input_count = f->nb_inputs;
#endif
}
/** Insert a new output pad for the filter. */
static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
AVFilterPad *p)
{
ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
ff_insert_pad(index, &f->nb_outputs, offsetof(AVFilterLink, srcpad),
&f->output_pads, &f->outputs, p);
#if FF_API_FOO_COUNT
f->output_count = f->nb_outputs;
#endif
}
/**

@ -59,7 +59,7 @@ static void split_uninit(AVFilterContext *ctx)
{
int i;
for (i = 0; i < ctx->output_count; i++)
for (i = 0; i < ctx->nb_outputs; i++)
av_freep(&ctx->output_pads[i].name);
}
@ -68,7 +68,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
AVFilterContext *ctx = inlink->dst;
int i;
for (i = 0; i < ctx->output_count; i++)
for (i = 0; i < ctx->nb_outputs; i++)
ff_start_frame(ctx->outputs[i],
avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
}
@ -78,7 +78,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
AVFilterContext *ctx = inlink->dst;
int i;
for (i = 0; i < ctx->output_count; i++)
for (i = 0; i < ctx->nb_outputs; i++)
ff_draw_slice(ctx->outputs[i], y, h, slice_dir);
}
@ -87,7 +87,7 @@ static void end_frame(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->dst;
int i;
for (i = 0; i < ctx->output_count; i++)
for (i = 0; i < ctx->nb_outputs; i++)
ff_end_frame(ctx->outputs[i]);
avfilter_unref_buffer(inlink->cur_buf);
@ -115,7 +115,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
AVFilterContext *ctx = inlink->dst;
int i;
for (i = 0; i < ctx->output_count; i++)
for (i = 0; i < ctx->nb_outputs; i++)
ff_filter_samples(inlink->dst->outputs[i],
avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
}

@ -29,7 +29,7 @@
#include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 22
#define LIBAVFILTER_VERSION_MINOR 23
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@ -62,5 +62,8 @@
#ifndef FF_API_AVFILTERPAD_PUBLIC
#define FF_API_AVFILTERPAD_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 4)
#endif
#ifndef FF_API_FOO_COUNT
#define FF_API_FOO_COUNT (LIBAVFILTER_VERSION_MAJOR < 4)
#endif
#endif // AVFILTER_VERSION_H

@ -169,7 +169,7 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterLink *outlink = NULL;
if (inlink->dst->output_count)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
if (outlink) {
@ -220,7 +220,7 @@ static void default_end_frame(AVFilterLink *inlink)
{
AVFilterLink *outlink = NULL;
if (inlink->dst->output_count)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
avfilter_unref_buffer(inlink->cur_buf);
@ -261,7 +261,7 @@ static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir
{
AVFilterLink *outlink = NULL;
if (inlink->dst->output_count)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
if (outlink)

Loading…
Cancel
Save