add threads param to ffmpeg plugins, spec fix, added m2t ext
authorGood Guy <[email protected]>
Thu, 12 Oct 2017 22:16:02 +0000 (16:16 -0600)
committerGood Guy <[email protected]>
Thu, 12 Oct 2017 22:16:02 +0000 (16:16 -0600)
cinelerra-5.1/cinelerra.spec
cinelerra-5.1/cinelerra/pluginfclient.C
cinelerra-5.1/cinelerra/pluginfclient.h
cinelerra-5.1/guicast/bcresources.C

index 54d57758b2ef4e1d8a898acdb4a85297efa755a3..e7620ea3510faf6e7b72dfa30ca94ecd8eab4641 100644 (file)
@@ -7,7 +7,7 @@ Summary: Multimedia Editing and construction
 %define xcfg --enable-x265_hidepth --with-exec-name=cinx
 %endif
 
-Name: %{cin}%{xbit}
+Name: %{cin}%{?xbit}
 Version: 5.1
 Release: %{ver}
 License: GPL
@@ -69,7 +69,7 @@ Multimedia editing and construction
 %setup -q -n %{cin}-%{version}
 %build
 ./autogen.sh
-%configure %{xcfg}
+%configure %{?xcfg}
 %{__make}
 
 %install
index 373f3d2564766c95a518cd3593293d13b13c03bc..56b459587222e120a996a1cc2fb7f89995c77779 100644 (file)
@@ -101,6 +101,13 @@ void PluginFClientConfig::initialize(const char *name)
                        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()
@@ -616,6 +623,13 @@ void PluginFClient::save_data(KeyFrame *keyframe)
                        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();
@@ -624,7 +638,7 @@ void PluginFClient::save_data(KeyFrame *keyframe)
 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() ) {
@@ -635,9 +649,12 @@ void PluginFClient::read_data(KeyFrame *keyframe)
                        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);
                        }
                }
        }
@@ -985,23 +1002,35 @@ PluginFClient_Opt::~PluginFClient_Opt()
        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()
@@ -1060,9 +1089,16 @@ int PluginFFilter::init(const char *name, PluginFClientConfig *conf)
        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);
+       fctx->thread_type = graph->thread_type; // bug in avfilter
        if( !fctx ) return AVERROR(ENOMEM);
        if( conf ) {
                AVDictionary *opts = 0;
index 4d112568add51a6ec4b87a1a96fd2ce708caaceb..0768d0beb556ec4699a6a44449710f86ceeb0386 100644 (file)
@@ -97,7 +97,10 @@ public:
        PluginFFilter *ffilt;
        void *filter_config() { return ffilt->filter_config(); }
        const AVClass *filter_class() { return ffilt->filter_class(); }
+       PluginFClient_Opt *get(int i) { return ArrayList<PluginFClient_Opt *>::get(i); }
 
+       const char *get(const char *name);
+       void set(const char *name, const char *val);
        void copy_from(PluginFClientConfig &that);
        int equivalent(PluginFClientConfig &that);
        void interpolate(PluginFClientConfig &prev, PluginFClientConfig &next,
index d2f0b7a912ff6cdbb5e6f68dfe0d5adab5ce6a15..4ae705adb645f301368b2176fee49d9e2e8b91a6 100644 (file)
@@ -201,6 +201,7 @@ suffix_to_type_t BC_Resources::suffix_to_type[] =
     { "ifo", ICON_FILM },
     { "jpeg", ICON_FILM },
     { "jpg", ICON_FILM },
+    { "m2t", ICON_FILM },
     { "m2ts", ICON_FILM },
     { "m2v", ICON_FILM },
     { "m4v", ICON_FILM },