コード例 #1
0
ファイル: producer_qimage.c プロジェクト: mcfrisk/mlt
static int load_sequence2( producer_qimage self, mlt_properties properties, const char *filename )
{
	int result = 0;
	const char *start;

	// Obtain filenames with pattern containing a begin value, e.g. foo%1234d.png
	if ( ( start = strchr( filename, '%' ) ) )
	{
		const char *end = ++start;
		while ( isdigit( *end ) ) end++;
		if ( end > start && ( end[0] == 'd' || end[0] == 'i' || end[0] == 'u' ) )
		{
			int n = end - start;
			char *s = calloc( 1, n + 1 );
			strncpy( s, start, n );
			mlt_properties_set( properties, "begin", s );
			free( s );
			s = calloc( 1, strlen( filename ) );
			strncpy( s, filename, start - filename );
			sprintf( s + ( start - filename ), ".%d%s", n, end );
			result = load_sequence( self, properties, s );
			free( s );
		}
	}
	return result;
}
コード例 #2
0
void pedometer_update() {
	if (startedSession) {
		X_DELTA_TEMP = abs(abs(currX) - abs(lastX));
		if (X_DELTA_TEMP >= X_DELTA) {
			validX = true;
		}
		Y_DELTA_TEMP = abs(abs(currY) - abs(lastY));
		if (Y_DELTA_TEMP >= Y_DELTA) {
			validY = true;
			if (Y_DELTA_TEMP - Y_DELTA > 200){
				autoCorrectY();
				Y_DELTA = (Y_DELTA < YZ_DELTA_MAX) ? Y_DELTA + PED_ADJUST : Y_DELTA;
			} else if (Y_DELTA - Y_DELTA_TEMP > 175){
				autoCorrectY();
				Y_DELTA = (Y_DELTA > YZ_DELTA_MIN) ? Y_DELTA - PED_ADJUST : Y_DELTA;
			}
		}
		Z_DELTA_TEMP = abs(abs(currZ) - abs(lastZ));
		if (abs(abs(currZ) - abs(lastZ)) >= Z_DELTA) {
			validZ = true;
			if (Z_DELTA_TEMP - Z_DELTA > 200){
				autoCorrectZ();
				Z_DELTA = (Z_DELTA < YZ_DELTA_MAX) ? Z_DELTA + PED_ADJUST : Z_DELTA;
			} else if (Z_DELTA - Z_DELTA_TEMP > 175){
				autoCorrectZ();
				Z_DELTA = (Z_DELTA < YZ_DELTA_MAX) ? Z_DELTA + PED_ADJUST : Z_DELTA;
			}
		}
	} else {
		startedSession = true;
	}
  
  //Update UI
  if ((validX && validY && !did_pebble_vibrate) || (validX && validZ && !did_pebble_vibrate)) {
		step_count++;
    
    //update level
    int percentStepGoal = ((double)step_count / step_goal) * 100;
    if(percentStepGoal > 0 && percentStepGoal != level_int && level_int < 100)
    {      
      level_int = percentStepGoal;      
      update_level_text();
      if(level_int == 100)
      {
        shinyAlly = true;
        load_sequence();
      }
    }
  }  
  
  resetUpdate();
}
コード例 #3
0
/*
 * This is the main function for dumping any node.
 */
SV *
load_node(perl_yaml_loader_t *loader)
{
    /* Get the next parser event */
    if (!yaml_parser_parse(&loader->parser, &loader->event))
        goto load_error;

    /* Return NULL when we hit the end of a scope */
    if (loader->event.type == YAML_DOCUMENT_END_EVENT ||
        loader->event.type == YAML_MAPPING_END_EVENT ||
        loader->event.type == YAML_SEQUENCE_END_EVENT) return NULL;

    /* Handle loading a mapping */
    if (loader->event.type == YAML_MAPPING_START_EVENT) {
        SV *hash_ref;
        char *tag = (char *)loader->event.data.mapping_start.tag;

        /* Handle mapping tagged as a Perl hard reference */
        if (tag && strEQ(tag, TAG_PERL_REF))
            return load_scalar_ref(loader);
        
        /* Handle mapping tagged as a Perl typeglob */
        if (tag && strEQ(tag, TAG_PERL_GLOB))
            return load_glob(loader);

        /* Load the mapping into a hash ref and return it */
        return load_mapping(loader, NULL);
    }

    /* Handle loading a sequence into an array */
    if (loader->event.type == YAML_SEQUENCE_START_EVENT)
        return load_sequence(loader);

    /* Handle loading a scalar */
    if (loader->event.type == YAML_SCALAR_EVENT)
        return load_scalar(loader);

    /* Handle loading an alias node */
    if (loader->event.type == YAML_ALIAS_EVENT)
        return load_alias(loader);

    /* Some kind of error occurred */
    if (loader->event.type == YAML_NO_EVENT)
        croak(loader_error_msg(loader, NULL));

    croak(ERRMSG "Invalid event '%d' at top level", (int) loader->event.type);

load_error:
    croak(loader_error_msg(loader, NULL));
}
コード例 #4
0
ファイル: producer_qimage.c プロジェクト: mcfrisk/mlt
static void load_filenames( producer_qimage self, mlt_properties properties )
{
	char *filename = mlt_properties_get( properties, "resource" );
	self->filenames = mlt_properties_new( );

	if (!load_svg( self, properties, filename ) &&
		!load_sequence( self, properties, filename ) &&
		!load_sequence2( self, properties, filename ) &&
		!load_folder( self, properties, filename ) )
	{
		mlt_properties_set( self->filenames, "0", filename );
	}
	self->count = mlt_properties_count( self->filenames );
}
コード例 #5
0
/*
 * This is the main function for dumping any node.
 */
