49 typedef void (*
f0r_update_f)(f0r_instance_t instance,
double time,
const uint32_t *inframe, uint32_t *outframe);
50 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);
82 void *sym = dlsym(s->
dl_handle, sym_name);
93 f0r_param_color_t col;
94 f0r_param_position_t pos;
101 if (!strcmp(param,
"y")) val.d = 1.0;
102 else if (!strcmp(param,
"n")) val.d = 0.0;
106 case F0R_PARAM_DOUBLE:
107 val.d =
strtod(param, &tail);
108 if (*tail || val.d == HUGE_VAL)
112 case F0R_PARAM_COLOR:
113 if (sscanf(param,
"%f/%f/%f", &val.col.r, &val.col.g, &val.col.b) != 3) {
116 val.col.r = rgba[0] / 255.0;
117 val.col.g = rgba[1] / 255.0;
118 val.col.b = rgba[2] / 255.0;
122 case F0R_PARAM_POSITION:
123 if (sscanf(param,
"%lf/%lf", &val.pos.x, &val.pos.y) != 2)
143 f0r_param_info_t info;
161 "idx:%d name:'%s' type:%s explanation:'%s' ",
163 info.type == F0R_PARAM_BOOL ?
"bool" :
164 info.type == F0R_PARAM_DOUBLE ?
"double" :
165 info.type == F0R_PARAM_COLOR ?
"color" :
166 info.type == F0R_PARAM_POSITION ?
"position" :
167 info.type == F0R_PARAM_STRING ?
"string" :
"unknown",
176 f0r_param_color_t col;
177 f0r_param_position_t pos;
184 case F0R_PARAM_DOUBLE:
186 s->get_param_value(s->instance, v, i);
189 case F0R_PARAM_COLOR:
191 s->get_param_value(s->instance, v, i);
194 case F0R_PARAM_POSITION:
196 s->get_param_value(s->instance, v, i);
201 s->get_param_value(s->instance, v, i);
216 snprintf(path,
sizeof(path),
"%s%s%s", prefix, name,
SLIBSUF);
218 return dlopen(path, RTLD_NOW|RTLD_LOCAL);
227 f0r_plugin_info_t *pi;
236 if (path = getenv(
"FREI0R_PATH")) {
249 if (!s->
dl_handle && (path = getenv(
"HOME"))) {
251 snprintf(prefix,
sizeof(prefix),
"%s/.frei0r-1/lib/", path);
263 if (!(f0r_init =
load_sym(ctx,
"f0r_init" )) ||
264 !(f0r_get_plugin_info =
load_sym(ctx,
"f0r_get_plugin_info")) ||
274 if (f0r_init() < 0) {
281 if (pi->plugin_type != type) {
283 "Invalid type '%s' for this plugin\n",
284 pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ?
"filter" :
285 pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ?
"source" :
286 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ?
"mixer2" :
287 pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ?
"mixer3" :
"unknown");
292 "name:%s author:'%s' explanation:'%s' color_model:%s " 293 "frei0r_version:%d version:%d.%d num_params:%d\n",
294 pi->name, pi->author, pi->explanation,
295 pi->color_model == F0R_COLOR_MODEL_BGRA8888 ?
"bgra8888" :
296 pi->color_model == F0R_COLOR_MODEL_RGBA8888 ?
"rgba8888" :
297 pi->color_model == F0R_COLOR_MODEL_PACKED32 ?
"packed32" :
"unknown",
298 pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
342 if (s->
plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
344 }
else if (s->
plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
374 (
const uint32_t *)in->
data[0],
375 (uint32_t *)out->
data[0]);
382 #define OFFSET(x) offsetof(Frei0rContext, x) 383 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM 424 .priv_class = &filter_class,
442 frame_rate_q.
den <= 0 || frame_rate_q.
num <= 0) {
520 .
name =
"frei0r_src",
524 .priv_class = &src_class,
static av_cold int filter_init(AVFilterContext *ctx)
This structure describes decoded (raw) audio or video data.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
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[]
Main libavfilter public API header.
memory handling functions
int h
agreed upon image height
f0r_plugin_info_t plugin_info
static const AVOption src_options[]
void(* f0r_get_plugin_info_f)(f0r_plugin_info_t *info)
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_dlog(ac->avr, "%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-> out
static enum AVSampleFormat formats[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVFilterPad avfilter_vf_frei0r_outputs[]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
f0r_get_param_value_f get_param_value
static int query_formats(AVFilterContext *ctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold void uninit(AVFilterContext *ctx)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
double strtod(const char *, char **)
static double av_q2d(AVRational a)
Convert rational to double.
#define AV_LOG_VERBOSE
Detailed information.
static av_cold int frei0r_init(AVFilterContext *ctx, const char *dl_name, int type)
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 av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void(* f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe)
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_dlog(ac->avr, "%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
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. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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[]
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
void(* f0r_deinit_f)(void)
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...
AVFilter ff_vsrc_frei0r_src
int w
agreed upon image width
common internal API header
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)
static int source_config_props(AVFilterLink *outlink)
f0r_get_param_info_f get_param_info
static const AVClass src_class
AVFilterContext * src
source filter
static int config_input_props(AVFilterLink *inlink)
static int set_params(AVFilterContext *ctx, const char *params)
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)
f0r_construct_f construct
void(* f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
static const AVFilterPad avfilter_vf_frei0r_inputs[]
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
static const AVClass filter_class
rational number numerator/denominator
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const AVOption filter_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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)
struct AVFilterPad AVFilterPad
static av_cold int init(AVCodecParserContext *s)
AVFilterContext * dst
dest filter
void(* f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
void(* f0r_destruct_f)(f0r_instance_t instance)
static int source_request_frame(AVFilterLink *outlink)
f0r_instance_t(* f0r_construct_f)(unsigned int width, unsigned int height)
AVPixelFormat
Pixel format.
static av_cold int source_init(AVFilterContext *ctx)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.