diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-09-05 11:03:24 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-09-09 17:26:18 +0200 |
commit | b38f4e7f865df63610987e5dd78ccbda9a5dc01a (patch) | |
tree | 3a00050796c0ada5f51b68a939fb9b957abc5612 | |
parent | d0f4c08207e35bc42801550259286f959002395c (diff) | |
download | ffmpeg-b38f4e7f865df63610987e5dd78ccbda9a5dc01a.tar.gz |
lavfi/af_pan: stop modifying private data in query_formats()
It is not supposed to have any side effects, and the modification in
question can just as well be done in filter init.
-rw-r--r-- | libavfilter/af_pan.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index 02a899b88e..f2f6daa658 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -91,6 +91,28 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed) return AVERROR(EINVAL); } +static int are_gains_pure(const PanContext *pan) +{ + int i, j; + + for (i = 0; i < MAX_CHANNELS; i++) { + int nb_gain = 0; + + for (j = 0; j < MAX_CHANNELS; j++) { + double gain = pan->gain[i][j]; + + /* channel mapping is effective only if 0% or 100% of a channel is + * selected... */ + if (gain != 0. && gain != 1.) + return 0; + /* ...and if the output channel is only composed of one input */ + if (gain && nb_gain++) + return 0; + } + } + return 1; +} + static av_cold int init(AVFilterContext *ctx) { PanContext *const pan = ctx->priv; @@ -213,6 +235,7 @@ static av_cold int init(AVFilterContext *ctx) } } pan->need_renumber = !!nb_in_channels[1]; + pan->pure_gains = are_gains_pure(pan); ret = 0; fail: @@ -220,37 +243,14 @@ fail: return ret; } -static int are_gains_pure(const PanContext *pan) -{ - int i, j; - - for (i = 0; i < MAX_CHANNELS; i++) { - int nb_gain = 0; - - for (j = 0; j < MAX_CHANNELS; j++) { - double gain = pan->gain[i][j]; - - /* channel mapping is effective only if 0% or 100% of a channel is - * selected... */ - if (gain != 0. && gain != 1.) - return 0; - /* ...and if the output channel is only composed of one input */ - if (gain && nb_gain++) - return 0; - } - } - return 1; -} - static int query_formats(AVFilterContext *ctx) { - PanContext *pan = ctx->priv; + const PanContext *pan = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; AVFilterChannelLayouts *layouts; int ret; - pan->pure_gains = are_gains_pure(pan); /* libswr supports any sample and packing formats */ if ((ret = ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO))) < 0) return ret; |