57 const LADSPA_Descriptor *
desc;
68 #define OFFSET(x) offsetof(LADSPAContext, x)
69 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
79 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
90 LADSPA_Data *values,
int print)
92 const LADSPA_PortRangeHint *
h = s->
desc->PortRangeHints + map[ctl];
94 av_log(ctx, level,
"c%i: %s [", ctl, s->
desc->PortNames[map[ctl]]);
96 if (LADSPA_IS_HINT_TOGGLED(h->HintDescriptor)) {
97 av_log(ctx, level,
"toggled (1 or 0)");
99 if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
100 av_log(ctx, level,
" (default %i)", (
int)values[ctl]);
102 if (LADSPA_IS_HINT_INTEGER(h->HintDescriptor)) {
103 av_log(ctx, level,
"<int>");
105 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
106 av_log(ctx, level,
", min: %i", (
int)h->LowerBound);
108 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
109 av_log(ctx, level,
", max: %i", (
int)h->UpperBound);
112 av_log(ctx, level,
" (value %d)", (
int)values[ctl]);
113 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
114 av_log(ctx, level,
" (default %d)", (
int)values[ctl]);
116 av_log(ctx, level,
"<float>");
118 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
119 av_log(ctx, level,
", min: %f", h->LowerBound);
121 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
122 av_log(ctx, level,
", max: %f", h->UpperBound);
125 av_log(ctx, level,
" (value %f)", values[ctl]);
126 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
127 av_log(ctx, level,
" (default %f)", values[ctl]);
130 if (LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor))
131 av_log(ctx, level,
", multiple of sample rate");
133 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
134 av_log(ctx, level,
", logarithmic scale");
137 av_log(ctx, level,
"]\n");
149 !(s->
desc->Properties & LADSPA_PROPERTY_INPLACE_BROKEN))) {
219 unsigned long *map, LADSPA_Data *values)
221 const LADSPA_PortRangeHint *
h = s->
desc->PortRangeHints + map[ctl];
222 const LADSPA_Data lower = h->LowerBound;
223 const LADSPA_Data upper = h->UpperBound;
225 if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
227 }
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
229 }
else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
231 }
else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
233 }
else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
235 }
else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
237 }
else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
238 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
239 values[ctl] = exp(log(lower) * 0.75 + log(upper) * 0.25);
241 values[ctl] = lower * 0.75 + upper * 0.25;
242 }
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
243 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
244 values[ctl] = exp(log(lower) * 0.5 + log(upper) * 0.5);
246 values[ctl] = lower * 0.5 + upper * 0.5;
247 }
else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
248 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
249 values[ctl] = exp(log(lower) * 0.25 + log(upper) * 0.75);
251 values[ctl] = lower * 0.25 + upper * 0.75;
280 if (s->
desc->activate)
321 unsigned long *nb_inputs,
unsigned long *nb_outputs)
323 LADSPA_PortDescriptor pd;
326 for (i = 0; i < desc->PortCount; i++) {
327 pd = desc->PortDescriptors[i];
329 if (LADSPA_IS_PORT_AUDIO(pd)) {
330 if (LADSPA_IS_PORT_INPUT(pd)) {
332 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
339 static void *
try_load(
const char *dir,
const char *soname)
345 ret = dlopen(path, RTLD_LOCAL|RTLD_NOW);
355 const char *label = s->
desc->Label;
356 LADSPA_PortRangeHint *
h = (LADSPA_PortRangeHint *)s->
desc->PortRangeHints +
365 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) &&
368 "%s: input control c%ld is below lower boundary of %0.4f.\n",
369 label, port, h->LowerBound);
373 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
374 value > h->UpperBound) {
376 "%s: input control c%ld is above upper boundary of %0.4f.\n",
377 label, port, h->UpperBound);
389 LADSPA_Descriptor_Function descriptor_fn;
390 const LADSPA_Descriptor *desc;
391 LADSPA_PortDescriptor pd;
393 char *p, *
arg, *saveptr =
NULL;
394 unsigned long nb_ports;
407 char *paths =
av_strdup(getenv(
"LADSPA_PATH"));
408 const char *separator =
":";
435 descriptor_fn = dlsym(s->
dl_handle,
"ladspa_descriptor");
436 if (!descriptor_fn) {
448 for (i = 0; desc = descriptor_fn(i); i++) {
462 desc = descriptor_fn(i);
468 if (desc->Label && !strcmp(desc->Label, s->
plugin))
474 nb_ports = desc->PortCount;
487 for (i = 0; i < nb_ports; i++) {
488 pd = desc->PortDescriptors[i];
490 if (LADSPA_IS_PORT_AUDIO(pd)) {
491 if (LADSPA_IS_PORT_INPUT(pd)) {
494 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
498 }
else if (LADSPA_IS_PORT_CONTROL(pd)) {
499 if (LADSPA_IS_PORT_INPUT(pd)) {
502 if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor))
508 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
519 "The '%s' plugin does not have any input controls.\n",
523 "The '%s' plugin has the following input controls:\n",
537 if (!(arg =
av_strtok(p,
"|", &saveptr)))
541 if (sscanf(arg,
"c%d=%f", &i, &val) != 2) {
649 if (s->
desc->deactivate)
651 if (s->
desc->cleanup)
672 char *res,
int res_len,
int flags)
677 if (sscanf(cmd,
"c%ld", &port) + sscanf(args,
"%f", &value) != 2)
697 .priv_class = &ladspa_class,
static void set_default_ctl_value(LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values)
const char const char void * val
static int request_frame(AVFilterLink *outlink)
This structure describes decoded (raw) audio or video data.
static int config_output(AVFilterLink *outlink)
static const AVFilterPad outputs[]
Main libavfilter public API header.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
enum AVMediaType type
AVFilterPad type.
static enum AVSampleFormat formats[]
struct AVFilterChannelLayouts * in_channel_layouts
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void count_ports(const LADSPA_Descriptor *desc, unsigned long *nb_inputs, unsigned long *nb_outputs)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
const OptionDef options[]
AVFILTER_DEFINE_CLASS(ladspa)
A filter pad used for either input or output.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
A link between two filters.
AVFilterPad * input_pads
array of input pads
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
const LADSPA_Descriptor * desc
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
struct AVFilterChannelLayouts * out_channel_layouts
static const int sample_rates[]
char * av_asprintf(const char *fmt,...)
audio channel layout utility functions
unsigned nb_inputs
number of input pads
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
static av_cold int init(AVFilterContext *ctx)
GLsizei GLboolean const GLfloat * value
static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
AVFilterContext * src
source filter
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static av_cold void uninit(AVFilterContext *ctx)
int format
agreed upon media format
A list of supported channel layouts.
static int config_input(AVFilterLink *inlink)
static void * try_load(const char *dir, const char *soname)
static const AVOption ladspa_options[]
#define AV_LOG_INFO
Standard information.
unsigned long nb_outputcontrols
AVSampleFormat
Audio sample formats.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
char * av_strdup(const char *s)
Duplicate the string s.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
static const AVFilterPad inputs[]
rational number numerator/denominator
static int query_formats(AVFilterContext *ctx)
const char * name
Filter name.
static int connect_ports(AVFilterContext *ctx, AVFilterLink *link)
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
static void print_ctl_info(AVFilterContext *ctx, int level, LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values, int print)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
int channels
Number of channels.
AVFilterContext * dst
dest filter
static const AVFilterPad ladspa_outputs[]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static enum AVSampleFormat sample_fmts[]
int(* config_props)(AVFilterLink *link)
Link configuration callback.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
#define AVERROR_EXTERNAL
Generic error in an external library.
unsigned long nb_inputcontrols
int nb_samples
number of audio samples (per channel) described by this frame
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.