[gephex-devel] gephex--main--0.4--patch-1846

gephex at sonnenland.kexbox.org gephex at sonnenland.kexbox.org
Sat Feb 26 01:38:31 CET 2005


Archive: gephex at gephex.org--2004
New revision: gephex--main--0.4--patch-1846

--
Revision: gephex--main--0.4--patch-1846
Archive: gephex at gephex.org--2004
Creator: The Gephex Source Archive <gephex at gephex.org>
Date: Sat Feb 26 01:35:52 CET 2005
Standard-date: 2005-02-26 00:35:52 GMT
Modified-files: data/gephex.conf.default.in
    engine/src/dllloader/dllloader.cpp
    modules/src/frbinmodule/frbinmodule.cpp
    types/src/framebuffertype/framebuffertype.h
New-patches: gephex at gephex.org--2004/gephex--main--0.4--patch-1846
    martin at gephex.org--2004/gephex--martin--0.4--patch-56
    martin at gephex.org--2004/gephex--martin--0.4--patch-57
    martin at gephex.org--2004/gephex--martin--0.4--patch-58
Summary: [MERGE-REQUEST] new search path defaults for plugins
Keywords: 

Patches applied:

 * martin at gephex.org--2004/gephex--martin--0.4--patch-56
   add framebuffer_set_default to framebuffertype.h

 * martin at gephex.org--2004/gephex--martin--0.4--patch-57
   better error handling in frbin module

 * martin at gephex.org--2004/gephex--martin--0.4--patch-58
   new default search path for type and module plugins

* added files

    {arch}/gephex/gephex--main/gephex--main--0.4/gephex at gephex.org--2004/patch-log/patch-1846
    {arch}/gephex/gephex--martin/gephex--martin--0.4/martin at gephex.org--2004/patch-log/patch-56
    {arch}/gephex/gephex--martin/gephex--martin--0.4/martin at gephex.org--2004/patch-log/patch-57
    {arch}/gephex/gephex--martin/gephex--martin--0.4/martin at gephex.org--2004/patch-log/patch-58

* modified files

