gephex--main--0.4--patch-1816

[email protected]
Newsgroups gmane.comp.video.gephex.devel
Message-ID <[email protected]>
Archive: [email protected]
New revision: gephex--main--0.4--patch-1816

--
Revision: gephex--main--0.4--patch-1816
Archive: [email protected]
Creator: GePhex <[email protected]>
Date: Tue Nov 16 09:57:36 CET 2004
Standard-date: 2004-11-16 08:57:36 GMT
Modified-files: base/src/utils/string_.cpp
    base/src/utils/string_.h
    engine/src/dllloader/c_moduleclass.cpp
    engine/src/dllloader/c_moduleclass.h
    engine/src/dllloader/dllloader.cpp
    engine/src/dllloader/frei0rwrapper.cpp
    engine/src/dllloader/frei0rwrapper.h
    modules/src/capturemodule/v4l1.cpp
    modules/src/chromakeymodule/chromakeymodule.c
    qtgui/src/gui/ownstyle.h
New-patches: [email protected]/gephex--georg--0.4--patch-356
    [email protected]/gephex--georg--0.4--patch-357
    [email protected]/gephex--georg--0.4--patch-358
    [email protected]/gephex--main--0.4--patch-1816
Summary: update frei0r loader: add support for sources, improve widgets
Keywords: 

Patches applied:

 * [email protected]/gephex--georg--0.4--patch-356
   Fix some compilation errors with gcc-3.4.1

 * [email protected]/gephex--georg--0.4--patch-357
   Added support for source frei0r effects

 * [email protected]/gephex--georg--0.4--patch-358
   Fix wrong input id in frei0rwrapper

* added files

    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-356
    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-357
    {arch}/gephex/gephex--georg/gephex--georg--0.4/[email protected]/patch-log/patch-358
    {arch}/gephex/gephex--main/gephex--main--0.4/[email protected]/patch-log/patch-1816

* modified files

--- orig/base/src/utils/string_.cpp
+++ mod/base/src/utils/string_.cpp
@@ -34,6 +34,11 @@
   {
   }
 
+  String::String(const String& str)
+    : m_data(str.m_data)
+  {
+  }
+
   const String& String::operator=(const String& str)
   {
     m_data = str.m_data;


--- orig/base/src/utils/string_.h
+++ mod/base/src/utils/string_.h
@@ -46,6 +46,7 @@
   {
   public:
     String(const std::string& str = "");
+    String(const String&);
 
     const String& operator=(const String&);
 
@@ -66,7 +67,6 @@
     }
 
   private:
-    String(const String&);
 
     std::string m_data;
   };


--- orig/engine/src/dllloader/c_moduleclass.cpp
+++ mod/engine/src/dllloader/c_moduleclass.cpp
@@ -42,11 +42,12 @@
 CModuleClass::CModuleClass(const CModuleFunctionTable& ftab_,
 			   const CModuleAttributes& attr_,
 			   const std::string& name,
-			   frei0r_funs_t* frei0r)
+			   frei0r_funs_t* frei0r,
+                           int frei0r_plugin_type)
   : functionTable(new CModuleFunctionTable(ftab_)), 
-  attributes(new CModuleAttributes(attr_)), 
-  defaultInputValues(attr_.inputs.size()),
-    m_name(name), m_frei0r(0)
+    attributes(new CModuleAttributes(attr_)), 
+    defaultInputValues(attr_.inputs.size()),
+    m_name(name), m_frei0r(0), m_frei0r_plugin_type(frei0r_plugin_type)
 {
   if (frei0r)
     m_frei0r = new frei0r_funs_t(*frei0r);
@@ -56,7 +57,8 @@
 {
   CModuleClass* newClass = new CModuleClass(*this->functionTable,
 					    *this->attributes,
-					    this->m_name, this->m_frei0r);
+					    this->m_name, this->m_frei0r,
+                                            this->m_frei0r_plugin_type);
   newClass->defaultInputValues = defaultInputValues;
   return newClass;
 }
@@ -79,10 +81,11 @@
   void* instance;
   if (m_frei0r)
     {
-      typedef void* (*harr_t)(void*, int);
+      typedef void* (*harr_t)(void*, int, int);
       harr_t harr = (harr_t) functionTable->newInstance;
 
-      instance = harr(m_frei0r, defaultInputValues.size());
+      instance = harr(m_frei0r, defaultInputValues.size(),
+                      m_frei0r_plugin_type);
     }
   else
     instance = functionTable->newInstance();


