Пример #1
0
 void setParameters(gem::Properties&parms) {
   unsigned int i=0;
   for(i=0; i<m_parameterNames.size(); i++) {
     std::string key=m_parameterNames[i];
     std::string s1, s2;
     double d1, d2;
     switch(m_parameter.type(key)) {
     case gem::Properties::NONE:
       if(gem::Properties::NONE==parms.type(key)) {
         parms.erase(key);
         setParameter(i);
       }
       break;
     case gem::Properties::DOUBLE:
       if(m_parameter.get(key, d1) && parms.get(key, d2)) {
         if(d1!=d2) {
           m_parameter.set(key, d2);
           setParameter(i, d2);
         }
       }
       break;
     case gem::Properties::STRING:
       if(m_parameter.get(key, s1) && parms.get(key, s2)) {
         if(s1!=s2) {
           m_parameter.set(key, s2);
           setParameter(i, s2);
         }
       }
       break;
     default: break;
     }
   }
 }
Пример #2
0
float imageTIFF::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
  float result=0;
  if(mimetype == "image/tiff" || mimetype == "image/x-tiff")
    result += 100;

  if(gem::Properties::UNSET != props.type("xresolution"))result+=1.;
  if(gem::Properties::UNSET != props.type("yresolution"))result+=1.;
  if(gem::Properties::UNSET != props.type("resolutionunit"))result+=1.;
  if(gem::Properties::UNSET != props.type("software"))result+=1.;
  if(gem::Properties::UNSET != props.type("artist"))result+=1.;
  if(gem::Properties::UNSET != props.type("hostcomputer"))result+=1.;

  return result;
}
Пример #3
0
void imageBase :: setProperties(gem::Properties&props) {
    // nada
    m_properties=props;
#if 0
    std::vector<std::string> keys=props.keys();
    int i=0;
    for(i=0; i<keys.size(); i++) {
        enum gem::Properties::PropertyType typ=props.type(keys[i]);
        std::cerr  << "key["<<keys[i]<<"]: "<<typ<<" :: ";
        switch(typ) {
        case (gem::Properties::NONE):
            props.erase(keys[i]);
            break;
        case (gem::Properties::DOUBLE):
            std::cerr << gem::any_cast<double>(props.get(keys[i]));
            break;
        case (gem::Properties::STRING):
            std::cerr << "'" << gem::any_cast<std::string>(props.get(keys[i])) << "'";
            break;
        default:
            std::cerr << "<unknown:" << props.get(keys[i]).get_type().name() << ">";
            break;
        }
    }
    std::cerr << std::endl;
#endif
}
Пример #4
0
float imageJPEG::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
  float result=0.;
  if(mimetype == "image/jpeg")// || mimetype == "image/pjpeg")
    result += 100.;

  // LATER check some properties....
  if(gem::Properties::UNSET != props.type("quality"))
    result += 1.;

  return result;
}
Пример #5
0
float imageQT::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
  float result=0.;

  OSType			filetype; // just a dummy
  if(mime2type(mimetype, filetype))
    result+=100.;

  // LATER check some properties....
  if(gem::Properties::UNSET != props.type("quality"))
    result += 1.;

  return result;
}
Пример #6
0
void modelASSIMP3 :: setProperties(gem::Properties&props) {
  double d;

#if 0
  std::vector<std::string>keys=props.keys();
  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    post("key[%d]=%s ... %d", i, keys[i].c_str(), props.type(keys[i]));
  }
