#include "vframe.h"
#include "filexml.h"
+#ifdef FFMPEG3
+#define av_filter_iterate(p) ((*(const AVFilter**)(p))=avfilter_next(*(const AVFilter **)(p)))
+#endif
static void ff_err(int ret, const char *fmt, ...)
{
int PluginFClientApply::handle_event()
{
- const char *text = fwin->text->get_text();
- if( text && fwin->selected ) {
- fwin->selected->set(text);
- fwin->selected->item_value->update();
- fwin->draw();
- fwin->ffmpeg->plugin->send_configure_change();
+ return fwin->update();
+}
+
+PluginFClientPot::PluginFClientPot(PluginFClientWindow *fwin, int x, int y)
+ : BC_FPot(x, y, 0.f, 0.f, 0.f)
+{
+ this->fwin = fwin;
+}
+
+int PluginFClient_Opt::get_range(float &fmn, float &fmx)
+{
+ switch( opt->type ) {
+ case AV_OPT_TYPE_INT:
+ case AV_OPT_TYPE_INT64:
+ case AV_OPT_TYPE_DOUBLE:
+ case AV_OPT_TYPE_FLOAT: break;
+ default: return 1;
+ }
+ const AVClass *filt_class = filter_class();
+ if( !filt_class || !filt_class->option ) return 1;
+ AVOptionRanges *r = 0;
+ void *obj = &filt_class;
+ if( av_opt_query_ranges(&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) < 0 ) return 1;
+ int ret = 1;
+ if( r->nb_ranges == 1 ) {
+ fmn = r->range[0]->value_min;
+ fmx = r->range[0]->value_max;
+ ret = 0;
+ }
+ av_opt_freep_ranges(&r);
+ return ret;
+}
+
+float PluginFClient_Opt::get_float()
+{
+ char val[BCTEXTLEN]; val[0] = 0;
+ get(val, sizeof(val));
+ return atof(val);
+}
+
+void PluginFClient_Opt::set_float(float v)
+{
+ char val[BCTEXTLEN]; val[0] = 0;
+ sprintf(val, "%f", v);
+ set(val);
+}
+
+int PluginFClientPot::handle_event()
+{
+ if( fwin->selected ) {
+ fwin->selected->set_float(get_value());
+ fwin->update_selected();
+ return fwin->update();
+ }
+ return 1;
+}
+
+PluginFClientSlider::PluginFClientSlider(PluginFClientWindow *fwin, int x, int y)
+ : BC_FSlider(x, y, 0, fwin->get_w()-x-20, fwin->get_w()-x-20, 0.f, 0.f, 0.f)
+{
+ this->fwin = fwin;
+}
+
+int PluginFClientSlider::handle_event()
+{
+ if( fwin->selected ) {
+ fwin->selected->set_float(get_value());
+ fwin->update_selected();
+ return fwin->update();
}
return 1;
}
if( opt ) opt->get(val, sizeof(val));
text->update(val);
+ float v = 0, fmn = 0, fmx = 0;
+ if( opt && !opt->get_range(fmn, fmx) ) v = atof(val);
+ float p = (fmx-fmn) / slider->get_w();
+ slider->set_precision(p);
+ slider->update(slider->get_w(), v, fmn, fmx);
+ pot->set_precision(p);
+ pot->update(v, fmn, fmx);
panel->update();
}
+int PluginFClientWindow::update()
+{
+ const char *txt = text->get_text();
+ if( txt && selected ) {
+ selected->set(txt);
+ selected->item_value->update();
+ draw();
+ ffmpeg->plugin->send_configure_change();
+ }
+ return 1;
+}
+
+void PluginFClientWindow::update_selected()
+{
+ update(selected);
+}
+
int PluginFClient_OptPanel::selection_changed()
{
PluginFClient_Opt *opt = 0;
add_subwindow(apply = new PluginFClientApply(this, x1, y));
add_subwindow(text = new PluginFClientText(this, x0, y, x1-x0 - 8));
y += title->get_h() + 10;
+ add_subwindow(pot = new PluginFClientPot(this, x, y));
+ x1 = x + pot->get_w() + 10;
+ add_subwindow(slider = new PluginFClientSlider(this, x1, y+10));
+ y += pot->get_h() + 10;
panel_x = x; panel_y = y;
panel_w = get_w()-10 - panel_x;
int x0 = units->get_x() + units->get_w() + 8;
int y0 = units->get_y();
text->reposition_window(x0,y0, x1-x0-8);
+ x1 = pot->get_x() + pot->get_w() + 10;
+ int w1 = w - slider->get_x() - 20;
+ slider->set_pointer_motion_range(w1);
+ slider->reposition_window(x1, slider->get_y(), w1, slider->get_h());
panel_w = get_w()-10 - panel_x;
panel_h = get_h()-10 - panel_y;
panel->reposition_window(panel_x,panel_y, panel_w, panel_h);
return 1;
}
+
PluginFClient::PluginFClient(PluginClient *plugin, const char *name)
{
this->plugin = plugin;
delete ffilt;
}
-bool PluginFClient::is_audio(AVFilter *fp)
+bool PluginFClient::is_audio(const AVFilter *fp)
{
if( !fp->outputs ) return 0;
if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
if( avfilter_pad_get_type(fp->inputs, 0) != AVMEDIA_TYPE_AUDIO ) return 0;
return 1;
}
-bool PluginFClient::is_video(AVFilter *fp)
+bool PluginFClient::is_video(const AVFilter *fp)
{
if( !fp->outputs ) return 0;
if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
{
AVFilterContext *fctx = ffilt->fctx;
AVFilterLink **links = !fctx->nb_inputs ? 0 : fctx->inputs;
- return !links ? 0 : avfilter_link_get_channels(links[0]);
+ return !links ? 0 : links[0]->channels;
}
int PluginFAClient::get_outchannels()
{
AVFilterContext *fctx = ffilt->fctx;
AVFilterLink **links = !fctx->nb_outputs ? 0 : fctx->outputs;
- return !links ? 0 : avfilter_link_get_channels(links[0]);
+ return !links ? 0 : links[0]->channels;
}
int PluginFAClient::process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate)
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);
PluginClient *PluginServer::new_ffmpeg_plugin()
{
- AVFilter *filter = avfilter_get_by_name(ff_name);
+ const AVFilter *filter = avfilter_get_by_name(ff_name);
if( !filter ) return 0;
PluginFClient *ffmpeg =
PluginFClient::is_audio(filter) ?
PluginFFilter *ffilt = PluginFFilter::new_ffilter(name);
if( !ffilt ) return 0;
delete ffilt;
- return new PluginServer(mwindow, (char*)name, PLUGIN_TYPE_FFMPEG);
+ return new PluginServer(mwindow, name, PLUGIN_TYPE_FFMPEG);
}
void MWindow::init_ffmpeg_index(MWindow *mwindow, Preferences *preferences, FILE *fp)
{
PluginFLogLevel errs(AV_LOG_ERROR);
- const AVFilter *filter = 0;
- while( (filter=avfilter_next(filter)) != 0 ) {
+ const AVFilter *filter = 0; void *idx = 0;
+ while( (filter=av_filter_iterate(&idx)) != 0 ) {
+//printf("%s\n",filter->name);
PluginServer *server = new_ffmpeg_server(mwindow, filter->name);
if( server ) {
int result = server->open_plugin(1, preferences, 0, 0);
void MWindow::init_ffmpeg()
{
- av_register_all();
- avfilter_register_all();
}