summaryrefslogtreecommitdiff
path: root/libavfilter/af_headphone.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/af_headphone.c')
-rw-r--r--libavfilter/af_headphone.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
index aea861aa04..edaae62172 100644
--- a/libavfilter/af_headphone.c
+++ b/libavfilter/af_headphone.c
@@ -82,18 +82,18 @@ typedef struct HeadphoneContext {
int ir_len;
int eof;
} hrir_in[64];
- uint64_t map_channel_layout;
- uint64_t mapping[64];
+ AVChannelLayout map_channel_layout;
+ enum AVChannel mapping[64];
uint8_t hrir_map[64];
} HeadphoneContext;
-static int parse_channel_name(const char *arg, uint64_t *rchannel)
+static int parse_channel_name(const char *arg, enum AVChannel *rchannel)
{
- 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 || channel >= 64)
return AVERROR(EINVAL);
- *rchannel = layout;
+ *rchannel = channel;
return 0;
}
@@ -105,22 +105,22 @@ static void parse_map(AVFilterContext *ctx)
p = s->map;
while ((arg = av_strtok(p, "|", &tokenizer))) {
- uint64_t out_channel;
+ enum AVChannel out_channel;
p = NULL;
if (parse_channel_name(arg, &out_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)) {
av_log(ctx, AV_LOG_WARNING, "Ignoring duplicate channel '%s'.\n", arg);
continue;
}
- used_channels |= out_channel;
+ used_channels |= (1ULL << out_channel);
s->mapping[s->nb_irs] = out_channel;
s->nb_irs++;
}
- s->map_channel_layout = used_channels;
+ av_channel_layout_from_mask(&s->map_channel_layout, used_channels);
if (s->hrir_fmt == HRIR_MULTI)
s->nb_hrir_inputs = 1;
@@ -155,7 +155,7 @@ static int headphone_convolute(AVFilterContext *ctx, void *arg, int jobnr, int n
const int air_len = s->air_len;
const float *src = (const float *)in->data[0];
float *dst = (float *)out->data[0];
- const int in_channels = in->channels;
+ const int in_channels = in->ch_layout.nb_channels;
const int buffer_length = s->buffer_length;
const uint32_t modulo = (uint32_t)buffer_length - 1;
float *buffer[64];
@@ -224,7 +224,7 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
const int ir_len = s->ir_len;
const float *src = (const float *)in->data[0];
float *dst = (float *)out->data[0];
- const int in_channels = in->channels;
+ const int in_channels = in->ch_layout.nb_channels;
const int buffer_length = s->buffer_length;
const uint32_t modulo = (uint32_t)buffer_length - 1;
AVComplexFloat *fft_out = s->out_fft[jobnr];
@@ -363,8 +363,8 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
{
struct HeadphoneContext *s = ctx->priv;
const int ir_len = s->ir_len;
- int nb_input_channels = ctx->inputs[0]->channels;
- const int nb_hrir_channels = s->nb_hrir_inputs == 1 ? ctx->inputs[1]->channels : s->nb_hrir_inputs * 2;
+ int nb_input_channels = ctx->inputs[0]->ch_layout.nb_channels;
+ const int nb_hrir_channels = s->nb_hrir_inputs == 1 ? ctx->inputs[1]->ch_layout.nb_channels : s->nb_hrir_inputs * 2;
float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10);
AVFrame *frame;
int ret = 0;
@@ -455,7 +455,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
ptr = (float *)frame->extended_data[0];
if (s->hrir_fmt == HRIR_STEREO) {
- int idx = av_get_channel_layout_channel_index(s->map_channel_layout,
+ int idx = av_channel_layout_index_from_channel(&s->map_channel_layout,
s->mapping[i]);
if (idx < 0)
continue;
@@ -484,10 +484,10 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
s->tx_fn[0](s->fft[0], fft_out_r, fft_in_r, sizeof(float));
}
} else {
- int I, N = ctx->inputs[1]->channels;
+ int I, N = ctx->inputs[1]->ch_layout.nb_channels;
for (k = 0; k < N / 2; k++) {
- int idx = av_get_channel_layout_channel_index(inlink->channel_layout,
+ int idx = av_channel_layout_index_from_channel(&inlink->ch_layout,
s->mapping[k]);
if (idx < 0)
continue;
@@ -609,7 +609,7 @@ static int query_formats(AVFilterContext *ctx)
if (ret)
return ret;
- ret = ff_add_channel_layout(&stereo_layout, AV_CH_LAYOUT_STEREO);
+ ret = ff_add_channel_layout(&stereo_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
if (ret)
return ret;
ret = ff_channel_layouts_ref(stereo_layout, &ctx->outputs[0]->incfg.channel_layouts);
@@ -639,13 +639,13 @@ static int config_input(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->dst;
HeadphoneContext *s = ctx->priv;
- if (s->nb_irs < inlink->channels) {
- av_log(ctx, AV_LOG_ERROR, "Number of HRIRs must be >= %d.\n", inlink->channels);
+ if (s->nb_irs < inlink->ch_layout.nb_channels) {
+ av_log(ctx, AV_LOG_ERROR, "Number of HRIRs must be >= %d.\n", inlink->ch_layout.nb_channels);
return AVERROR(EINVAL);
}
- s->lfe_channel = av_get_channel_layout_channel_index(inlink->channel_layout,
- AV_CH_LOW_FREQUENCY);
+ s->lfe_channel = av_channel_layout_index_from_channel(&inlink->ch_layout,
+ AV_CHAN_LOW_FREQUENCY);
return 0;
}
@@ -701,13 +701,13 @@ static int config_output(AVFilterLink *outlink)
if (s->hrir_fmt == HRIR_MULTI) {
AVFilterLink *hrir_link = ctx->inputs[1];
- if (hrir_link->channels < inlink->channels * 2) {
- av_log(ctx, AV_LOG_ERROR, "Number of channels in HRIR stream must be >= %d.\n", inlink->channels * 2);
+ if (hrir_link->ch_layout.nb_channels < inlink->ch_layout.nb_channels * 2) {
+ av_log(ctx, AV_LOG_ERROR, "Number of channels in HRIR stream must be >= %d.\n", inlink->ch_layout.nb_channels * 2);
return AVERROR(EINVAL);
}
}
- s->gain_lfe = expf((s->gain - 3 * inlink->channels + s->lfe_gain) / 20 * M_LN10);
+ s->gain_lfe = expf((s->gain - 3 * inlink->ch_layout.nb_channels + s->lfe_gain) / 20 * M_LN10);
return 0;
}