50 typedef void (*
f0r_update_f)(f0r_instance_t instance,
double time,
const uint32_t *inframe, uint32_t *outframe);
51 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);
78 void *sym = dlsym(frei0r->
dl_handle, sym_name);
89 f0r_param_color_t col;
90 f0r_param_position_t pos;
97 if (!strcmp(param,
"y")) val.d = 1.0;
98 else if (!strcmp(param,
"n")) val.d = 0.0;
102 case F0R_PARAM_DOUBLE:
103 val.d =
strtod(param, &tail);
104 if (*tail || val.d == HUGE_VAL)
108 case F0R_PARAM_COLOR:
109 if (sscanf(param,
"%f/%f/%f", &val.col.r, &val.col.g, &val.col.b) != 3) {
112 val.col.r = rgba[0] / 255.0;
113 val.col.g = rgba[1] / 255.0;
114 val.col.b = rgba[2] / 255.0;
118 case F0R_PARAM_POSITION:
119 if (sscanf(param,
"%lf/%lf", &val.pos.x, &val.pos.y) != 2)
138 for (i = 0; i < frei0r->
plugin_info.num_params; i++) {
139 f0r_param_info_t info;
156 "idx:%d name:'%s' type:%s explanation:'%s' ",
158 info.type == F0R_PARAM_BOOL ?
"bool" :
159 info.type == F0R_PARAM_DOUBLE ?
"double" :
160 info.type == F0R_PARAM_COLOR ?
"color" :
161 info.type == F0R_PARAM_POSITION ?
"position" :
162 info.type == F0R_PARAM_STRING ?
"string" :
"unknown",
171 f0r_param_color_t col;
172 f0r_param_position_t pos;
179 case F0R_PARAM_DOUBLE:
184 case F0R_PARAM_COLOR:
189 case F0R_PARAM_POSITION:
211 snprintf(path,
sizeof(path),
"%s%s%s", prefix, name,
SLIBSUF);
213 return dlopen(path, RTLD_NOW|RTLD_LOCAL);
217 const char *dl_name,
int type)
222 f0r_plugin_info_t *pi;
226 if ((path =
av_strdup(getenv(
"FREI0R_PATH")))) {
227 char *p, *ptr =
NULL;
228 for (p = path; p = strtok_r(p,
":", &ptr); p =
NULL)
233 if (!frei0r->
dl_handle && (path = getenv(
"HOME"))) {
235 snprintf(prefix,
sizeof(prefix),
"%s/.frei0r-1/lib/", path);
247 if (!(f0r_init =
load_sym(ctx,
"f0r_init" )) ||
248 !(f0r_get_plugin_info =
load_sym(ctx,
"f0r_get_plugin_info")) ||
258 if (f0r_init() < 0) {
265 if (pi->plugin_type != type) {
267 "Invalid type '%s' for the plugin\n",
268 pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ?
"filter" :
269 pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ?
"source" :
270 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ?
"mixer2" :
271 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ?
"mixer3" :
"unknown");
276 "name:%s author:'%s' explanation:'%s' color_model:%s "
277 "frei0r_version:%d version:%d.%d num_params:%d\n",
278 pi->name, pi->author, pi->explanation,
279 pi->color_model == F0R_COLOR_MODEL_BGRA8888 ?
"bgra8888" :
280 pi->color_model == F0R_COLOR_MODEL_RGBA8888 ?
"rgba8888" :
281 pi->color_model == F0R_COLOR_MODEL_PACKED32 ?
"packed32" :
"unknown",
282 pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
290 char dl_name[1024], c;
294 sscanf(args,
"%1023[^:=]%c%255c", dl_name, &c, frei0r->
params);
296 return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_FILTER);
310 memset(frei0r, 0,
sizeof(*frei0r));
331 if (frei0r->
plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
333 }
else if (frei0r->
plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
363 (
const uint32_t *)in->
data[0],
364 (uint32_t *)out->
data[0]);
400 .
inputs = avfilter_vf_frei0r_inputs,
402 .
outputs = avfilter_vf_frei0r_outputs,
408 char dl_name[1024], c;
410 char frame_rate[128] =
"";
416 sscanf(args,
"%127[^:]:%127[^:]:%1023[^:=]%c%255c",
417 frame_size, frame_rate, dl_name, &c, frei0r->
params);
425 frame_rate_q.
den <= 0 || frame_rate_q.
num <= 0) {
432 return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_SOURCE);
442 outlink->
w = frei0r->
w;
443 outlink->
h = frei0r->
h;
463 picref->
pts = frei0r->
pts++;
467 NULL, (uint32_t *)picref->data[0]);
483 .
name =
"frei0r_src",
494 .
outputs = avfilter_vsrc_frei0r_src_outputs,
AVFilter avfilter_vsrc_frei0r_src
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
AVFilterBufferRefVideoProps * video
video buffer specific properties
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
static const AVFilterPad outputs[]
memory handling functions
int h
agreed upon image height
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
f0r_plugin_info_t plugin_info
static av_cold int source_init(AVFilterContext *ctx, const char *args)
static enum AVSampleFormat formats[]
static const AVFilterPad avfilter_vf_frei0r_outputs[]
#define AV_PERM_READ
can read from the buffer
const char * name
Pad name.
f0r_get_param_value_f get_param_value
void(* f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
static int query_formats(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
double strtod(const char *, char **)
static double av_q2d(AVRational a)
Convert rational to double.
static av_cold int frei0r_init(AVFilterContext *ctx, const char *dl_name, int type)
AVRational pixel_aspect
pixel aspect ratio
static int init(AVCodecParserContext *s)
static av_cold int filter_init(AVFilterContext *ctx, const char *args)
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.
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static const uint8_t frame_size[4]
A link between two filters.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
void(* f0r_get_plugin_info_f)(f0r_plugin_info_t *info)
f0r_instance_t(* f0r_construct_f)(unsigned int width, unsigned int height)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
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...
void av_log(void *avcl, int level, const char *fmt,...)
static const AVFilterPad avfilter_vsrc_frei0r_src_outputs[]
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
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...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
common internal API header
struct AVRational AVRational
rational number numerator/denominator
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 void * load_path(AVFilterContext *ctx, const char *prefix, const char *name)
struct Frei0rContext Frei0rContext
static int source_config_props(AVFilterLink *outlink)
f0r_get_param_info_f get_param_info
void(* f0r_deinit_f)(void)
AVFilterContext * src
source filter
static int config_input_props(AVFilterLink *inlink)
static int set_params(AVFilterContext *ctx, const char *params)
A reference to an AVFilterBuffer.
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)
char * av_strdup(const char *s)
Duplicate the string s.
f0r_construct_f construct
static const AVFilterPad avfilter_vf_frei0r_inputs[]
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
static const AVFilterPad inputs[]
rational number numerator/denominator
void(* f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
void(* f0r_destruct_f)(f0r_instance_t instance)
f0r_set_param_value_f set_param_value
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
static void * load_sym(AVFilterContext *ctx, const char *sym_name)
static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
#define AV_PERM_WRITE
can write to the buffer
AVFilter avfilter_vf_frei0r
int64_t pos
byte position in stream, -1 if unknown
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
void(* f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe)
static int source_request_frame(AVFilterLink *outlink)
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
AVPixelFormat
Pixel format.