41 typedef void (*
f0r_update_f)(f0r_instance_t instance,
double time,
const uint32_t *inframe, uint32_t *outframe);
42 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);
69 void *sym = dlsym(frei0r->
dl_handle, sym_name);
80 f0r_param_color_t col;
81 f0r_param_position_t pos;
88 if (!strcmp(param,
"y")) val.d = 1.0;
89 else if (!strcmp(param,
"n")) val.d = 0.0;
93 case F0R_PARAM_DOUBLE:
94 val.d = strtod(param, &tail);
95 if (*tail || val.d == HUGE_VAL)
100 if (sscanf(param,
"%f/%f/%f", &val.col.r, &val.col.g, &val.col.b) != 3) {
103 val.col.r = rgba[0] / 255.0;
104 val.col.g = rgba[1] / 255.0;
105 val.col.b = rgba[2] / 255.0;
109 case F0R_PARAM_POSITION:
110 if (sscanf(param,
"%lf/%lf", &val.pos.x, &val.pos.y) != 2)
129 for (i = 0; i < frei0r->
plugin_info.num_params; i++) {
130 f0r_param_info_t info;
147 "idx:%d name:'%s' type:%s explanation:'%s' ",
149 info.type == F0R_PARAM_BOOL ?
"bool" :
150 info.type == F0R_PARAM_DOUBLE ?
"double" :
151 info.type == F0R_PARAM_COLOR ?
"color" :
152 info.type == F0R_PARAM_POSITION ?
"position" :
153 info.type == F0R_PARAM_STRING ?
"string" :
"unknown",
162 f0r_param_color_t col;
163 f0r_param_position_t pos;
170 case F0R_PARAM_DOUBLE:
175 case F0R_PARAM_COLOR:
180 case F0R_PARAM_POSITION:
202 snprintf(path,
sizeof(path),
"%s%s%s", prefix, name,
SLIBSUF);
204 return dlopen(path, RTLD_NOW|RTLD_LOCAL);
208 const char *dl_name,
int type)
213 f0r_plugin_info_t *pi;
217 if ((path =
av_strdup(getenv(
"FREI0R_PATH")))) {
218 char *p, *ptr =
NULL;
219 for (p = path; p = strtok_r(p,
":", &ptr); p =
NULL)
224 if (!frei0r->
dl_handle && (path = getenv(
"HOME"))) {
226 snprintf(prefix,
sizeof(prefix),
"%s/.frei0r-1/lib/", path);
238 if (!(f0r_init =
load_sym(ctx,
"f0r_init" )) ||
239 !(f0r_get_plugin_info =
load_sym(ctx,
"f0r_get_plugin_info")) ||
249 if (f0r_init() < 0) {
256 if (pi->plugin_type != type) {
258 "Invalid type '%s' for the plugin\n",
259 pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ?
"filter" :
260 pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ?
"source" :
261 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ?
"mixer2" :
262 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ?
"mixer3" :
"unknown");
267 "name:%s author:'%s' explanation:'%s' color_model:%s "
268 "frei0r_version:%d version:%d.%d num_params:%d\n",
269 pi->name, pi->author, pi->explanation,
270 pi->color_model == F0R_COLOR_MODEL_BGRA8888 ?
"bgra8888" :
271 pi->color_model == F0R_COLOR_MODEL_RGBA8888 ?
"rgba8888" :
272 pi->color_model == F0R_COLOR_MODEL_PACKED32 ?
"packed32" :
"unknown",
273 pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
281 char dl_name[1024], c;
285 sscanf(args,
"%1023[^:=]%c%255c", dl_name, &c, frei0r->
params);
287 return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_FILTER);
301 memset(frei0r, 0,
sizeof(*frei0r));
322 if (frei0r->
plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
324 }
else if (frei0r->
plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
350 (
const uint32_t *)inpicref->
data[0],
351 (uint32_t *)outpicref->
data[0]);
384 char dl_name[1024], c;
385 char frame_size[128] =
"";
392 sscanf(args,
"%127[^:]:%127[^:]:%1023[^:=]%c%255c",
393 frame_size, frame_rate, dl_name, &c, frei0r->
params);
401 frame_rate_q.
den <= 0 || frame_rate_q.
num <= 0) {
408 return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_SOURCE);
418 outlink->
w = frei0r->
w;
419 outlink->
h = frei0r->
h;
435 picref->
pts = frei0r->
pts++;
449 .
name =
"frei0r_src",
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
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.
int h
agreed upon image height
AVFilterBufferRef * out_buf
f0r_plugin_info_t plugin_info
#define AV_PERM_READ
can read from the buffer
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)
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
static av_cold void uninit(AVFilterContext *ctx)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static av_cold int source_init(AVFilterContext *ctx, const char *args, void *opaque)
static double av_q2d(AVRational a)
Convert rational to double.
int avfilter_add_format(AVFilterFormats **avff, int fmt)
Add fmt to the list of media formats contained in *avff.
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)
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.
A link between two filters.
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(). ...
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
#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
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,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
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 w
agreed upon image width
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
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
static int config_input_props(AVFilterLink *inlink)
static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
static int set_params(AVFilterContext *ctx, const char *params)
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
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 void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int filter_init(AVFilterContext *ctx, const char *args, void *opaque)
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
rational number numerator/denominator
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
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)
static void end_frame(AVFilterLink *inlink)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
f0r_set_param_value_f set_param_value
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)
static AVRational frame_rate
#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)
AVFilterBufferRef * cur_buf
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static int source_request_frame(AVFilterLink *outlink)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...