SV *
load_node(perl_yaml_loader_t *loader)
{
    SV* return_sv = NULL;
    /* This uses stack, but avoids (severe!) memory leaks */
    yaml_event_t uplevel_event;

    uplevel_event = loader->event;

    /* Get the next parser event */
    if (!yaml_parser_parse(&loader->parser, &loader->event))
        goto load_error;

    /* These events don't need yaml_event_delete */
    /* Some kind of error occurred */
    if (loader->event.type == YAML_NO_EVENT)
        goto load_error;

    /* Return NULL when we hit the end of a scope */
    if (loader->event.type == YAML_DOCUMENT_END_EVENT ||
        loader->event.type == YAML_MAPPING_END_EVENT ||
        loader->event.type == YAML_SEQUENCE_END_EVENT) {
            /* restore the uplevel event, so it can be properly deleted */
            loader->event = uplevel_event;
            return return_sv;
    }

    /* The rest all need cleanup */
    switch (loader->event.type) {
        char *tag;

        /* Handle loading a mapping */
        case YAML_MAPPING_START_EVENT:
            tag = (char *)loader->event.data.mapping_start.tag;

            /* Handle mapping tagged as a Perl hard reference */
            if (tag && strEQ(tag, TAG_PERL_REF)) {
                return_sv = load_scalar_ref(loader);
                break;
            }

            /* Handle mapping tagged as a Perl typeglob */
            if (tag && strEQ(tag, TAG_PERL_GLOB)) {
                return_sv = load_glob(loader);
                break;
            }

            return_sv = load_mapping(loader, NULL);
            break;

        /* Handle loading a sequence into an array */
        case YAML_SEQUENCE_START_EVENT:
            return_sv = load_sequence(loader);
            break;

        /* Handle loading a scalar */
        case YAML_SCALAR_EVENT:
            return_sv = load_scalar(loader);
            break;

        /* Handle loading an alias node */
        case YAML_ALIAS_EVENT:
            return_sv = load_alias(loader);
            break;

        default:
            croak("%sInvalid event '%d' at top level", ERRMSG, (int) loader->event.type);
    }

    yaml_event_delete(&loader->event);

    /* restore the uplevel event, so it can be properly deleted */
    loader->event = uplevel_event;

    return return_sv;

    load_error:
        croak("%s", loader_error_msg(loader, NULL));
}
コード例 #6
0
ファイル: example2.c プロジェクト: Caspinol/dct
int main(int argc, char *argv[])
{
  sequence *seq;       /* pointer to input sequence data structure  */
  image    **imgs;     /* pointer to input sequence array of images */
  image    *out;       /* pointer the output image */

  char  seq_in[100],  /* input sequence name */
        seq_out[100], /* output sequence name */
        file_out[100]; /* output file name */

  int length;         /* length of the sequence */
  int i;              /* loop index */

  /* Process input arguments */
  if(argc != 3)
    {
      fprintf(stderr,"Usage: %s [input PGM sequence name] [output PGM sequence name]\n", argv[0]);
      exit(0);
    }
  else
    {
      strcpy(seq_in, argv[1]);
      strcpy(seq_out, argv[2]);
    }

  /* Load the input sequence */
  seq = load_sequence(seq_in);

  /* Get a pointer to the sequence images */
  imgs = get_sequence_images(seq);

  /* Get sequence length */
  length = get_sequence_length(seq);

  /* Check if sequence is long enough */
  if(length < 2) {
    fprintf(stderr, "sequence is too short\n");
    exit(1);
  }

  /* Clone the first image to store results */
  out = clone_image(imgs[0]);

  /* Loop through the sequence and write the mean sequence       */
  /* i.e. for each image of the input sequence, write the image  */
  /* resulting from the mean between the current image and       */
  /* the next one.                                               */

  for(i = 0; i < length - 1; i++) {
    /* Compute the mean between the current picture and the next one */
    mean_image(imgs[i], imgs[i+1], out);

    /* Now write out the output image */
    sprintf(file_out, "%s%03d.pgm", seq_out, i);
    printf("Writing out %s\n",file_out);
    pgm_write_image(out, file_out);
  }

  /* We must deallocate the memory the sequence and for the image before */
  /* we finish */
  free_image(out);
  free_sequence(seq);

  return(EXIT_SUCCESS);
}