#include <ctype.h>
-#include "libavutil/audioconvert.h"
#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
ChannelMapContext *s = ctx->priv;
int ret;
char *mapping;
- enum mode;
int map_entries = 0;
char buf[256];
enum MappingMode mode;
} else {
char *dash = strchr(mapping, '-');
if (!dash) { // short mapping
- if (isdigit(*mapping))
+ if (av_isdigit(*mapping))
mode = MAP_ONE_INT;
else
mode = MAP_ONE_STR;
- } else if (isdigit(*mapping)) {
- if (isdigit(*(dash+1)))
+ } else if (av_isdigit(*mapping)) {
+ if (av_isdigit(*(dash+1)))
mode = MAP_PAIR_INT_INT;
else
mode = MAP_PAIR_INT_STR;
} else {
- if (isdigit(*(dash+1)))
+ if (av_isdigit(*(dash+1)))
mode = MAP_PAIR_STR_INT;
else
mode = MAP_PAIR_STR_STR;
return 0;
}
-static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
+static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
uint8_t **new_extended_data =
av_mallocz(nch_out * sizeof(*buf->extended_data));
if (!new_extended_data) {
- avfilter_unref_buffer(buf);
+ av_frame_free(&buf);
return AVERROR(ENOMEM);
}
if (buf->extended_data == buf->data) {
memcpy(buf->data, buf->extended_data,
FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
- return ff_filter_samples(outlink, buf);
+ return ff_filter_frame(outlink, buf);
}
static int channelmap_config_input(AVFilterLink *inlink)
return err;
}
+static const AVFilterPad avfilter_af_channelmap_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .filter_frame = channelmap_filter_frame,
+ .config_props = channelmap_config_input
+ },
+ { NULL }
+};
+
+static const AVFilterPad avfilter_af_channelmap_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO
+ },
+ { NULL }
+};
+
AVFilter avfilter_af_channelmap = {
.name = "channelmap",
.description = NULL_IF_CONFIG_SMALL("Remap audio channels."),
.query_formats = channelmap_query_formats,
.priv_size = sizeof(ChannelMapContext),
- .inputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_AUDIO,
- .filter_samples = channelmap_filter_samples,
- .config_props = channelmap_config_input },
- { .name = NULL }},
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_AUDIO },
- { .name = NULL }},
+ .inputs = avfilter_af_channelmap_inputs,
+ .outputs = avfilter_af_channelmap_outputs,
};