コード例 #1
0
ファイル: filter_glsl_manager.cpp プロジェクト: jksiezni/mlt
int GlslManager::render_frame_texture(mlt_service service, mlt_frame frame, int width, int height, uint8_t **image)
{
	EffectChain* chain = get_chain( service );
	if (!chain) return 1;
	glsl_fbo fbo = get_fbo( width, height );
	if (!fbo) return 1;
	glsl_texture texture = get_texture( width, height, GL_RGBA );
	if (!texture) {
		release_fbo( fbo );
		return 1;
	}

	glBindFramebuffer( GL_FRAMEBUFFER, fbo->fbo );
	check_error();
	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture, 0 );
	check_error();
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
	check_error();

	render_fbo( service, chain, fbo->fbo, width, height );

	glFinish();
	check_error();
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
	check_error();
	release_fbo( fbo );

	*image = (uint8_t*) &texture->texture;
	mlt_frame_set_image( frame, *image, 0, NULL );
	mlt_properties_set_data( MLT_FRAME_PROPERTIES(frame), "movit.convert.texture", texture, 0,
		(mlt_destructor) GlslManager::release_texture, NULL );

	return 0;
}
コード例 #2
0
ファイル: hooks.c プロジェクト: fgoncalves/Thesis
static unsigned int nf_ip_post_routing_hook(unsigned int hooknum,
		struct sk_buff *skb, const struct net_device *in,
		const struct net_device *out, int(*okfn)(struct sk_buff*)) {
	filter_chain c = get_chain(POST_ROUTING_CHAIN);
	klist_iterator* it;
	filter* f;
	unsigned int retval;

	if (c.len == 0)
		return NF_ACCEPT;

	it = make_klist_iterator(c.filters);
	while (klist_iterator_has_next(it)) {
		f = (filter*) (klist_iterator_next(it))->data;
		if (match_filter(f, skb)) {
			retval = apply_filter(f, hooknum, skb, in, out, okfn);
			if (retval != NF_ACCEPT) {
				free_klist_iterator(it);
				return retval;
			}
		}
	}
	free_klist_iterator(it);

	return NF_ACCEPT;
}
コード例 #3
0
/*FUNC-************************************************************************/
static int parse_add_chains(char *entries)
{
  char *token;
  char *saveptr;
  int ret;

  for (token = strtok_r(entries, " ", &saveptr);
       (token != NULL) && (dnswld.fw.n_chains < FW_CHAIN_MAX_NUM);
       token = strtok_r(NULL, " ", &saveptr))
  {
    if (get_chain(token))
    {
      PUTS_OSYS(LOG_DEBUG, "Chain [%s] already added. Skipping.", token);
      continue;
    }

    PUTS_OSYS(LOG_DEBUG, "Adding [%s] to chains list at [%d]...", token,
              dnswld.fw.n_chains);
    strncpy(dnswld.fw.chains[dnswld.fw.n_chains], token, FW_CHAIN_MAX_LEN - 1);
    dnswld.fw.n_chains++;
  }

  ret = RET_OK;

  return(ret);
}
コード例 #4
0
ファイル: edge_strip.C プロジェクト: ArnaudGastinel/jot-lib
void
EdgeStrip::get_chains(ARRAY<Bvert_list>& chains) const
{
   // Return a list of distinct chains of edges, in the form
   // of a set of Bvert_lists. 

   chains.clear();

   Bvert_list chain;
   for (int k=0; get_chain(k, chain); )
      chains += chain;
}
コード例 #5
0
ファイル: filter_glsl_manager.cpp プロジェクト: jksiezni/mlt
int GlslManager::render_frame_rgba(mlt_service service, mlt_frame frame, int width, int height, uint8_t **image)
{
	EffectChain* chain = get_chain( service );
	if (!chain) return 1;
	glsl_fbo fbo = get_fbo( width, height );
	if (!fbo) return 1;
	glsl_texture texture = get_texture( width, height, GL_RGBA );
	if (!texture) {
		release_fbo( fbo );
		return 1;
	}

	// Use a PBO to hold the data we read back with glReadPixels().
	// (Intel/DRI goes into a slow path if we don't read to PBO.)
	int img_size = width * height * 4;
	glsl_pbo pbo = get_pbo( img_size );
	if (!pbo) {
		release_fbo( fbo );
		release_texture(texture);
		return 1;
	}

	// Set the FBO
	check_error();
	glBindFramebuffer( GL_FRAMEBUFFER, fbo->fbo );
	check_error();
	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture, 0 );
	check_error();
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
	check_error();

	render_fbo( service, chain, fbo->fbo, width, height );

	// Read FBO into PBO
	glBindFramebuffer( GL_FRAMEBUFFER, fbo->fbo );
	check_error();
	glBindBuffer( GL_PIXEL_PACK_BUFFER_ARB, pbo->pbo );
	check_error();
	glBufferData( GL_PIXEL_PACK_BUFFER_ARB, img_size, NULL, GL_STREAM_READ );
	check_error();
	glReadPixels( 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0) );
	check_error();

	// Copy from PBO
	uint8_t* buf = (uint8_t*) glMapBuffer( GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY );
	check_error();
	*image = (uint8_t*) mlt_pool_alloc( img_size );
	mlt_frame_set_image( frame, *image, img_size, mlt_pool_release );
	memcpy( *image, buf, img_size );

	// Convert BGRA to RGBA
	register uint8_t *p = *image;
	register int n = width * height + 1;
	while ( --n ) {
		uint8_t b = p[0];
		*p = p[2]; p += 2;
		*p = b; p += 2;
	}

	// Release PBO and FBO
	glUnmapBuffer( GL_PIXEL_PACK_BUFFER_ARB );
	check_error();
	glBindBuffer( GL_PIXEL_PACK_BUFFER_ARB, 0 );
	check_error();
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
	check_error();
	glBindTexture( GL_TEXTURE_2D, 0 );
	check_error();
	mlt_properties_set_data( MLT_FRAME_PROPERTIES(frame), "movit.convert.texture", texture, 0,
		(mlt_destructor) GlslManager::release_texture, NULL);
	release_fbo( fbo );

	return 0;
}
コード例 #6
0
ファイル: pdb.cpp プロジェクト: salilab/imp
void write_pdb(const ParticlesTemp& ps, TextOutput out) {
  IMP_FUNCTION_LOG;
  int last_index = 0;
  bool use_input_index = true;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (Atom(ps[i]).get_input_index() != last_index + 1) {
      use_input_index = false;
      break;
    } else {
      ++last_index;
    }
  }
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (Atom::get_is_setup(ps[i])) {
      Atom ad(ps[i]);
      Residue rd = get_residue(ad);
      // really dumb and slow, fix later
      char chain;
      Chain c = get_chain(rd);
      if (c) {
        chain = c.get_id()[0];
      } else {
        chain = ' ';
      }
      int inum = i+1;
      if (i>=99999) inum=99999;
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              use_input_index ? ad.get_input_index()
                                              : static_cast<int>(inum),
                              ad.get_atom_type(), rd.get_residue_type(), chain,
                              rd.get_index(), rd.get_insertion_code(),
                              ad.get_occupancy(), ad.get_temperature_factor(),
                              ad.get_element());

      if (!out) {
        IMP_THROW("Error writing to file in write_pdb", IOException);
      }
    }
    else if (Residue::get_is_setup(ps[i])) {    // if C-alpha residue is available
      Residue rd = IMP::atom::Residue(ps[i]);
      // comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
      char chain;
      Chain c = get_chain(rd);
      if (c) {
        chain = c.get_id()[0];
      } else {
        chain = ' ';
      }

      // comment 2 by SJ - TODO: The C-alpha residues are not sorted yet. We need to sort the residues similarly to what PMI does.
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              static_cast<int>(i + 1),
                              IMP::atom::AT_CA, rd.get_residue_type(), chain,
                              rd.get_index(), ' ',
                              1.0, IMP::core::XYZR(ps[i]).get_radius());
    }
    else {  // if a coarse-grained BEAD is available
      Ints resindexes = IMP::atom::Fragment(ps[i]).get_residue_indexes();
      int resindex = (int)resindexes.front() + (int)(resindexes.size()/2);
      // comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
      char chain = ' ';

      // comment 3 by SJ - TODO: The BEADs are not sorted yet. We need to sort the residues similarly to what PMI does.
      // comment 4 by SJ - TODO: currently IMP does not allow "BEA" as a residue name, while PMI allows it. Thus "UNK" was used instead.
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              static_cast<int>(i + 1),
                              IMP::atom::AT_CA, IMP::atom::UNK, chain,
                              (int)resindex, ' ',
                              1.0, IMP::core::XYZR(ps[i]).get_radius());
    }
  }
}
コード例 #7
0
ファイル: chain2.c プロジェクト: crooks/mixmaster
int
chain_2 (int argc, char *argv[])
{
  FILE *in;
  char line[256], filename[80] = "", *destination[NUMDEST], outfile[80] = "";
  char *subject[NUMSUB], *t;
  int chain[HOPMAX];
  byte numdest = 0, numsub = 0;
  int i, num_remailers, outfileflag = 0;
  REMAILER remailer_list[256];
  int filter = 0, rfcmsg = 0, dummy = 0;

  num_remailers = read_remailer_list (remailer_list);

  chain[0] = 0;

  /* what is in those arguments */
  /* Here is the expected format */
  /* mixmaster [-c][-f][filename][-[o,O] outfile][-to who@where][-s "subject"][-l 1 2 3 4] */
  /* if no outfile given, then pipe to sendmail. outfile = stdout send to stdout */
  for (i = 1; i < argc; i++)
    {
      if (streq (argv[i], "-c"))
	{
	  /* nop */
	}
      else if (strleft (argv[i], "-h") || streq (argv[i], "--help"))
	{
	  /* Print help and exit */
	  printf ("Mixmaster %s (C) Copyright Lance M. Cottrell 1995, 1996\n",
		  VERSION);
	  printf ("Released under the GNU public license. No warranty!\n\n");
	  printf ("Client Mode command line arguments:\n");
	  printf ("mixmaster [-c] [infile] [-f] [-m] [-s subject] [-v 'Header: text' [-v ...]]\n[-n numcopies] [-[o,O] outfile] [-to who@where] [-l 1 2 3 ...]\n");
	  exit (-1);
	}
      else if (streq (argv[i], "-f"))
	{
	  /* set filter mode */
	  filter = 1;
	}
      else if (streq (argv[i], "-m"))
	{
	  filter = 1;
	  rfcmsg = 1;
	}
      else if (streq (argv[i], "-d"))
	{
	  filter = 1;
	  destination[0] = (char *) calloc (1, DESTSIZE);
	  strcpy (destination[0], "null:");
	  numdest = 1;
	  REQUIRE[0] = '\0';
	  REJECT[0] = '\0';
	  dummy = 5 + random_number (11);
	}
      else if (streq (argv[i], "-s"))
	{
	  if (i < argc - 1)
	    i++;
	  subject[numsub] = (char *) calloc (1, SUBSIZE);
	  strcpy (subject[numsub], "Subject: ");
	  strncat (subject[numsub], argv[i], SUBSIZE - sizeof ("Subject: "));
	  numsub++;
	}
      else if (streq (argv[i], "-v"))
	{
	  if (i < argc - 1)
	    i++;
	  subject[numsub] = (char *) calloc (1, SUBSIZE);
	  subject[numsub][0] = 0;
	  strncat (subject[numsub], argv[i], SUBSIZE - 1);
	  numsub++;
	}
      else if (streq (argv[i], "-o") || streq (argv[i], "-O"))
	{
	  if (streq (argv[i], "-O"))
	    outfileflag = 1;	/* add To: line */
	  if (i < argc - 1)
	    i++;
	  if (streq (argv[i], "stdout"))
	    strcpy (outfile, "-");
	  else
	    parse_filename (outfile, argv[i]);
	}
      else if (streq (argv[i], "-n"))
	{
	  if (i < argc - 1)
	    i++;
	  sscanf (argv[i], "%d", &NUMCOPIES);
	}
      else if (streq (argv[i], "-to") && numdest < NUMDEST)
	{
	  if (i < argc - 1)
	    i++;
	  destination[numdest] = (char *) calloc (1, DESTSIZE);
	  strncpy (destination[numdest], argv[i], DESTSIZE - 1);
	  destination[numdest][DESTSIZE - 1] = '\0';
	  chop (destination[numdest]);
	  numdest++;
	}
      else if (streq (argv[i], "-l"))
	{
	  for (i++; i < argc && chain[0] < HOPMAX; i++)
	    if ((chain[++chain[0]] =
		 select_remailer (remailer_list,
				  num_remailers, argv[i])) < 0)
	      exit (-1);	/* Invalid remailer */
	}
      else
	{
	  if (strlen (filename) != 0)
	    {
	      fprintf (errlog, "problem with the command line\n");
	      return (-1);
	    }
	  strncpy (filename, argv[i], sizeof (filename));
	}
    }

  if (numdest == 0 && !rfcmsg)
    {
      if (!filter)
	fprintf (errlog, "Enter final destinations (one per line return when done).\n");
      do
	{
	  if (!filter)
	    fprintf (errlog, "Enter destination :");
	  getline (line, sizeof (line), stdin);
	  if (strlen (line) >= 2 && numdest < NUMDEST)
	    {
	      destination[numdest] = (char *) calloc (1, DESTSIZE);
	      strncpy (destination[numdest], line, DESTSIZE - 1);
	      destination[numdest][DESTSIZE - 1] = '\0';
	      numdest++;
	    }
	}
      while (strlen (line) > 0 || numdest == 0);
    }
  if (numdest == 0 && filter && !rfcmsg)
    exit (-1);			/* no destination and in filter mode */

  if (numsub == 0 && !dummy)
    {
      if (!filter)
	{
	  fprintf (errlog, "Enter message headers (one per line, return when done).\n");
	  fprintf (errlog, "You must include the header name, e.g. 'Subject: foo'\n");
	}
      do
	{
	  if (!filter)
	    fprintf (errlog, "Enter header :");
	  getline (line, sizeof (line), stdin);
	  if (rfcmsg && (strileft (line, "To:") || strileft (line, "Newsgroups:")) && numdest < NUMDEST)
	    {
	      destination[numdest] = (char *) calloc (1, DESTSIZE);
	      if (strileft (line, "To:"))
		{
		  t = line + sizeof ("To:") - 1;
		  while (*t == ' ' || *t == '\t')
		    t++;
		  strncpy (destination[numdest], t, DESTSIZE - 1);
		}
	      else
		{
		  t = line + sizeof ("Newsgroups:") - 1;
		  while (*t == ' ' || *t == '\t')
		    t++;
		  strcpy (destination[numdest], "post: ");
		  strncat (destination[numdest], t, DESTSIZE - sizeof ("post: "));
		}
	      destination[numdest][DESTSIZE - 1] = '\0';
	      numdest++;
	    }
	  else if (strlen (line) > 0 && numsub < NUMSUB)
	    {
	      subject[numsub] = (char *) calloc (1, SUBSIZE);
	      strncpy (subject[numsub], line, SUBSIZE - 1);
	      subject[numsub][SUBSIZE - 1] = '\0';
	      numsub++;
	    }
	}
      while (strlen (line) > 0);
    }

  if (!strchr (REQUIRE, 'N'))
    for (i = 0; i < numdest; i++)
      if (strileft (destination[i], "post:"))
	{
	  strcat (REQUIRE, "N");
	  break;
	}

  if (chain[0] == 0 && strlen (CHAIN))
    if (scan_remailer_list (CHAIN, chain, remailer_list, num_remailers) < 0)
      return (-1);
  if (chain[0] == 0 && dummy)
    {
      while (chain[0] < dummy)
	chain[++chain[0]] = 0;
    }
  if (chain[0] == 0 && !filter)
    {
      get_chain (remailer_list, num_remailers, chain);
    }
  if (chain[0] == 0)
    {
      return (-1);
    }
#if 1
  if ((chain[chain[0]] > 0)
      && check_abilities (remailer_list[chain[chain[0]]].abilities,
			  REQUIRE, REJECT) == 0)
    {
      fprintf (errlog, "Warning: Remailer %s has insufficient capabilities!\n",
	       remailer_list[chain[chain[0]]].shortname);
    }
#else
  while ((chain[chain[0]] > 0)
	 && check_abilities (remailer_list[chain[chain[0]]].abilities,
			     REQUIRE, REJECT) == 0)
    {
      fprintf (errlog, "Remailer %s has insufficient capabilities!\n",
	       remailer_list[chain[chain[0]]].shortname);
      if (!filter)
	{
	  chain[0]--;
	  get_chain (remailer_list, num_remailers, chain);
	}
      else
	exit (-1);
    }
#endif

  /* if file = stdin then I will take stdin */
  if (strlen (filename) == 0 && !filter)
    {
      fprintf (errlog, "Please enter the name of the file to chain: ");
      getline (filename, sizeof (filename), stdin);
    }
  if (streq (filename, "stdin"))
    strcpy (filename, "-");
  parse_filename (line, filename);
  if (dummy)
    in = NULL;
  else if (streq (filename, "-") || strlen (filename) == 0)
    {
      if (!filter)
	fprintf (errlog, "Please enter the message.\n");
      in = stdin;
    }
  else
    in = open_user_file (line, "r");
  /* ok, that should be everything we need to know */

#ifdef DEBUG
  printf ("filtermode %d\n", filter);	/*debug */
  printf ("source file %s\n", filename);	/*debug */
  printf ("#destinations %d\n", numdest);	/*debug */
  for (i = 0; i < numdest; i++)
    printf ("destination %d  %s\n", i, destination[i]);	/*debug */
  for (i = 1; i <= chain[0]; i++)
    printf ("remailer %d\n", chain[i]);	/*debug */
  for (i = 0; i < numsub; i++)
    printf ("header %d  %s\n", i, subject[i]);	/*debug */
#endif

  return (build_message (in, numdest, destination, chain,
			 numsub, subject, outfile, outfileflag,
			 remailer_list, num_remailers, 1));
}