--- orig/data/gephex.conf.default.in
+++ mod/data/gephex.conf.default.in
@@ -3,9 +3,9 @@
 }
 
 engine {
-    module_path          = [@gphx_module_lib_dir@/]
+    module_path          = [__HOME_DIR__/.gephex/0.4/modules/;/usr/local/lib/gephex-0.4/modules/;/usr/lib/gephex-0.4/modules/]
     frei0r_path          = [__HOME_DIR__/.frei0r-1/lib/;/usr/local/lib/frei0r-1/;/usr/lib/frei0r-1/]
-    type_path            = [@gphx_type_lib_dir@/]
+    type_path            = [__HOME_DIR__/.gephex/0.4/types/;/usr/local/lib/gephex-0.4/types/;/usr/lib/gephex-0.4/types/]
     graph_path           = [__CONF_DIR__/graphs/]
     ipc_unix_node_prefix = [/tmp/gephex_socket_]
     ipc_type             = [inet]


--- orig/engine/src/dllloader/dllloader.cpp
+++ mod/engine/src/dllloader/dllloader.cpp
@@ -871,8 +871,8 @@
 
     if (it != m_mod2fileName.end())
       {
-	throw std::runtime_error("Modulname '" + name 
-				 + "'doppelt bei processModFile");
+	throw std::runtime_error("A module with id '" + name 
+				 + "' already exists in plugin " + it->second);
       }
 
     m_mod2fileName[name] = fname;


--- orig/modules/src/frbinmodule/frbinmodule.cpp
+++ mod/modules/src/frbinmodule/frbinmodule.cpp
@@ -101,7 +101,7 @@
   VideoFileDriver* drv;
   VideoInfo  info;
   std::string* fileName;  
-  int flush;
+  bool flush;
 
   InfoMap* known_infos;
   bool damaged;
@@ -173,7 +173,7 @@
 
   my->drv = 0;
   my->fileName = new std::string("");  
-  my->flush = 0;
+  my->flush = false;
 
   my->known_infos = new InfoMap();
 
@@ -355,136 +355,135 @@
 
 void update(void* instance)
 {
-  InstancePtr inst = (InstancePtr) instance;
-  MyInstancePtr my = inst->my;
-  int xsize = trim_int(inst->in_x_size->number, 0 , 1024);
-  int ysize = trim_int(inst->in_y_size->number, 0 , 1024);
-  int flush = trim_int(inst->in_flush->number, 0, 1);
-  int frame_number = trim_int(inst->in_frame->number, 0, INT_MAX);
-
-  bool use_cache = false;
-  if (strcmp(inst->in_cache->text, "yes") == 0)
-    use_cache = true;
-
-  InfoMap& m_known_infos   = *my->known_infos;
-  std::string& m_file_name = *my->fileName;
-
-  if (flush != my->flush)
+  const InstancePtr inst = (InstancePtr) instance;
+  
+  try
     {
-      my->flush = flush;
-      s_cache->flush();
+      const unsigned int user_xsize = trim_int(inst->in_x_size->number,
+					       0 , 1920);
+      const unsigned int user_ysize = trim_int(inst->in_y_size->number,
+					       0 , 1080);
+      const bool use_cache = strcmp(inst->in_cache->text, "yes");
+      const bool flush = trim_bool(inst->in_flush->number);
+      const std::string newFileName = inst->in_fileName->text;  
+      const unsigned int frame_number = trim_int(inst->in_frame->number,
+						 0, INT_MAX);
+      
+      // user wants default size ?
+      const bool default_size(user_xsize == 0 || user_ysize == 0);
+
+      const MyInstancePtr my = inst->my;
+      InfoMap& m_known_infos   = *my->known_infos;
+      std::string& m_file_name = *my->fileName;
+      
+      if (flush != my->flush)
+	{
+	  my->flush = flush;
+	  s_cache->flush();
 	  m_known_infos.clear();
-    }
-
-  std::string newFileName = std::string(inst->in_fileName->text);  
-  std::string error_text = "";
-
-  // first determine the output size
-  if (m_file_name != newFileName || (!use_cache && my->drv == 0)
-      || my->damaged)
-    {
-      if (my->drv)
-        {
-          //printf("Closing driver
");
-          if (my->drv->is_open())
-            my->drv->close_file();
-          delete my->drv;
-          my->drv = 0;
-        }
+	}
+      
+      if (m_file_name != newFileName   ||
+	  (!use_cache && my->drv == 0) ||
+	  my->damaged)
+	{
+	  if (my->drv)
+	    {
+	      //printf("Closing driver
");
+	      if (my->drv->is_open())
+		my->drv->close_file();
+	      delete my->drv;
+	      my->drv = 0;
+	    }
 	  
-      if (use_cache)
-        {  	  		  
-          InfoMap::const_iterator it = m_known_infos.find(newFileName);
-          if (it != m_known_infos.end())
-            {
-              my->info = it->second;
-            }
-          else
-            {
-              try
-                {
-                  my->drv = load_file(newFileName, *s_factory, my->info);
-                  m_known_infos.insert(std::make_pair(newFileName,
-                                                      my->info));
-                  my->damaged = false;
-                }
-              catch (std::exception& e)
-                {
-                  error_text = e.what();
-                  my->damaged = true;
-                }
-            }
-        }  	  
-      else // don't use cache
-        {
-          try
-            {			  
-              my->drv = load_file(newFileName, *s_factory, my->info);	
-              my->damaged = false;
-            }
-          catch (std::exception& e)
-            {
-              error_text = e.what();
-            }
-        }	  
-      m_file_name = newFileName;
-    }
-  
-  if (error_text != "")
-    {
-      s_log(0, error_text.c_str());
-      fallback_setting(inst->out_position,
-                       inst->out_length,
-                       inst->out_result);
-      return;
-    }
-
-  if (my->damaged)
-    return;
-
+	  if (use_cache)
+	    {  	  		  
+	      InfoMap::const_iterator it = m_known_infos.find(newFileName);
+	      if (it != m_known_infos.end())
+		{
+		  my->info = it->second;
+		}
+	      else
+		{
+		  my->drv = load_file(newFileName, *s_factory, my->info);
+		  if (my->info.num_frames < 1)
+		    {
+		      my->damaged = true;
+		      throw std::runtime_error("zero frames in file");
+		    }
+		  else
+		    {
+		      my->damaged = false;
+		      m_known_infos.insert(std::make_pair(newFileName,
+							  my->info));
+		    }
+		}
+	    }  	  
+	  else // don't use cache
+	    {
+	      my->drv = load_file(newFileName, *s_factory, my->info);
+
+	      if (my->info.num_frames < 1)
+		{
+		  my->damaged = true;
+		  throw std::runtime_error("zero frames in file");
+		}
+	      else
+		my->damaged = false;
+	    }	  
+	  m_file_name = newFileName;
+	}
+      
+      
   assert(m_file_name == newFileName);
 
   // determine frame number
-  int pos = frame_number % my->info.num_frames;
+  assert( my->info.num_frames > 0 );
+  
+  const unsigned int pos = frame_number % my->info.num_frames;
 
-  // resize the output
-  if (xsize == 0 || ysize == 0)
-    {
-      xsize = my->info.width;
-      ysize = my->info.height;
-    }
+  const unsigned int xsize = default_size ? user_xsize : my->info.width;
+  const unsigned int ysize = default_size ? user_ysize : my->info.height;
+
+  assert( xsize > 0 );
+  assert( ysize > 0 );
   
-  FrameBufferAttributes attribs;
-  attribs.xsize = xsize;
-  attribs.ysize = ysize;
-  int result = framebuffer_changeAttributes(inst->out_result, &attribs);
+
+  // resize the output
+  {
+    FrameBufferAttributes attribs;
+    attribs.xsize = xsize;
+    attribs.ysize = ysize;  
+    
+    int result = framebuffer_changeAttributes(inst->out_result, &attribs);
+    
+    if (result != 1)
+      throw std::runtime_error("Could not scale output!");
+  }
   
-  if (result != 1)
+  if( ! use_cache )
     {
-      s_log(0, "Could not scale output!");
-      fallback_setting(inst->out_position,
-                       inst->out_length,
-                       inst->out_result);
-      return;
+      // decode the frame
+      my->drv->decode_frame(pos, inst->out_result->framebuffer,
+			    xsize, ysize);      
     }
-
-  // now get the frame
-  if (use_cache)
-    {	  
+    else
+    {
       uint_32* frb = s_cache->lookup(m_file_name, pos, xsize, ysize);
 	  
       if (frb == 0) //Cache miss
         {
-          frb = new uint_32[xsize*ysize];
+	  // lacy open in cache mode
+	  if (my->drv == 0)
+	    {
+	      my->drv = load_file(m_file_name, *s_factory, my->info);
+	      m_known_infos.insert(std::make_pair(m_file_name, my->info));
+	    }
+	  
+	  // fill cache with a new frame
           try
             {
-              if (my->drv == 0)
-                {
-                  my->drv = load_file(m_file_name, *s_factory, my->info);
-                  m_known_infos.insert(std::make_pair(m_file_name,
-                                                      my->info));
-                }
-
+	      frb = new uint_32[xsize*ysize];
               my->drv->decode_frame(pos, frb, xsize, ysize);
               s_cache->store(m_file_name, pos, xsize, ysize, frb);
             }          
@@ -492,51 +491,25 @@
             {
               delete[] frb;
               frb = 0;
-              error_text = e.what();	  
+	      throw;
             }
         }
-
-      if (frb)
-        memcpy(inst->out_result->framebuffer, frb, xsize*ysize*4);
-    }
-  else // don't use the cache
-    {
-      try
-        {
-          my->drv->decode_frame(pos, inst->out_result->framebuffer,
-                                xsize, ysize);
-        }          
-      catch (std::exception& e)
-        {		  
-          error_text = e.what();
-        }
+      // copy cached frame to output
+      memcpy(inst->out_result->framebuffer, frb, xsize*ysize*4);
     }
    
-  if (error_text != "")
-    {
-      s_log(0, error_text.c_str());
-      fallback_setting(inst->out_position,
-                       inst->out_length,
-                       inst->out_result);
-      return;
-    }
-    
   inst->out_position->number = (double) pos;
   inst->out_length->number   = (double) my->info.num_frames;
+    }
+  catch (std::exception& e)
+    {
+      // log error message
+      s_log(0, e.what());
 
-}
+      // no video
+      inst->out_position->number = 0.0;
+      inst->out_length->number = 0.0; // is this a good error code?
 
-//---------------------------------------------------------------------
-
-static void fallback_setting(NumberType* pos, NumberType* len,
-                             FrameBufferType* fr)
-{
-  FrameBufferAttributes attribs;
-  attribs.xsize = 1;
-  attribs.ysize = 1;
-  framebuffer_changeAttributes(fr,&attribs);
-  // set black background
-  *(fr->data) = 0x00000000;
-  pos->number = 0.0;
-  len->number = 0.0;
+      framebuffer_set_default(inst->out_result);
+    }
 }


--- orig/types/src/framebuffertype/framebuffertype.h
+++ mod/types/src/framebuffertype/framebuffertype.h
@@ -302,4 +302,15 @@
   attr->ysize = fb->ysize;
 }	
 
+static __inline
+void framebuffer_set_default(FrameBufferType* fb)
+{
+  FrameBufferAttributes attribs;
+  attribs.xsize = 1;
+  attribs.ysize = 1;
+  framebuffer_changeAttributes(fb, &attribs);
+  // set black background
+  *(fb->data) = 0x00000000;
+}
+
 #endif



More information about the gephex-devel mailing list