--- orig/engine/src/dllloader/c_moduleclass.h
+++ mod/engine/src/dllloader/c_moduleclass.h
@@ -46,7 +46,8 @@
 	CModuleClass(const CModuleFunctionTable&,
 		     const CModuleAttributes& attr_,
 		     const std::string& name,
-		     frei0r_funs_t* frei0r);
+		     frei0r_funs_t* frei0r,
+                     int frei0r_plugin_type);
 
 	virtual IModuleClass* clone() const;
 
@@ -62,6 +63,7 @@
 	mutable std::vector<ITypePtr> defaultInputValues;
 	std::string m_name;
 	frei0r_funs_t* m_frei0r;
+        int m_frei0r_plugin_type;
 };
 
 #endif


--- orig/engine/src/dllloader/dllloader.cpp
+++ mod/engine/src/dllloader/dllloader.cpp
@@ -475,7 +475,7 @@
       m_typeInfoReceiver->typeClassLoaded(id,mi);
   }
 	
-  void DllLoader::unloadTypeClass(const std::string& name)
+  void DllLoader::unloadTypeClass(const std::string& /*name*/)
   {
     //TODO
   }
@@ -520,6 +520,8 @@
                                        const std::string& moduleName,
 				       frei0r_funs_t* frei0r)
   {
+    int frei0r_plugin_type = -1;
+
     if (frei0r)
       {
 	if (frei0r->init() == 0)
@@ -549,12 +551,16 @@
       {
 	frei0r->get_plugin_info(&f0r_info);
 
-	// +1 for input frame, +1 for time
-	numInputs = 1 + f0r_info.num_params + 1;
+        frei0r_check_plugin_info(f0r_info);
+
+        // remember this for later
+        frei0r_plugin_type = f0r_info.plugin_type;
+
+        numInputs = frei0r_num_inputs(f0r_info);
+
 	numOutputs = 1;
 	isDeterministic = false;
 
-
 	moduleSpec = frei0r_create_spec(f0r_info);
       }
     else
@@ -600,26 +606,14 @@
 	std::string inSpec;
 	if (frei0r)
 	  {
-	    if (i == 0)
-	      {
-		inSpec = frei0r_create_in_spec();
-	      }
-	    else if (i == numInputs-1)
-	      {
-		inSpec = frei0r_create_time_spec();
-	      }
-	    else
-	      {
-		f0r_param_info_t pinfo;
-		frei0r->get_param_info(&pinfo, i-1);
-		inSpec = frei0r_create_in_param_spec(pinfo);
+            std::string param_name;
+            inSpec = frei0r_create_in_param_spec(f0r_info, frei0r, i,
+                                                 param_name);
 #if (ENGINE_VERBOSITY > 1)
-		std::cout << "param # " << i-1 << " name '" 
-			  << pinfo.name << "'
";
+            std::cout << "param # " << i << ": '" << inSpec << "'
";
 #endif
-		f0r_param_names.push_back(pinfo.name);
-	      }
-	  }
+            f0r_param_names.push_back(param_name);
+          }
 	else
 	  {
 	    inSpec = fTable->getInputSpec(i);
@@ -769,6 +763,10 @@
       {
 	std::vector<char> buf = frei0r_create_info(f0r_info,
 						   f0r_param_names);
+
+#if (ENGINE_VERBOSITY > 1)
+        std::cout << "Inf0r: '" << &buf[0] << "'
";
+#endif
 	data = new char[buf.size()];
 	memcpy(data, &buf[0], buf.size());
 	bufLen = buf.size();
@@ -797,8 +795,8 @@
 			
 	m_infoReceiver->moduleClassLoaded(name,mi);
 
-	m_classReceiver->moduleClassLoaded(name,
-					   CModuleClass(*fTable,attributes,name, frei0r));
+        CModuleClass cm(*fTable,attributes,name, frei0r, frei0r_plugin_type);
+	m_classReceiver->moduleClassLoaded(name, cm);
 
 	m_specReceiver->moduleClassLoaded(name,ModuleClassSpec(name,inputs,
 							       defaultVals,


--- orig/engine/src/dllloader/frei0rwrapper.cpp
+++ mod/engine/src/dllloader/frei0rwrapper.cpp
@@ -6,6 +6,7 @@
 #include <iostream>
 
 #include "../../../types/src/framebuffertype/framebuffertype.h"
+#include "../../../types/src/numbertype/numbertype.h"
 #include "../engine/dllutils.h"
 
 #include "frei0r.xpm"
@@ -17,12 +18,13 @@
 
 struct f0r_wrapper_t
 {
-  f0r_wrapper_t() : funs(0), f0r_instance(0) {}
+  f0r_wrapper_t(int plugin_type_)
+    : plugin_type(plugin_type_), funs(0), f0r_instance(0) {}
 
+  int plugin_type;
   frei0r_funs_t* funs;
   f0r_instance_t f0r_instance;
 
-  FrameBufferType* inf;
   FrameBufferType* outf;
 
   std::vector<void*> input_params;
@@ -32,13 +34,14 @@
 };
 
 
-void* f0rwrapper_newInstance (frei0r_funs_t* funs, int num_inputs)
+void* f0rwrapper_newInstance (frei0r_funs_t* funs, int num_inputs,
+                              int plugin_type)
 {
-  f0r_wrapper_t* wr = new f0r_wrapper_t();
+  f0r_wrapper_t* wr = new f0r_wrapper_t(plugin_type);
 
   wr->f0r_instance = funs->construct(XSIZE, YSIZE);
   wr->funs = funs;
-  wr->input_params.resize(num_inputs-1);
+  wr->input_params.resize(num_inputs);
   wr->width  = XSIZE;
   wr->height = YSIZE;
 
@@ -59,20 +62,15 @@
 {
   f0r_wrapper_t* wr = (f0r_wrapper_t*) instance;
 
-  if (index == 0)
-    {
-      wr->inf = (FrameBufferType*) typePointer;
-    }
-  else
-    {
-      wr->input_params[index-1] = typePointer;
-    }
+  wr->input_params[index] = typePointer;
 
   return 1;
 }
 
 int f0rwrapper_setOutput (void* instance,int index,void* typePointer)
 {
+  assert(index == 0);
+
   f0r_wrapper_t* wr = (f0r_wrapper_t*) instance;
 
   FrameBufferType* fb = (FrameBufferType*) typePointer;
@@ -86,8 +84,23 @@
 {
   f0r_wrapper_t* wr = (f0r_wrapper_t*) instance;
 
+  FrameBufferType* in = 0;
+
   FrameBufferAttributes attribs;
-  framebuffer_getAttributes(wr->inf, &attribs);
+
+  if (wr->plugin_type == F0R_PLUGIN_TYPE_SOURCE)
+    {
+      attribs.xsize = trim_int(((NumberType*) wr->input_params[0])->number,
+                               8, 4096);
+
+      attribs.ysize = trim_int(((NumberType*) wr->input_params[1])->number,
+                               8, 4096);
+    }
+  else if (wr->plugin_type == F0R_PLUGIN_TYPE_FILTER)
+    {
+      in = (FrameBufferType*) wr->input_params[0];
+      framebuffer_getAttributes(in, &attribs);
+    }
 
   // TODO: check for multiples of 8
   if (attribs.xsize != wr->width || attribs.ysize != wr->height)
@@ -106,15 +119,18 @@
   attribs.ysize = wr->height;  
   framebuffer_changeAttributes(wr->outf, &attribs);
 
-  for (int i = 0; i < wr->input_params.size()-1; ++i)
+  int offset = (wr->plugin_type == F0R_PLUGIN_TYPE_SOURCE) ? 2 : 1;
+
+  for (int i = offset; i < wr->input_params.size()-1; ++i)
     {
-      wr->funs->set_param_value(wr->f0r_instance, wr->input_params[i], i);
+      wr->funs->set_param_value(wr->f0r_instance, wr->input_params[i],
+                                i-offset);
     }
 
   double time = *((double*) wr->input_params[wr->input_params.size()-1]);
 
   wr->funs->update(wr->f0r_instance, time,
-		   wr->inf->framebuffer,
+		   in ? in->framebuffer : 0,
 		   wr->outf->framebuffer);
 }
 
@@ -136,40 +152,20 @@
 }
 
 
-std::string frei0r_create_spec(f0r_plugin_info_t& f0r_info)
+std::string frei0r_create_spec(const f0r_plugin_info_t& f0r_info)
 {
   std::ostringstream os;
   // return "mod_spec { name=[mod_gradnormmodule] number_of_inputs=[3] number_of_outputs=[1] deterministic=[true] }";
 
+  int num_inputs = frei0r_num_inputs(f0r_info);
+
   os << "mod_spec { name=[mod_" << f0r_info.name
-     << "] number_of_inputs=[" << f0r_info.num_params+2
+     << "] number_of_inputs=[" << num_inputs
      << "] number_of_outputs=[1] deterministic=[true] } ";
 
   return os.str();
 }
 
-std::string frei0r_create_in_spec()
-{
-//return "input_spec { type=typ_FrameBufferType id=b const=true strong_dependency=true  } ";
-  std::ostringstream os;
-
-  os << "input_spec { type=typ_FrameBufferType "
-     << "id=in const=true strong_dependency=true } ";
-
-  return os.str();
-}
-
-std::string frei0r_create_time_spec()
-{
-//return "input_spec { type=typ_FrameBufferType id=b const=true strong_dependency=true  } ";
-  std::ostringstream os;
-
-  os << "input_spec { type=typ_NumberType "
-     << "id=frei0r_time const=true strong_dependency=true } ";
-
-  return os.str();
-}
-
 static std::string quote_spaces(const std::string& s)
 {
   std::string ret;
@@ -183,14 +179,60 @@
   return ret;
 }
 
-std::string frei0r_create_in_param_spec(f0r_param_info_t& f0r_pinfo)
+std::string frei0r_create_in_param_spec(const f0r_plugin_info_t& f0r_info,
+                                        frei0r_funs_t* frei0r, int input,
+                                        std::string& param_name)
 {
 //return "input_spec { type=typ_FrameBufferType id=b const=true strong_dependency=true  } ";
+  int index = -1;
   std::ostringstream os;
-
   os << "input_spec { type=";
+
+  if (f0r_info.plugin_type == F0R_PLUGIN_TYPE_SOURCE)
+    {
+      if (input == 0 || input == 1)
+        {
+          param_name = (input == 0) ? "width" : "height";
+          int default_value = (input == 0) ? XSIZE : YSIZE;
+
+          os << "typ_NumberType; id=frei0r_" << param_name
+             << " const=true strong_dependency=true default=" 
+             << default_value << "}";
+          return os.str();
+        }
+      index = input - 2;
+    }
+  else if (f0r_info.plugin_type == F0R_PLUGIN_TYPE_FILTER)
+    {
+      if (input == 0)
+        {
+          param_name = "input";
+
+          os << "typ_FrameBufferType; id=frei0r_" << param_name
+             << " const=true strong_dependency=true }";
+
+          return os.str();
+        }
+      index = input - 1;
+    }
+
+  // the last input is time
+  if (index == f0r_info.num_params)
+    {
+      param_name="time";
+
+      os << "typ_NumberType "
+         << "id=frei0r_"<< param_name << " const=true strong_dependency=true } ";
+
+      return os.str();
+    }
+
+  assert(index >= 0 && index < f0r_info.num_params);
+
+  f0r_param_info_t pinfo;
+  frei0r->get_param_info(&pinfo, index);
   
-  switch (f0r_pinfo.type)
+  switch (pinfo.type)
     {
     case F0R_PARAM_BOOL:
       os << "typ_NumberType"; break;
@@ -204,32 +246,51 @@
       throw std::runtime_error("Invalid frei0r parameter type");
     }
 
-  os << " id=[" << f0r_pinfo.name << "] const=true strong_dependency=true } ";
+  param_name = quote_spaces(pinfo.name);
+  os << " id=[" << param_name << "] const=true strong_dependency=true } ";
     
   return os.str();
 }
 
 std::string frei0r_create_out_spec()
 {
-  return "output_spec { type=typ_FrameBufferType id=Output } ";
+  return "output_spec { type=typ_FrameBufferType id=frei0r_output } ";
 }
 
 
-std::vector<char> frei0r_create_info(f0r_plugin_info_t& f0r_info,
+std::vector<char> frei0r_create_info(const f0r_plugin_info_t& f0r_info,
 				     const std::vector<std::string>& param_names)
 {
   std::ostringstream os;
+  int num_inputs = frei0r_num_inputs(f0r_info);
+  int param_offset;
   //  static const char* INFO = "info { name=[Gradientnorm] group=[Filter] inputs=[3 Image Lightness{lower_bound=[0] step_size=[0.01] higher_bound=[1] hidden=[true] help=[lightness] } Algorithm{widget_type=[combo_box] values=[sobel,roberts-cross] hidden=[true] help=[sobel is slower and smoother, roberts-cross is quick and dirty] } ] outputs=[1 Image ] type=xpm } ";
 
   os << "info { name=[" << f0r_info.name
      << "] group=[Frei0r] inputs=["
-     << f0r_info.num_params+2 << " Image ";
+     << num_inputs;
+
+  if (f0r_info.plugin_type == F0R_PLUGIN_TYPE_SOURCE)
+    {
+      std::string properties = "{widget_type=number_selector "
+        "lower_bound=8 step_size=8 higher_bound=4096 hidden=true}";
+
+      os << " Width" << properties << " Height" << properties;
+      param_offset = 2;
+    }
+  else if (f0r_info.plugin_type == F0R_PLUGIN_TYPE_FILTER)
+    {
+      os << " Image ";
+      param_offset = 1;
+    }
 
   for (int i = 0; i < f0r_info.num_params; ++i)
     {
-      os << quote_spaces(param_names[i]) << " ";
+      os << quote_spaces(param_names[i+param_offset]) << " ";
     }
-  os << " Time] outputs=[1 Image] type=xpm } ";
+
+  std::string time_properties = "{widget_type=unboundednumber_selector}";
+  os << " Time" << time_properties << " ] outputs=[1 Output] type=xpm } ";
 
   //  std::cout << "INFO = " << os.str() << "
";
   char* tmpBuf;
@@ -261,3 +322,27 @@
 }
 
 
+void frei0r_check_plugin_info(const f0r_plugin_info_t& f0r_info)
+{
+  if (f0r_info.plugin_type != F0R_PLUGIN_TYPE_SOURCE &&
+      f0r_info.plugin_type != F0R_PLUGIN_TYPE_FILTER)
+    throw std::runtime_error("Invalid plugin_type");
+
+  if (f0r_info.frei0r_version != 1)
+    throw std::runtime_error("Invalid frei0r version");
+}
+
+int frei0r_num_inputs(const f0r_plugin_info& f0r_info)
+{
+  switch (f0r_info.plugin_type)
+    {
+    case F0R_PLUGIN_TYPE_SOURCE:
+      // +2 for size, +1 for time
+      return 2 + f0r_info.num_params + 1;
+    case F0R_PLUGIN_TYPE_FILTER:
+      // +1 for input frame, +1 for time
+      return 1 + f0r_info.num_params + 1;
+    default:
+      throw std::runtime_error("Argl0r");
+    }
+}


--- orig/engine/src/dllloader/frei0rwrapper.h
+++ mod/engine/src/dllloader/frei0rwrapper.h
@@ -44,16 +44,21 @@
 
 void create_f0r_wrapper(CModuleFunctionTable& fTable);
 
-std::string frei0r_create_spec(f0r_plugin_info_t&);
+std::string frei0r_create_spec(const f0r_plugin_info_t&);
 
-std::string frei0r_create_in_spec();
-std::string frei0r_create_time_spec();
+std::string frei0r_create_in_param_spec(const f0r_plugin_info_t& f0r_info,
+                                        frei0r_funs_t* frei0r, int input,
+                                        std::string& param_name);
 
-std::string frei0r_create_in_param_spec(f0r_param_info_t& f0r_pinfo);
 std::string frei0r_create_out_spec();
 
 
-std::vector<char> frei0r_create_info(f0r_plugin_info_t& f0r_info,
+std::vector<char> frei0r_create_info(const f0r_plugin_info_t& f0r_info,
 				     const std::vector<std::string>& param_names);
 
+void frei0r_check_plugin_info(const f0r_plugin_info_t& f0r_info);
+
+int frei0r_num_inputs(const f0r_plugin_info& f0r_info);
+
 #endif
+


--- orig/modules/src/capturemodule/v4l1.cpp
+++ mod/modules/src/capturemodule/v4l1.cpp
@@ -12,6 +12,8 @@
 #include <sstream>
 #include <videodev.h>
 
+#include <errno.h>
+
 struct v4l1_intern
 {
   int fd;


--- orig/modules/src/chromakeymodule/chromakeymodule.c
+++ mod/modules/src/chromakeymodule/chromakeymodule.c
@@ -28,12 +28,13 @@
 #include "config.h"
 #endif
 
+#if defined(CPU_I386) && defined(OPT_INCLUDE_MMX)
 #include "cpuinfo.h"
-
-static logT s_log;
-
 static int s_mmx_supported;
 static int s_e3dnow_supported;
+#endif
+
+static logT s_log;
 
 typedef void (*chroma_key_t)(uint_8 r, uint_8 g, uint_8 b, uint_8 tolerance,
                              uint_32* dst, const uint_32* fg,


--- orig/qtgui/src/gui/ownstyle.h
+++ mod/qtgui/src/gui/ownstyle.h
@@ -43,7 +43,7 @@
     virtual int pixelMetric( QStyle::PixelMetric metric,
                              const QWidget * widget = 0 ) const
     {
-      if (metric == PM_ScrollBarExtent)
+      if (metric == QStyle::PM_ScrollBarExtent)
         return 15;
       else
         return STYLE::pixelMetric(metric, widget);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.