mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2025-03-03 09:37:28 +00:00
af_pan: switch to an AVOptions-based shorthand system.
TODO: The first argument can be seperated into its own AVOption Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
9470b541e5
commit
3c821e7550
@ -40,6 +40,8 @@
|
|||||||
#define MAX_CHANNELS 63
|
#define MAX_CHANNELS 63
|
||||||
|
|
||||||
typedef struct PanContext {
|
typedef struct PanContext {
|
||||||
|
const AVClass *class;
|
||||||
|
char *args;
|
||||||
int64_t out_channel_layout;
|
int64_t out_channel_layout;
|
||||||
double gain[MAX_CHANNELS][MAX_CHANNELS];
|
double gain[MAX_CHANNELS][MAX_CHANNELS];
|
||||||
int64_t need_renorm;
|
int64_t need_renorm;
|
||||||
@ -99,12 +101,12 @@ static void skip_spaces(char **arg)
|
|||||||
static av_cold int init(AVFilterContext *ctx, const char *args0)
|
static av_cold int init(AVFilterContext *ctx, const char *args0)
|
||||||
{
|
{
|
||||||
PanContext *const pan = ctx->priv;
|
PanContext *const pan = ctx->priv;
|
||||||
char *arg, *arg0, *tokenizer, *args = av_strdup(args0);
|
char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args);
|
||||||
int out_ch_id, in_ch_id, len, named, ret;
|
int out_ch_id, in_ch_id, len, named, ret;
|
||||||
int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels
|
int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels
|
||||||
double gain;
|
double gain;
|
||||||
|
|
||||||
if (!args0) {
|
if (!pan->args) {
|
||||||
av_log(ctx, AV_LOG_ERROR,
|
av_log(ctx, AV_LOG_ERROR,
|
||||||
"pan filter needs a channel layout and a set "
|
"pan filter needs a channel layout and a set "
|
||||||
"of channels definitions as parameter\n");
|
"of channels definitions as parameter\n");
|
||||||
@ -112,14 +114,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
|
|||||||
}
|
}
|
||||||
if (!args)
|
if (!args)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
arg = av_strtok(args, ":", &tokenizer);
|
arg = av_strtok(args, "|", &tokenizer);
|
||||||
ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
|
ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
|
pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
|
||||||
|
|
||||||
/* parse channel specifications */
|
/* parse channel specifications */
|
||||||
while ((arg = arg0 = av_strtok(NULL, ":", &tokenizer))) {
|
while ((arg = arg0 = av_strtok(NULL, "|", &tokenizer))) {
|
||||||
/* channel name */
|
/* channel name */
|
||||||
if (parse_channel_name(&arg, &out_ch_id, &named)) {
|
if (parse_channel_name(&arg, &out_ch_id, &named)) {
|
||||||
av_log(ctx, AV_LOG_ERROR,
|
av_log(ctx, AV_LOG_ERROR,
|
||||||
@ -379,6 +381,16 @@ static av_cold void uninit(AVFilterContext *ctx)
|
|||||||
swr_free(&pan->swr);
|
swr_free(&pan->swr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OFFSET(x) offsetof(PanContext, x)
|
||||||
|
|
||||||
|
static const AVOption pan_options[] = {
|
||||||
|
{ "args", NULL, OFFSET(args), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
AVFILTER_DEFINE_CLASS(pan);
|
||||||
|
|
||||||
|
|
||||||
static const AVFilterPad pan_inputs[] = {
|
static const AVFilterPad pan_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
@ -401,6 +413,7 @@ AVFilter avfilter_af_pan = {
|
|||||||
.name = "pan",
|
.name = "pan",
|
||||||
.description = NULL_IF_CONFIG_SMALL("Remix channels with coefficients (panning)."),
|
.description = NULL_IF_CONFIG_SMALL("Remix channels with coefficients (panning)."),
|
||||||
.priv_size = sizeof(PanContext),
|
.priv_size = sizeof(PanContext),
|
||||||
|
.priv_class = &pan_class,
|
||||||
.init = init,
|
.init = init,
|
||||||
.uninit = uninit,
|
.uninit = uninit,
|
||||||
.query_formats = query_formats,
|
.query_formats = query_formats,
|
||||||
|
@ -686,7 +686,6 @@ static const char *const filters_left_to_update[] = {
|
|||||||
#if FF_API_ACONVERT_FILTER
|
#if FF_API_ACONVERT_FILTER
|
||||||
"aconvert",
|
"aconvert",
|
||||||
#endif
|
#endif
|
||||||
"pan",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int filter_use_deprecated_init(const char *name)
|
static int filter_use_deprecated_init(const char *name)
|
||||||
@ -772,6 +771,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
|
|||||||
!strcmp(filter->filter->name, "frei0r") ||
|
!strcmp(filter->filter->name, "frei0r") ||
|
||||||
!strcmp(filter->filter->name, "frei0r_src") ||
|
!strcmp(filter->filter->name, "frei0r_src") ||
|
||||||
!strcmp(filter->filter->name, "ocv") ||
|
!strcmp(filter->filter->name, "ocv") ||
|
||||||
|
!strcmp(filter->filter->name, "pan") ||
|
||||||
!strcmp(filter->filter->name, "pp") ||
|
!strcmp(filter->filter->name, "pp") ||
|
||||||
!strcmp(filter->filter->name, "aevalsrc")) {
|
!strcmp(filter->filter->name, "aevalsrc")) {
|
||||||
/* a hack for compatibility with the old syntax
|
/* a hack for compatibility with the old syntax
|
||||||
|
Loading…
x
Reference in New Issue
Block a user