27 #include <lilv/lilv.h> 28 #include <lv2/lv2plug.in/ns/ext/atom/atom.h> 29 #include <lv2/lv2plug.in/ns/ext/buf-size/buf-size.h> 67 LV2_Atom_Sequence seq_in[2];
69 const LV2_Feature *features[5];
91 #define OFFSET(x) offsetof(LV2Context, x) 92 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM 101 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
102 {
"n",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
120 for (i = 0; i < table->
n_uris; i++) {
130 const size_t len = strlen(uri);
134 for (i = 0; i < table->
n_uris; i++) {
135 if (!strcmp(table->
uris[i], uri)) {
143 memcpy(tmp, table->
uris, table->
n_uris *
sizeof(
char**));
151 memcpy(table->
uris[table->
n_uris], uri, len + 1);
161 if (urid > 0 && urid <= table->
n_uris) {
162 return table->
uris[urid - 1];
170 int ich = 0, och = 0, i;
173 const LilvPort *port = lilv_plugin_get_port_by_index(s->
plugin, i);
195 s->
seq_in[0].atom.size =
sizeof(LV2_Atom_Sequence_Body);
259 { LV2_BUF_SIZE__powerOf2BlockLength,
NULL },
260 { LV2_BUF_SIZE__fixedBlockLength, NULL },
261 { LV2_BUF_SIZE__boundedBlockLength, NULL },
268 char *p, *
arg, *saveptr =
NULL;
322 "The '%s' plugin does not have any input controls.\n",
326 "The '%s' plugin has the following input controls:\n",
329 const LilvPort *port = lilv_plugin_get_port_by_index(s->
plugin, i);
330 const LilvNode *symbol = lilv_port_get_symbol(s->
plugin, port);
331 LilvNode *
name = lilv_port_get_name(s->
plugin, port);
337 lilv_node_as_string(name));
340 lilv_node_free(name);
348 const LilvPort *port;
354 if (!(arg =
av_strtok(p,
" |", &saveptr)))
358 vstr = strstr(arg,
"=");
367 sym = lilv_new_string(s->
world, str);
368 port = lilv_plugin_get_port_by_symbol(s->
plugin, sym);
373 index = lilv_port_get_index(s->
plugin, port);
393 const LilvPlugins *plugins;
394 const LilvPlugin *plugin;
399 s->
world = lilv_world_new();
409 lilv_world_load_all(s->
world);
410 plugins = lilv_world_get_all_plugins(s->
world);
411 plugin = lilv_plugins_get_by_uri(plugins, uri);
435 const LilvPort *lport = lilv_plugin_get_port_by_index(s->
plugin, i);
571 lilv_world_free(s->
world);
595 .priv_class = &lv2_class,
static void connect_ports(LV2Context *s, AVFrame *in, AVFrame *out)
const char const char void * val
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
int max_samples
Maximum number of samples to filter at once.
LilvNode * lv2_ControlPort
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static int query_formats(AVFilterContext *ctx)
enum AVMediaType type
AVFilterPad type.
#define AV_CH_LAYOUT_STEREO
struct AVFilterChannelLayouts * in_channel_layouts
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
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 const AVOption lv2_options[]
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad lv2_outputs[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
const LV2_Feature * features[5]
#define AVERROR_EOF
End of file.
A filter pad used for either input or output.
A link between two filters.
static void uri_table_init(URITable *table)
AVFilterPad * input_pads
array of input pads
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int min_samples
Minimum number of samples to filter at once.
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.
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
LilvNode * fixedBlockLength
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
static int request_frame(AVFilterLink *outlink)
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.
LilvNode * boundedBlockLength
AVFilterContext * src
source filter
int partial_buf_size
Size of the partial buffer to allocate.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static const AVFilterPad inputs[]
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
unsigned nb_inputcontrols
#define AV_LOG_INFO
Standard information.
AVSampleFormat
Audio sample formats.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
LV2_Atom_Sequence * seq_out
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static void uri_table_destroy(URITable *table)
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
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()...
LV2_Atom_Sequence seq_in[2]
const OptionDef options[]
static int config_output(AVFilterLink *outlink)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static const LV2_Feature buf_size_features[3]
int channels
Number of channels.
LilvNode * powerOf2BlockLength
const LilvPlugin * plugin
AVFilterContext * dst
dest filter
AVFILTER_DEFINE_CLASS(lv2)
LilvNode * lv2_OutputPort
static enum AVSampleFormat sample_fmts[]
LV2_Feature unmap_feature
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.
static const char * uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
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 av_cold int init(AVFilterContext *ctx)
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.