#endif

  std::string s;
  if(props.get("textype", s)) {
    // if there are NO texcoords, we only accept 'linear' and 'spheremap'
    // else, we also allow 'UV'
    // not-accepted textype, simply use the last one
    if(m_have_texcoords && "UV" == s)
      m_textype = "";
    else
    if(("linear" == s) || ("spheremap" == s))
      m_textype = s;
    m_rebuild = true;
  }

  if(props.get("rescale", d)) {
    bool b=(bool)d;
    if(b) {
      float tmp;
      tmp = m_max.x-m_min.x;
      tmp = aisgl_max(m_max.y - m_min.y,tmp);
      tmp = aisgl_max(m_max.z - m_min.z,tmp);
      m_scale = 2.f / tmp;

      m_offset.x=-m_center.x;
      m_offset.y=-m_center.y;
      m_offset.z=-m_center.z;
    } else {
      // FIXXME shouldn't this be the default???
      m_scale=1.;
      m_offset.x=m_offset.y=m_offset.z=0.f;
    }
  }
  if(props.get("usematerials", d)) {
    bool useMaterial=d;
    if(useMaterial!=m_useMaterial)
      m_rebuild=true;
    m_useMaterial=useMaterial;
  }

  render();
}
Пример #7
0
float imageMAGICK::estimateSave(const imageStruct&image, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
    float result=0.5; // slightly preference for MAGICK
    int i;
    for(i=0; i<m_mimetypes.size(); i++) {
        if(mimetype==m_mimetypes[i]) {
            result+=100.;
            break;
        }
    }

    if(gem::Properties::UNSET != props.type("quality"))
        result += 1.;

    return result;
}
Пример #8
0
  virtual void getProperties(gem::Properties&props) {
    std::vector<std::string> ids;
    if(props.type("backends")!=gem::Properties::UNSET) {
      unsigned int i;
      for(i=0; i<m_ids.size(); i++) {
        ids.push_back(m_ids[i]);
      }
    }
    props.erase("backends");

    if(m_handle)
      m_handle->getProperties(props);
    else
      props.clear();

    if(!ids.empty()) {
      props.set("backends", ids);
    }
  }
Пример #9
0
  virtual bool open(const std::string&name, const gem::Properties&requestprops) {
    if(m_handle)close();

    std::vector<std::string> backends;
    if(requestprops.type("backends")!=gem::Properties::UNSET) {
      requestprops.get("backends", backends);
    }
    //      requestprops.erase("backends");

    bool tried=false;
    if(!backends.empty()) {
      unsigned int i, j;
      for(j=0; !m_handle && j<backends.size(); j++) {
        std::string id=backends[j];

        for(i=0; i<m_handles.size(); i++) {
	    /* coverity[assign_where_compare_meant] we set 'tried' to true if we have found at least one matching backend */
          if(id==m_ids[i]&& (tried=true) && m_handles[i]->open(name, requestprops)) {
            m_handle=m_handles[i];
          }
        }
      }
    }
    if(!m_handle && !tried) {
      if(!backends.empty() && !m_handles.empty()) {
        verbose(2, "no available loader selected, falling back to valid ones");
      }
      unsigned int i=0;
      for(i=0; i<m_handles.size(); i++) {
        if(m_handles[i] && m_handles[i]->open(name, requestprops)) {
          m_handle=m_handles[i];
          break;
        } else {

        }
      }
    }
    return (NULL!=m_handle);
  }
