Go to the documentation of this file.
51 typedef void (*
f0r_update_f)(f0r_instance_t instance,
double time,
const uint32_t *inframe, uint32_t *outframe);
52 typedef void (*
f0r_update2_f)(f0r_instance_t instance,
double time,
const uint32_t *inframe1,
const uint32_t *inframe2,
const uint32_t *inframe3, uint32_t *outframe);
83 void *sym = dlsym(
s->dl_handle, sym_name);
94 f0r_param_color_t col;
95 f0r_param_position_t pos;
103 if (!strcmp(param,
"y"))
val.d = 1.0;
104 else if (!strcmp(param,
"n"))
val.d = 0.0;
108 case F0R_PARAM_DOUBLE:
110 if (*tail ||
val.d == HUGE_VAL)
114 case F0R_PARAM_COLOR:
115 if (sscanf(param,
"%f/%f/%f", &
val.col.r, &
val.col.g, &
val.col.b) != 3) {
118 val.col.r = rgba[0] / 255.0;
119 val.col.g = rgba[1] / 255.0;
120 val.col.b = rgba[2] / 255.0;
124 case F0R_PARAM_POSITION:
125 if (sscanf(param,
"%lf/%lf", &
val.pos.x, &
val.pos.y) != 2)
129 case F0R_PARAM_STRING:
151 for (
i = 0;
i <
s->plugin_info.num_params;
i++) {
152 f0r_param_info_t
info;
156 s->get_param_info(&
info,
i);
179 *handle_ptr = dlopen(path, RTLD_NOW|RTLD_LOCAL);
185 const char *dl_name,
int type)
190 f0r_plugin_info_t *pi;
194 static const char*
const frei0r_pathlist[] = {
195 "/usr/local/lib/frei0r-1/",
196 "/usr/lib/frei0r-1/",
197 "/usr/local/lib64/frei0r-1/",
198 "/usr/lib64/frei0r-1/"
207 if ((path =
av_strdup(getenv(
"FREI0R_PATH")))) {
209 const char *separator =
";";
211 const char *separator =
":";
213 char *p, *ptr =
NULL;
214 for (p = path; p =
av_strtok(p, separator, &ptr); p =
NULL) {
234 if (!
s->dl_handle && (path = getenv(
"HOME"))) {
235 char *prefix =
av_asprintf(
"%s/.frei0r-1/lib/", path);
254 !(f0r_get_plugin_info =
load_sym(
ctx,
"f0r_get_plugin_info")) ||
255 !(
s->get_param_info =
load_sym(
ctx,
"f0r_get_param_info" )) ||
256 !(
s->get_param_value =
load_sym(
ctx,
"f0r_get_param_value")) ||
257 !(
s->set_param_value =
load_sym(
ctx,
"f0r_set_param_value")) ||
264 if (f0r_init() < 0) {
269 f0r_get_plugin_info(&
s->plugin_info);
270 pi = &
s->plugin_info;
271 if (pi->plugin_type !=
type) {
273 "Invalid type '%s' for this plugin\n",
274 pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ?
"filter" :
275 pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ?
"source" :
276 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ?
"mixer2" :
277 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ?
"mixer3" :
"unknown");
282 "name:%s author:'%s' explanation:'%s' color_model:%s "
283 "frei0r_version:%d version:%d.%d num_params:%d\n",
284 pi->name, pi->author, pi->explanation,
285 pi->color_model == F0R_COLOR_MODEL_BGRA8888 ?
"bgra8888" :
286 pi->color_model == F0R_COLOR_MODEL_RGBA8888 ?
"rgba8888" :
287 pi->color_model == F0R_COLOR_MODEL_PACKED32 ?
"packed32" :
"unknown",
288 pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
304 if (
s->destruct &&
s->instance)
305 s->destruct(
s->instance);
309 dlclose(
s->dl_handle);
317 if (
s->destruct &&
s->instance)
318 s->destruct(
s->instance);
333 if (
s->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
336 }
else if (
s->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
366 (
const uint32_t *)
in->data[0],
367 (uint32_t *)
out->data[0]);
374 #define OFFSET(x) offsetof(Frei0rContext, x)
375 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
409 .priv_class = &frei0r_class,
418 s->time_base.num =
s->framerate.den;
419 s->time_base.den =
s->framerate.num;
437 if (
s->destruct &&
s->instance)
438 s->destruct(
s->instance);
439 if (!(
s->instance =
s->construct(outlink->
w, outlink->
h))) {
489 .
name =
"frei0r_src",
492 .priv_class = &frei0r_src_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static void * load_sym(AVFilterContext *ctx, const char *sym_name)
AVPixelFormat
Pixel format.
void(* f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
static av_cold int init(AVCodecContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
char * av_asprintf(const char *fmt,...)
static av_cold void uninit(AVFilterContext *ctx)
static int set_params(AVFilterContext *ctx, const char *params)
AVFILTER_DEFINE_CLASS(frei0r)
static av_cold int source_init(AVFilterContext *ctx)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
void(* f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
#define AV_LOG_VERBOSE
Detailed information.
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
const char * name
Filter name.
A link between two filters.
AVFilter ff_vsrc_frei0r_src
void(* f0r_update2_f)(f0r_instance_t instance, double time, const uint32_t *inframe1, const uint32_t *inframe2, const uint32_t *inframe3, uint32_t *outframe)
void * priv
private data for use by the filter
static int source_request_frame(AVFilterLink *outlink)
f0r_plugin_info_t plugin_info
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static av_cold int frei0r_init(AVFilterContext *ctx, const char *dl_name, int type)
f0r_instance_t(* f0r_construct_f)(unsigned int width, unsigned int height)
static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int source_config_props(AVFilterLink *outlink)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
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().
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
f0r_get_param_info_f get_param_info
static const AVFilterPad outputs[]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static enum AVPixelFormat pix_fmts[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
f0r_get_param_value_f get_param_value
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int config_input_props(AVFilterLink *inlink)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Rational number (pair of numerator and denominator).
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
static av_cold int filter_init(AVFilterContext *ctx)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void(* f0r_destruct_f)(f0r_instance_t instance)
static const AVOption frei0r_options[]
static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix, const char *name)
static int query_formats(AVFilterContext *ctx)
AVFilterContext * src
source filter
const char const char void * val
static const AVFilterPad avfilter_vf_frei0r_outputs[]
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
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)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define i(width, name, range_min, range_max)
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
int w
agreed upon image width
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
const char const char * params
f0r_construct_f construct
#define FF_ARRAY_ELEMS(a)
void(* f0r_get_plugin_info_f)(f0r_plugin_info_t *info)
int h
agreed upon image height
void(* f0r_deinit_f)(void)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
void(* f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe)
char * av_strdup(const char *s)
Duplicate a string.
static const AVFilterPad avfilter_vsrc_frei0r_src_outputs[]
f0r_set_param_value_f set_param_value
static const AVFilterPad avfilter_vf_frei0r_inputs[]
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static const AVOption frei0r_src_options[]