Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
On 2/16/2022 3:15 PM, Anton Khirnov wrote: diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index b89a680883..3ebd279df7 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -189,23 +189,24 @@ static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx) { AVCodecParameters *dec_par = st->st->codecpar; char buf[256]; -int64_t chl = av_get_default_channel_layout(dec_par->channels); +AVChannelLayout chl = { 0 }; -if (!chl) { +av_channel_layout_default(, dec_par->ch_layout.nb_channels); + +if (!KNOWN()) { av_log(log_ctx, AV_LOG_ERROR, "Channel layout is not set in stream %d, and could not " "be guessed from the number of channels (%d)\n", - st_index, dec_par->channels); + st_index, dec_par->ch_layout.nb_channels); return AVERROR(EINVAL); Should this still be an error? Unspec layouts should now be properly supported by (almost?) everything. Probably, but making it no longer abort if a native channel layout can't be guessed is a behavior change that I'd rather leave for a different patch, if you don't mind. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
Quoting James Almer (2022-01-13 03:09:07) > diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c > index 1a2519dd32..31453823c5 100644 > --- a/libavfilter/af_channelsplit.c > +++ b/libavfilter/af_channelsplit.c > @@ -36,7 +36,7 @@ > typedef struct ChannelSplitContext { > const AVClass *class; > > -uint64_t channel_layout; > +AVChannelLayout channel_layout; > char*channel_layout_str; > char*channels_str; > > @@ -57,11 +57,11 @@ AVFILTER_DEFINE_CLASS(channelsplit); > static av_cold int init(AVFilterContext *ctx) > { > ChannelSplitContext *s = ctx->priv; > -uint64_t channel_layout; > +AVChannelLayout channel_layout = { 0 }; > int nb_channels; > int all = 0, ret = 0, i; > > -if (!(s->channel_layout = av_get_channel_layout(s->channel_layout_str))) > { > +if ((ret = av_channel_layout_from_string(>channel_layout, > s->channel_layout_str)) < 0) { > av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n", > s->channel_layout_str); > ret = AVERROR(EINVAL); > @@ -70,27 +70,32 @@ static av_cold int init(AVFilterContext *ctx) > > > if (!strcmp(s->channels_str, "all")) { > -nb_channels = av_get_channel_layout_nb_channels(s->channel_layout); > +nb_channels = s->channel_layout.nb_channels; > channel_layout = s->channel_layout; > all = 1; > } else { > -if ((ret = av_get_extended_channel_layout(s->channels_str, > _layout, _channels)) < 0) > +if ((ret = av_channel_layout_from_string(_layout, > s->channels_str)) < 0) > return ret; > } > > for (i = 0; i < nb_channels; i++) { > -uint64_t channel = av_channel_layout_extract_channel(channel_layout, > i); > -AVFilterPad pad = { 0 }; > +int channel = av_channel_layout_channel_from_index(_layout, > i); > +char buf[64]; > +AVFilterPad pad = { .flags = AVFILTERPAD_FLAG_FREE_NAME }; > > +av_channel_name(buf, sizeof(buf), channel); > pad.type = AVMEDIA_TYPE_AUDIO; > -pad.name = av_get_channel_name(channel); > +pad.name = av_strdup(buf); > +if (!pad.name) > +return AVERROR(ENOMEM); > > if (all) { > s->map[i] = i; Should either make map dynamically allocated or check that there are fewer than 64 channels in the layout. > } else { > -if ((ret = > av_get_channel_layout_channel_index(s->channel_layout, channel)) < 0) { > +if ((ret = > av_channel_layout_index_from_channel(>channel_layout, channel)) < 0) { > av_log(ctx, AV_LOG_ERROR, "Channel name '%s' not present in > channel layout '%s'.\n", > - av_get_channel_name(channel), s->channel_layout_str); > + pad.name, s->channel_layout_str); > +av_freep(); > return ret; > } > > @@ -115,15 +120,18 @@ static int query_formats(AVFilterContext *ctx) > (ret = ff_set_common_all_samplerates(ctx)) < 0) > return ret; > > -if ((ret = ff_add_channel_layout(_layouts, s->channel_layout)) < 0 || > +if ((ret = ff_add_channel_layout(_layouts, >channel_layout)) < 0 || > (ret = ff_channel_layouts_ref(in_layouts, > >inputs[0]->outcfg.channel_layouts)) < 0) > return ret; > > for (i = 0; i < ctx->nb_outputs; i++) { > +AVChannelLayout channel_layout = { 0 }; > AVFilterChannelLayouts *out_layouts = NULL; > -uint64_t channel = > av_channel_layout_extract_channel(s->channel_layout, s->map[i]); > +int channel = > av_channel_layout_channel_from_index(>channel_layout, s->map[i]); > > -if ((ret = ff_add_channel_layout(_layouts, channel)) < 0 || > +if ((channel < 0) || > +(ret = av_channel_layout_from_mask(_layout, 1ULL << > channel)) < 0 || > +(ret = ff_add_channel_layout(_layouts, _layout)) < 0 > || > (ret = ff_channel_layouts_ref(out_layouts, > >outputs[i]->incfg.channel_layouts)) < 0) > return ret; > } > @@ -139,6 +147,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *buf) > > for (i = 0; i < ctx->nb_outputs; i++) { > AVFrame *buf_out = av_frame_clone(buf); > +int channel = av_channel_layout_channel_from_index(>ch_layout, > s->map[i]); > > if (!buf_out) { > ret = AVERROR(ENOMEM); > @@ -146,9 +155,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *buf) > } > > buf_out->data[0] = buf_out->extended_data[0] = > buf_out->extended_data[s->map[i]]; > +ret = av_channel_layout_from_mask(_out->ch_layout, 1ULL << > channel); potential invalid shift? > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 7362bcdab5..acb2d7db51 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -204,6 +204,7
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
On 2/15/2022 8:50 AM, Anton Khirnov wrote: Quoting James Almer (2022-01-13 03:09:07) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index ed3c75311a..96704e041c 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -104,9 +104,36 @@ static av_cold int init(AVFilterContext *ctx) ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, get_sample_rate, 0, "sample rate"); -PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, - ff_add_channel_layout, av_get_channel_layout, 0, - "channel layout"); +{ +AVChannelLayout fmt = { 0 }; +const char *cur = s->channel_layouts_str; +int ret; + +if (s->channel_layouts_str && strchr(s->channel_layouts_str, ',')) { +av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to " + "separate channel layout.\n"); It might be unclear to the user what "this syntax" refers to, maybe make it "Using ',' to separate channel layouts is deprecated" This is copy-paste from the PARSE_FORMATS() macro. I'd rather leave changing it to a separate commit, and do it for sample rate and sample format too. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
Quoting James Almer (2022-02-15 13:27:37) > On 2/15/2022 8:50 AM, Anton Khirnov wrote: > > Quoting James Almer (2022-01-13 03:09:07) > >> @@ -212,31 +212,31 @@ static int config_input(AVFilterLink *inlink) > >> return AVERROR(ENOMEM); > >> for (ch = 0; ch < s->nb_in_channels; ch++) > >> s->input_levels[ch] = s->level_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_FRONT_CENTER); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_FRONT_CENTER); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->fc_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_FRONT_LEFT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_FRONT_LEFT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->fl_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_FRONT_RIGHT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_FRONT_RIGHT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->fr_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_SIDE_LEFT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_SIDE_LEFT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->sl_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_SIDE_RIGHT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_SIDE_RIGHT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->sr_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_BACK_LEFT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_BACK_LEFT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->bl_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_BACK_RIGHT); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_BACK_RIGHT); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->br_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_BACK_CENTER); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_BACK_CENTER); > >> if (ch >= 0) > >> s->input_levels[ch] *= s->bc_in; > >> -ch = av_get_channel_layout_channel_index(inlink->channel_layout, > >> AV_CH_LOW_FREQUENCY); > >> +ch = av_channel_layout_index_from_channel(>ch_layout, > >> AV_CHAN_LOW_FREQUENCY); > >> if (ch >= 0) > > > > Make all those compare to AV_CHAN_NONE > > ch is an index, so either >= 0, or EINVAL. right, nevermind then -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
On 2/15/2022 8:50 AM, Anton Khirnov wrote: Quoting James Almer (2022-01-13 03:09:07) @@ -212,31 +212,31 @@ static int config_input(AVFilterLink *inlink) return AVERROR(ENOMEM); for (ch = 0; ch < s->nb_in_channels; ch++) s->input_levels[ch] = s->level_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_FRONT_CENTER); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_FRONT_CENTER); if (ch >= 0) s->input_levels[ch] *= s->fc_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_FRONT_LEFT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_FRONT_LEFT); if (ch >= 0) s->input_levels[ch] *= s->fl_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_FRONT_RIGHT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_FRONT_RIGHT); if (ch >= 0) s->input_levels[ch] *= s->fr_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_SIDE_LEFT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_SIDE_LEFT); if (ch >= 0) s->input_levels[ch] *= s->sl_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_SIDE_RIGHT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_SIDE_RIGHT); if (ch >= 0) s->input_levels[ch] *= s->sr_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_BACK_LEFT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_BACK_LEFT); if (ch >= 0) s->input_levels[ch] *= s->bl_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_BACK_RIGHT); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_BACK_RIGHT); if (ch >= 0) s->input_levels[ch] *= s->br_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_BACK_CENTER); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_BACK_CENTER); if (ch >= 0) s->input_levels[ch] *= s->bc_in; -ch = av_get_channel_layout_channel_index(inlink->channel_layout, AV_CH_LOW_FREQUENCY); +ch = av_channel_layout_index_from_channel(>ch_layout, AV_CHAN_LOW_FREQUENCY); if (ch >= 0) Make all those compare to AV_CHAN_NONE ch is an index, so either >= 0, or EINVAL. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
Quoting James Almer (2022-01-13 03:09:07) > diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c > index ed3c75311a..96704e041c 100644 > --- a/libavfilter/af_aformat.c > +++ b/libavfilter/af_aformat.c > @@ -104,9 +104,36 @@ static av_cold int init(AVFilterContext *ctx) >ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, > "sample format"); > PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, >get_sample_rate, 0, "sample rate"); > -PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, > - ff_add_channel_layout, av_get_channel_layout, 0, > - "channel layout"); > +{ > +AVChannelLayout fmt = { 0 }; > +const char *cur = s->channel_layouts_str; > +int ret; > + > +if (s->channel_layouts_str && strchr(s->channel_layouts_str, ',')) { > +av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' > to " > + "separate channel layout.\n"); It might be unclear to the user what "this syntax" refers to, maybe make it "Using ',' to separate channel layouts is deprecated" > diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c > index ee42b2a034..2a0747a037 100644 > --- a/libavfilter/af_biquads.c > +++ b/libavfilter/af_biquads.c > @@ -125,7 +125,7 @@ typedef struct BiquadsContext { > double frequency; > double width; > double mix; > -uint64_t channels; > +AVChannelLayout ch_layout; > int normalize; > int order; > > @@ -716,11 +716,11 @@ static int config_filter(AVFilterLink *outlink, int > reset) > s->b2 *= factor; > } > > -s->cache = av_realloc_f(s->cache, sizeof(ChanCache), inlink->channels); > +s->cache = av_realloc_f(s->cache, sizeof(ChanCache), > inlink->ch_layout.nb_channels); > if (!s->cache) > return AVERROR(ENOMEM); > if (reset) > -memset(s->cache, 0, sizeof(ChanCache) * inlink->channels); > +memset(s->cache, 0, sizeof(ChanCache) * > inlink->ch_layout.nb_channels); > > switch (s->transform_type) { > case DI: > @@ -838,12 +838,14 @@ static int filter_channel(AVFilterContext *ctx, void > *arg, int jobnr, int nb_job > AVFrame *buf = td->in; > AVFrame *out_buf = td->out; > BiquadsContext *s = ctx->priv; > -const int start = (buf->channels * jobnr) / nb_jobs; > -const int end = (buf->channels * (jobnr+1)) / nb_jobs; > +const int start = (buf->ch_layout.nb_channels * jobnr) / nb_jobs; > +const int end = (buf->ch_layout.nb_channels * (jobnr+1)) / nb_jobs; > int ch; > > for (ch = start; ch < end; ch++) { > -if (!((av_channel_layout_extract_channel(inlink->channel_layout, ch) > & s->channels))) { > +if (!(av_channel_layout_channel_from_index(>ch_layout, ch) > >= 0 && > + av_channel_layout_channel_from_index(>ch_layout, ch) >= 0)) > { This doesn't look right. The original code tests whether the channel with index ch in inlink->channel_layout is present in s->channels. The new code tests whether the channel with index ch exists in both inlink->ch_layout and s->ch_layout (the test is also broken, because it should compare against AV_CHAN_NONE). Same applies to af_speechnorm > diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c > index b2030d..2fe36368c1 100644 > --- a/libavfilter/af_headphone.c > +++ b/libavfilter/af_headphone.c > @@ -85,13 +85,13 @@ typedef struct HeadphoneContext { > uint64_t mapping[64]; > } HeadphoneContext; > > -static int parse_channel_name(const char *arg, uint64_t *rchannel) > +static int parse_channel_name(const char *arg, int *rchannel) enum AVChannel everywhere? > { > -uint64_t layout = av_get_channel_layout(arg); > +int channel = av_channel_from_string(arg); > > -if (av_get_channel_layout_nb_channels(layout) != 1) > +if (channel < 0) > return AVERROR(EINVAL); > -*rchannel = layout; > +*rchannel = channel; > return 0; > } > > @@ -103,14 +103,14 @@ static void parse_map(AVFilterContext *ctx) > > p = s->map; > while ((arg = av_strtok(p, "|", ))) { > -uint64_t out_channel; > +int out_channel; > > p = NULL; > if (parse_channel_name(arg, _channel)) { > av_log(ctx, AV_LOG_WARNING, "Failed to parse \'%s\' as channel > name.\n", arg); > continue; > } > -if (used_channels & out_channel) { > +if (used_channels & (1ULL << out_channel)) { should check that out_channel < 64 > diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c > index ccd85148e9..71d713e4ed 100644 > --- a/libavfilter/af_surround.c > +++ b/libavfilter/af_surround.c > @@ -92,8 +92,8 @@ typedef struct AudioSurroundContext { > float lowcut; > float highcut; > > -uint64_t out_channel_layout; > -uint64_t in_channel_layout; > +
Re: [FFmpeg-devel] [PATCH 275/281] avfilter: convert to new channel layout API
Quoting James Almer (2022-01-13 03:09:07) > diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c > index c2a8de0e0b..c3ca752035 100644 > --- a/libavfilter/af_apulsator.c > +++ b/libavfilter/af_apulsator.c > @@ -192,7 +192,7 @@ static int query_formats(AVFilterContext *ctx) > > if ((ret = ff_add_format (, AV_SAMPLE_FMT_DBL > )) < 0 || > (ret = ff_set_common_formats (ctx , formats > )) < 0 || > -(ret = ff_add_channel_layout ( , > AV_CH_LAYOUT_STEREO)) < 0 || > +(ret = ff_add_channel_layout ( , > &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) < 0 || completion fail? > diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c > index 20b717bdf8..246ddeffb9 100644 > --- a/libavfilter/af_sofalizer.c > +++ b/libavfilter/af_sofalizer.c > @@ -187,25 +187,15 @@ static int preload_sofa(AVFilterContext *ctx, char > *filename, int *samplingrate) > > static int parse_channel_name(AVFilterContext *ctx, char **arg, int > *rchannel) > { > -int len, i, channel_id = 0; > -int64_t layout, layout0; > +int len, channel_id = 0; > char buf[8] = {0}; > > /* try to parse a channel name, e.g. "FL" */ > if (av_sscanf(*arg, "%7[A-Z]%n", buf, )) { > -layout0 = layout = av_get_channel_layout(buf); > -/* channel_id <- first set bit in layout */ > -for (i = 32; i > 0; i >>= 1) { > -if (layout >= 1LL << i) { > -channel_id += i; > -layout >>= i; > -} > -} > -/* reject layouts that are not a single channel */ > -if (channel_id >= 64 || layout0 != 1LL << channel_id) { You should keep the range check, because the id gets used as index into vspkrpos[64]. > -av_log(ctx, AV_LOG_WARNING, "Failed to parse \'%s\' as channel > name.\n", buf); > -return AVERROR(EINVAL); > -} > +channel_id = av_channel_from_string(buf); > +if (channel_id < 0) > +return channel_id; > + > *rchannel = channel_id; > *arg += len; > return 0; > @@ -221,7 +211,7 @@ static int parse_channel_name(AVFilterContext *ctx, char > **arg, int *rchannel) > return AVERROR(EINVAL); > } > > -static void parse_speaker_pos(AVFilterContext *ctx, int64_t > in_channel_layout) > +static void parse_speaker_pos(AVFilterContext *ctx) > { > SOFAlizerContext *s = ctx->priv; > char *arg, *tokenizer, *p, *args = av_strdup(s->speakers_pos); > @@ -256,10 +246,10 @@ static int get_speaker_pos(AVFilterContext *ctx, > float *speaker_azim, float *speaker_elev) > { > struct SOFAlizerContext *s = ctx->priv; > -uint64_t channels_layout = ctx->inputs[0]->channel_layout; > +AVChannelLayout *channel_layout = >inputs[0]->ch_layout; > float azim[64] = { 0 }; > float elev[64] = { 0 }; > -int m, ch, n_conv = ctx->inputs[0]->channels; /* get no. input channels > */ > +int m, ch, n_conv = ctx->inputs[0]->ch_layout.nb_channels; /* get no. > input channels */ > > if (n_conv < 0 || n_conv > 64) > return AVERROR(EINVAL); > @@ -267,45 +257,45 @@ static int get_speaker_pos(AVFilterContext *ctx, > s->lfe_channel = -1; > > if (s->speakers_pos) > -parse_speaker_pos(ctx, channels_layout); > +parse_speaker_pos(ctx); > > /* set speaker positions according to input channel configuration: */ > for (m = 0, ch = 0; ch < n_conv && m < 64; m++) { > -uint64_t mask = channels_layout & (1ULL << m); > - > -switch (mask) { > -case AV_CH_FRONT_LEFT:azim[ch] = 30; break; > -case AV_CH_FRONT_RIGHT: azim[ch] = 330; break; > -case AV_CH_FRONT_CENTER: azim[ch] = 0; break; > -case AV_CH_LOW_FREQUENCY: > -case AV_CH_LOW_FREQUENCY_2: s->lfe_channel = ch; break; > -case AV_CH_BACK_LEFT: azim[ch] = 150; break; > -case AV_CH_BACK_RIGHT:azim[ch] = 210; break; > -case AV_CH_BACK_CENTER: azim[ch] = 180; break; > -case AV_CH_SIDE_LEFT: azim[ch] = 90; break; > -case AV_CH_SIDE_RIGHT:azim[ch] = 270; break; > -case AV_CH_FRONT_LEFT_OF_CENTER: azim[ch] = 15; break; > -case AV_CH_FRONT_RIGHT_OF_CENTER: azim[ch] = 345; break; > -case AV_CH_TOP_CENTER:azim[ch] = 0; > +int chan = av_channel_layout_channel_from_index(channel_layout, m); > + > +switch (chan) { > +case AV_CHAN_FRONT_LEFT: azim[ch] = 30; break; > +case AV_CHAN_FRONT_RIGHT: azim[ch] = 330; break; > +case AV_CHAN_FRONT_CENTER:azim[ch] = 0; break; > +case AV_CHAN_LOW_FREQUENCY: > +case AV_CHAN_LOW_FREQUENCY_2: s->lfe_channel = ch; break; > +