Пример #10
0
bool videoVLC::open(gem::Properties&props)
{
  if(m_mediaplayer) {
    close();
  }
  m_pixBlock.image.xsize=0;
  m_pixBlock.image.ysize=0;

  setProperties(props);


  if(m_devname.empty()) {
    return false;
  }

  libvlc_media_t*media = libvlc_media_new_location (m_instance,
                         m_devname.c_str());
  if(!media) {
    media = libvlc_media_new_path (m_instance, m_devname.c_str());
  }

  if(!media) {
    return false;
  }

  char buf[MAXVLCSTRING];

  libvlc_media_add_option(media,":noaudio");
  libvlc_media_add_option(media,":no-video-title-show");


  int w=m_pixBlock.image.xsize;
  int h=m_pixBlock.image.ysize;


  std::vector<std::string>keys=props.keys();
  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];
    double d;
    std::string s;
    buf[0]=0;
    if(0) {}
    else if("width"==key) {
      if(props.get(key, d)&&(d>0)) {
        w=d;
      }
    } else if("height"==key) {
      if(props.get(key, d)&&(d>0)) {
        h=d;
      }
    } else {
      gem::Properties::PropertyType type = props.type(key);
      switch(type) {
      case gem::Properties::NONE:
        snprintf(buf, MAXVLCSTRING, ":%s", key.c_str());
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          snprintf(buf, MAXVLCSTRING, ":%s=%g", key.c_str(), d);
        }
        break;
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          /* need to find an option that actually takes strings, so i can test this with spaces */
          snprintf(buf, MAXVLCSTRING, ":%s=%s", key.c_str(), s.c_str());
        }
        break;
      default:
        break;
      }
      if(0!=buf[0]) {
        buf[MAXVLCSTRING-1]=0;
        libvlc_media_add_option(media,buf);
      }
    }

  }
  resize(w,h,0);
  m_pixBlock.image.setWhite();

  m_mediaplayer=libvlc_media_player_new_from_media(media);
  libvlc_media_release(media);

  /* helper classes to register callbacks */
  struct _callbackObj {
    static void*lock(void*opaque, void**plane )
    {
      videoVLC*obj=(videoVLC*)opaque;
      if(obj) {
        return obj->lockFrame(plane);
      }
      return NULL;
    }
    static void unlock(void*opaque, void*picture, void*const*plane)
    {
      videoVLC*obj=(videoVLC*)opaque;
      if(obj) {
        obj->unlockFrame(picture, plane);
      }
    }
    static void display(void*opaque, void*picture)
    {
      videoVLC*obj=(videoVLC*)opaque;
    }
    _callbackObj(videoVLC*data)
    {
      libvlc_video_set_callbacks(data->m_mediaplayer,
                                 lock,
                                 unlock,
                                 NULL,
                                 data);
    }
  };
  struct _formatCallbackObj {
    static unsigned format(void**opaque, char *chroma, unsigned *width,
                           unsigned *height, unsigned *pitches, unsigned *lines)
    {
      videoVLC**objptr=(videoVLC**)opaque;
      if(objptr && *objptr) {
        return (*objptr)->setFormat(chroma, *width, *height, *pitches, *lines);
      }
      return 0;
    }
    _formatCallbackObj(videoVLC*data)
    {
      libvlc_video_set_format_callbacks(data->m_mediaplayer,
                                        format,
                                        NULL
                                       );

    }
  };
  /* instantiate helper-classes (which registers callbacks) */
  _callbackObj(this);
  _formatCallbackObj(this);

  return true;
}
Пример #11
0
void videoDECKLINK::setProperties(gem::Properties&props)
{
  std::vector<std::string>keys=props.keys();
  int i=0;
  for(i=0; i<keys.size(); i++) {
    const std::string key =keys[i];
    if("format" == key) {
      std::string s;
      double d;
      switch(props.type(key)) {
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          m_formatnum =-1;
          m_formatname=s;
        }
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          m_formatnum =(int)d;
          m_formatname="";
        }
        break;
      }
    }
    if("connection" == key) {
      BMDVideoConnection vconn = m_connectionType;
      std::string s;
      double d;
      switch(props.type(key)) {
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          if      ("SDI"        == s) {
            vconn=bmdVideoConnectionSDI;
          } else if ("HDMI"       == s) {
            vconn=bmdVideoConnectionHDMI;
          } else if ("OpticalSDI" == s) {
            vconn=bmdVideoConnectionOpticalSDI;
          } else if ("Component"  == s) {
            vconn=bmdVideoConnectionComponent;
          } else if ("Composite"  == s) {
            vconn=bmdVideoConnectionComposite;
          } else if ("SVideo"     == s) {
            vconn=bmdVideoConnectionSVideo;
          }
        }
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          int idx =(int)d;
          switch(idx) {
          default:
          case 0:
            vconn=bmdVideoConnectionSDI;
            break;
          case 1:
            vconn=bmdVideoConnectionHDMI;
            break;
          case 2:
            vconn=bmdVideoConnectionOpticalSDI;
            break;
          case 3:
            vconn=bmdVideoConnectionComponent;
            break;
          case 4:
            vconn=bmdVideoConnectionComposite;
            break;
          case 5:
            vconn=bmdVideoConnectionSVideo;
            break;
          }
        }
        break;
      }
      if(m_dlConfig && (m_connectionType != vconn)) {
        m_dlConfig->SetInt(bmdDeckLinkConfigVideoInputConnection, vconn);
      }
      m_connectionType = vconn;
    }
  }
  m_props=props;
}