}
}
-void PluginFClientConfig::interpolate(PluginFClientConfig &prev, PluginFClientConfig &next,
+void PluginFClientConfig::interpolate(PluginFClientConfig &prev, PluginFClientConfig &next,
int64_t prev_frame, int64_t next_frame, int64_t current_frame)
{
copy_from(prev);
append(fopt);
}
}
+ if( (ffilt->filter->flags & AVFILTER_FLAG_SLICE_THREADS) != 0 ) {
+ opt = av_opt_find(ffilt->fctx, "threads", NULL, 0, 0);
+ if( opt ) {
+ PluginFClient_Opt *fopt = new PluginFClient_Opt(this, opt);
+ append(fopt);
+ }
+ }
}
int PluginFClientConfig::update()
if( strlen(opts[i]->name) < strlen(opt->name) ) opts[i] = opt;
break;
}
- if( i < 0 )
+ if( i < 0 )
opts.append(opt);
}
return opts.size();
av_freep(&buf);
}
}
+ if( (config.ffilt->filter->flags & AVFILTER_FLAG_SLICE_THREADS) != 0 ) {
+ uint8_t *buf = 0;
+ if( av_opt_get(config.ffilt->fctx, "threads", 0, &buf) >= 0 && buf ) {
+ output.tag.set_property("threads", (const char *)buf);
+ av_freep(&buf);
+ }
+ }
output.append_tag();
output.terminate_string();
void PluginFClient::read_data(KeyFrame *keyframe)
{
FileXML input;
- char string[BCTEXTLEN], value[BCTEXTLEN];
+ char string[BCTEXTLEN];
input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
while( !input.read_tag() ) {
void *obj = config.filter_config();
const AVOption *opt = NULL;
while( (opt=av_opt_next(obj, opt)) != 0 ) {
- to_upper(string, opt->name);
- if( !input.tag.get_property(string, value) ) continue;
- av_opt_set(obj, opt->name, value, 0);
+ const char *v = input.tag.get_property(opt->name);
+ if( v ) av_opt_set(obj, opt->name, v, 0);
+ }
+ if( (config.ffilt->filter->flags & AVFILTER_FLAG_SLICE_THREADS) != 0 ) {
+ const char *v = input.tag.get_property("threads");
+ if( v ) av_opt_set(config.ffilt->fctx, "threads", v, 0);
}
}
}
if( ret >= 0 ) {
in_channels = get_inchannels();
out_channels = get_outchannels();
+ frame->nb_samples = size;
+ frame->format = AV_SAMPLE_FMT_FLTP;
+ frame->channel_layout = (1<<in_channels)-1;
+ frame->sample_rate = sample_rate;
+ frame->pts = local_to_edl(filter_position);
}
int retry = 10;
for( int i=0; i<total_in; ++i )
read_samples(buffer[i], i, sample_rate, filter_position, size);
filter_position += size;
- frame->nb_samples = size;
- frame->format = AV_SAMPLE_FMT_FLTP;
- frame->channel_layout = (1<<in_channels)-1;
- frame->sample_rate = sample_rate;
- frame->pts = local_to_edl(filter_position);
ret = av_frame_get_buffer(frame, 0);
if( ret < 0 ) break;
float **in_buffers = (float **)&frame->extended_data[0];
color_model_to_pix_fmt(colormodel);
if( pix_fmt <= AV_PIX_FMT_NONE || pix_fmt >= AV_PIX_FMT_NB )
pix_fmt = AV_PIX_FMT_RGBA;
-
+
AVFrame *frame = 0;
if( ret >= 0 && !(frame = av_frame_alloc()) ) {
fprintf(stderr, "PluginFVClient::process_buffer: av_frame_alloc failed\n");
ret = av_buffersink_get_frame(fsink, frame);
if( ret >= 0 || ret != AVERROR(EAGAIN) ) break;
if( !fsrc ) { ret = AVERROR(EIO); break; }
- read_frame(vframe, 0, filter_position++, frame_rate, get_use_opengl());
+ read_frame(vframe, 0, filter_position++, frame_rate, 0);
frame->format = pix_fmt;
frame->width = width;
frame->height = height;
frame->pts = local_to_edl(position);
ret = av_frame_get_buffer(frame, 32);
if( ret < 0 ) break;
- ret = transfer_pixfmt(vframe, frame, pix_fmt, width, height);
+ ret = transfer_pixfmt(vframe, frame);
if( ret < 0 ) break;
ret = av_buffersrc_add_frame_flags(fsrc, frame, 0);
}
if( ret >= 0 ) {
pix_fmt = (AVPixelFormat) frame->format;
- ret = transfer_cmodel(vframe, frame, pix_fmt, width, height);
+ ret = transfer_cmodel(vframe, frame);
}
if( ret < 0 ) {
ff_err(ret, "PluginFVClient::process_buffer() %s\n", plugin_title());
delete item_value;
}
-char *PluginFClient_Opt::get(char *vp, int sz)
+const char *PluginFClientConfig::get(const char *name)
{
- char *ret = 0;
- void *obj = filter_config();
uint8_t *bp = 0;
- if( av_opt_get(obj, opt->name, 0, &bp) >= 0 && bp != 0 ) {
- const char *val = (const char *)bp;
- ret = sz >= 0 ? strncpy(vp,val,sz) : strcpy(vp, val);
- if( sz > 0 ) vp[sz-1] = 0;
- av_freep(&bp);
+ if( av_opt_get(filter_config(), name, 0, &bp) >= 0 ||
+ av_opt_get(ffilt->fctx, name, 0, &bp) >= 0 )
+ return (const char *)bp;
+ return 0;
+}
+char *PluginFClient_Opt::get(char *vp, int sz)
+{
+ const char *val = conf->get(opt->name);
+ if( val ) {
+ strncpy(vp, val, sz);
+ vp[sz-1] = 0;
}
- return ret;
+ else
+ vp = 0;
+ av_freep(&val);
+ return vp;
+}
+
+void PluginFClientConfig::set(const char *name, const char *val)
+{
+ if( av_opt_set(filter_config(), name, val, 0) < 0 )
+ av_opt_set(ffilt->fctx, name, val, 0);
}
void PluginFClient_Opt::set(const char *val)
{
- void *obj = filter_config();
- av_opt_set(obj , opt->name, val, 0);
+ conf->set(opt->name, val);
}
void PluginFFilter::uninit()
FILE *fp = fopen(defaults_path,"r");
if( !fp ) return 0;
char ff_plugin[BCSTRLEN], ff_args[BCTEXTLEN], *ap = 0;
- while( !ap && fgets(ff_args, sizeof(ff_args), fp) ) {
- if( *(ap=ff_args) == ';' ) continue;
- if( *(ap=ff_args) == '#' ) ++ap;
+ while( fgets(ff_args, sizeof(ff_args), fp) ) {
+ char *cp = ff_args;
+ if( *cp == ';' ) continue;
+ if( *cp == '#' ) ++cp;
char *bp = ff_plugin, *ep = bp + sizeof(ff_plugin)-1;
- while( bp < ep && *ap && *ap != '\n' && *ap != ' ' ) *bp++ = *ap++;
+ while( bp < ep && *cp && *cp != '\n' && *cp != ' ' ) *bp++ = *cp++;
*bp = 0;
- if( strcmp(ff_plugin, name) ) ap = 0;
+ if( !strcmp(ff_plugin, name) ) { ap = cp; break; }
}
fclose(fp);
if( !ap ) return 0;
static int inst = 0;
char inst_name[BCSTRLEN];
sprintf(inst_name,"%s_%d", name, ++inst);
- graph->thread_type = 0;
- graph->nb_threads = 1;
+ if( conf && (filter->flags & AVFILTER_FLAG_SLICE_THREADS) != 0 ) {
+ graph->thread_type = AVFILTER_THREAD_SLICE;
+ graph->nb_threads = atoi(conf->get("threads"));
+ }
+ else {
+ graph->thread_type = 0;
+ graph->nb_threads = 0;
+ }
fctx = avfilter_graph_alloc_filter(graph, filter, inst_name);
if( !fctx ) return AVERROR(ENOMEM);
+ fctx->thread_type = graph->thread_type; // bug in avfilter
if( conf ) {
AVDictionary *opts = 0;
for( int i=0; i<conf->size(); ++i ) {
PluginFClient_Opt *op = conf->get(i);
const char *name = op->opt->name;
char val[BCTEXTLEN], *vp = op->get(val, sizeof(val));
- if( vp ) av_dict_set(&opts, name, vp, 0);
+ if( !vp ) continue;
+ uint8_t *bp = 0;
+// unspecified opts cause a special behavior in some filters (lut3d)
+// so... if opt value is the default, skip it or no special behavior
+ if( av_opt_get(filter_config(), name, 0, &bp) >= 0 ) {
+ int result = strcmp((const char *)bp, vp);
+ av_freep(&bp);
+ if( !result ) continue;
+ }
+ av_dict_set(&opts, name, vp, 0);
}
ret = avfilter_init_dict(fctx, &opts);
av_dict_free(&opts);