static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats = NULL;
    AConvertContext *aconvert = ctx->priv;
    AVFilterLink *inlink  = ctx->inputs[0];
    AVFilterLink *outlink = ctx->outputs[0];
    AVFilterChannelLayouts *layouts;

    ff_formats_ref(ff_all_formats(AVMEDIA_TYPE_AUDIO),
                         &inlink->out_formats);
    if (aconvert->out_sample_fmt != AV_SAMPLE_FMT_NONE) {
        formats = NULL;
        ff_add_format(&formats, aconvert->out_sample_fmt);
        ff_formats_ref(formats, &outlink->in_formats);
    } else
        ff_formats_ref(ff_all_formats(AVMEDIA_TYPE_AUDIO),
                             &outlink->in_formats);

    ff_channel_layouts_ref(ff_all_channel_layouts(),
                         &inlink->out_channel_layouts);
    if (aconvert->out_chlayout != 0) {
        layouts = NULL;
        ff_add_channel_layout(&layouts, aconvert->out_chlayout);
        ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
    } else
        ff_channel_layouts_ref(ff_all_channel_layouts(),
                             &outlink->in_channel_layouts);

    return 0;
}
Esempio n. 2
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats;
    AVFilterChannelLayouts *layouts;
    static const enum AVSampleFormat sample_fmts[] = {
        AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
        AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
        AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P,
        AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
        AV_SAMPLE_FMT_NONE
    };

    layouts = ff_all_channel_layouts();
    if (!layouts)
        return AVERROR(ENOMEM);
    ff_set_common_channel_layouts(ctx, layouts);

    formats = ff_make_format_list(sample_fmts);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);

    formats = ff_all_samplerates();
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_samplerates(ctx, formats);

    return 0;
}
Esempio n. 3
0
static int filter_query_formats(AVFilterContext *ctx)
{
    int ret;
    AVFilterFormats *formats;
    AVFilterChannelLayouts *chlayouts;
    AVFilterFormats *samplerates;
    enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs [0]->type :
                            ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
                            AVMEDIA_TYPE_VIDEO;

    if ((ret = ctx->filter->query_formats(ctx)) < 0)
        return ret;

    formats = ff_all_formats(type);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);
    if (type == AVMEDIA_TYPE_AUDIO) {
        samplerates = ff_all_samplerates();
        if (!samplerates)
            return AVERROR(ENOMEM);
        ff_set_common_samplerates(ctx, samplerates);
        chlayouts = ff_all_channel_layouts();
        if (!chlayouts)
            return AVERROR(ENOMEM);
        ff_set_common_channel_layouts(ctx, chlayouts);
    }
    return 0;
}
Esempio n. 4
0
static int query_formats(AVFilterContext *ctx)
{
    AResampleContext *aresample = ctx->priv;
    int out_rate                   = av_get_int(aresample->swr, "osr", NULL);
    uint64_t out_layout            = av_get_int(aresample->swr, "ocl", NULL);
    enum AVSampleFormat out_format = av_get_int(aresample->swr, "osf", NULL);

    AVFilterLink *inlink  = ctx->inputs[0];
    AVFilterLink *outlink = ctx->outputs[0];

    AVFilterFormats        *in_formats      = ff_all_formats(AVMEDIA_TYPE_AUDIO);
    AVFilterFormats        *out_formats;
    AVFilterFormats        *in_samplerates  = ff_all_samplerates();
    AVFilterFormats        *out_samplerates;
    AVFilterChannelLayouts *in_layouts      = ff_all_channel_layouts();
    AVFilterChannelLayouts *out_layouts;

    ff_formats_ref  (in_formats,      &inlink->out_formats);
    ff_formats_ref  (in_samplerates,  &inlink->out_samplerates);
    ff_channel_layouts_ref(in_layouts,      &inlink->out_channel_layouts);

    if(out_rate > 0) {
        out_samplerates = ff_make_format_list((int[]) {
            out_rate, -1
        });
Esempio n. 5
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats = NULL;
    AVFilterChannelLayouts *layouts = NULL;
    AVFilterLink *inlink = ctx->inputs[0];
    AVFilterLink *outlink = ctx->outputs[0];
    static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
    static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
    int ret;

    formats = ff_make_format_list(sample_fmts);
    if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0)
        return ret;

    layouts = ff_all_channel_layouts();
    if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0)
        return ret;

    formats = ff_all_samplerates();
    if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0)
        return ret;

    formats = ff_make_format_list(pix_fmts);
    if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0)
        return ret;

    return 0;
}
Esempio n. 6
0
static int query_formats(AVFilterContext *ctx)
{
    LADSPAContext *s = ctx->priv;
    AVFilterFormats *formats;
    AVFilterChannelLayouts *layouts;
    static const enum AVSampleFormat sample_fmts[] = {
        AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };

    formats = ff_make_format_list(sample_fmts);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);

    if (s->nb_inputs) {
        formats = ff_all_samplerates();
        if (!formats)
            return AVERROR(ENOMEM);

        ff_set_common_samplerates(ctx, formats);
    } else {
        int sample_rates[] = { s->sample_rate, -1 };

        ff_set_common_samplerates(ctx, ff_make_format_list(sample_rates));
    }

    if (s->nb_inputs == 1 && s->nb_outputs == 1) {
        // We will instantiate multiple LADSPA_Handle, one over each channel
        layouts = ff_all_channel_layouts();
        if (!layouts)
            return AVERROR(ENOMEM);

        ff_set_common_channel_layouts(ctx, layouts);
    } else {
        AVFilterLink *outlink = ctx->outputs[0];

        if (s->nb_inputs >= 1) {
            AVFilterLink *inlink = ctx->inputs[0];
            int64_t inlayout = FF_COUNT2LAYOUT(s->nb_inputs);

            layouts = NULL;
            ff_add_channel_layout(&layouts, inlayout);
            ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);

            if (!s->nb_outputs)
                ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
        }

        if (s->nb_outputs >= 1) {
            int64_t outlayout = FF_COUNT2LAYOUT(s->nb_outputs);

            layouts = NULL;
            ff_add_channel_layout(&layouts, outlayout);
            ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
        }
    }

    return 0;
}
Esempio n. 7
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats = NULL;
    ff_add_format(&formats, AV_SAMPLE_FMT_FLT);
    ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
    ff_set_common_formats(ctx, formats);
    ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
    ff_set_common_samplerates(ctx, ff_all_samplerates());
    return 0;
}
Esempio n. 8
0
static int query_formats(AVFilterContext *ctx)
{
    SoxContext *sox = ctx->priv;
    AVFilterFormats *formats = NULL;
    AVFilterChannelLayouts *layouts = NULL;

    ff_add_format(&formats, AV_SAMPLE_FMT_S32);
    ff_set_common_formats(ctx, formats);

    if (sox->effect->handler.flags & SOX_EFF_CHAN) {
        layouts = NULL;
        ff_add_channel_layout(&layouts, av_get_default_channel_layout(sox->effect->out_signal.channels));

        ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts);
        ff_channel_layouts_ref(ff_all_channel_layouts(), &ctx->inputs[0]->out_channel_layouts);
    } else {
        ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
    }

    return 0;
}
Esempio n. 9
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterLink *inlink  = ctx->inputs[0];
    AVFilterLink *outlink = ctx->outputs[0];

    AVFilterFormats        *in_formats      = ff_all_formats(AVMEDIA_TYPE_AUDIO);
    AVFilterFormats        *out_formats     = ff_all_formats(AVMEDIA_TYPE_AUDIO);
    AVFilterFormats        *in_samplerates  = ff_all_samplerates();
    AVFilterFormats        *out_samplerates = ff_all_samplerates();
    AVFilterChannelLayouts *in_layouts      = ff_all_channel_layouts();
    AVFilterChannelLayouts *out_layouts     = ff_all_channel_layouts();

    ff_formats_ref(in_formats,  &inlink->out_formats);
    ff_formats_ref(out_formats, &outlink->in_formats);

    ff_formats_ref(in_samplerates,  &inlink->out_samplerates);
    ff_formats_ref(out_samplerates, &outlink->in_samplerates);

    ff_channel_layouts_ref(in_layouts,  &inlink->out_channel_layouts);
    ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts);

    return 0;
}
Esempio n. 10
0
int ff_default_query_formats(AVFilterContext *ctx)
{
    enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs [0]->type :
                            ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
                            AVMEDIA_TYPE_VIDEO;

    ff_set_common_formats(ctx, ff_all_formats(type));
    if (type == AVMEDIA_TYPE_AUDIO) {
        ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
        ff_set_common_samplerates(ctx, ff_all_samplerates());
    }

    return 0;
}
Esempio n. 11
0
static int query_formats(AVFilterContext *ctx)
{
    VolumeContext *vol = ctx->priv;
    AVFilterFormats *formats = NULL;
    AVFilterChannelLayouts *layouts;
    static const enum AVSampleFormat sample_fmts[][7] = {
        /* PRECISION_FIXED */
        {
            AV_SAMPLE_FMT_U8,
            AV_SAMPLE_FMT_U8P,
            AV_SAMPLE_FMT_S16,
            AV_SAMPLE_FMT_S16P,
            AV_SAMPLE_FMT_S32,
            AV_SAMPLE_FMT_S32P,
            AV_SAMPLE_FMT_NONE
        },
        /* PRECISION_FLOAT */
        {
            AV_SAMPLE_FMT_FLT,
            AV_SAMPLE_FMT_FLTP,
            AV_SAMPLE_FMT_NONE
        },
        /* PRECISION_DOUBLE */
        {
            AV_SAMPLE_FMT_DBL,
            AV_SAMPLE_FMT_DBLP,
            AV_SAMPLE_FMT_NONE
        }
    };

    layouts = ff_all_channel_layouts();
    if (!layouts)
        return AVERROR(ENOMEM);
    ff_set_common_channel_layouts(ctx, layouts);

    formats = ff_make_format_list(sample_fmts[vol->precision]);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);

    formats = ff_all_samplerates();
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_samplerates(ctx, formats);

    return 0;
}
Esempio n. 12
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats *formats = NULL;
    AVFilterChannelLayouts *layouts;

    layouts = ff_all_channel_layouts();

    if (!layouts)
        return AVERROR(ENOMEM);

    ff_add_format(&formats, AV_SAMPLE_FMT_FLT);
    ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
    ff_set_common_formats(ctx, formats);
    ff_set_common_channel_layouts(ctx, layouts);
    ff_set_common_samplerates(ctx, ff_all_samplerates());
    return 0;
}
static int filter_query_formats(AVFilterContext *ctx)
{
    int ret, i;
    AVFilterFormats *formats;
    AVFilterChannelLayouts *chlayouts;
    AVFilterFormats *samplerates;
    enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs [0]->type :
                            ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
                            AVMEDIA_TYPE_VIDEO;

    if ((ret = ctx->filter->query_formats(ctx)) < 0) {
        av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n",
               ctx->name, av_err2str(ret));
        return ret;
    }

    for (i = 0; i < ctx->nb_inputs; i++)
        sanitize_channel_layouts(ctx, ctx->inputs[i]->out_channel_layouts);
    for (i = 0; i < ctx->nb_outputs; i++)
        sanitize_channel_layouts(ctx, ctx->outputs[i]->in_channel_layouts);

    formats = ff_all_formats(type);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);
    if (type == AVMEDIA_TYPE_AUDIO) {
        samplerates = ff_all_samplerates();
        if (!samplerates)
            return AVERROR(ENOMEM);
        ff_set_common_samplerates(ctx, samplerates);
        chlayouts = ff_all_channel_layouts();
        if (!chlayouts)
            return AVERROR(ENOMEM);
        ff_set_common_channel_layouts(ctx, chlayouts);
    }
    return 0;
}
            AV_SAMPLE_FMT_S32P,
            AV_SAMPLE_FMT_NONE
        },
        [PRECISION_FLOAT] = {
            AV_SAMPLE_FMT_FLT,
            AV_SAMPLE_FMT_FLTP,
            AV_SAMPLE_FMT_NONE
        },
        [PRECISION_DOUBLE] = {
            AV_SAMPLE_FMT_DBL,
            AV_SAMPLE_FMT_DBLP,
            AV_SAMPLE_FMT_NONE
        }
    };

    layouts = ff_all_channel_layouts();
    if (!layouts)
        return AVERROR(ENOMEM);
    ff_set_common_channel_layouts(ctx, layouts);

    formats = ff_make_format_list(sample_fmts[vol->precision]);
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_formats(ctx, formats);

    formats = ff_all_samplerates();
    if (!formats)
        return AVERROR(ENOMEM);
    ff_set_common_samplerates(ctx, formats);

    return 0;