Esempio n. 1
0
static LOOP_IN unsigned get_ent_star_general(
    unsigned const* highs_of_lows_offsets,
    unsigned const* highs_of_lows,
    unsigned const* lows_of_highs,
    unsigned lows_per_high,
    unsigned low,
    unsigned* star)
{
  unsigned first_up = highs_of_lows_offsets[low];
  unsigned last_up = highs_of_lows_offsets[low + 1];
  unsigned size = 0;
  for (unsigned i = first_up; i < last_up; ++i) {
    unsigned high = highs_of_lows[i];
    for (unsigned j = 0; j < lows_per_high; ++j) {
      unsigned star_low = lows_of_highs[high * lows_per_high + j];
      if (star_low == low)
        continue;
      size = add_unique(star, size, star_low);
    }
  }
  return size;
}
Esempio n. 2
0
mlt_position mlt_multitrack_clip( mlt_multitrack self, mlt_whence whence, int index )
{
	mlt_position position = 0;
	int i = 0;
	int j = 0;
	mlt_position *map = calloc( 1000, sizeof( mlt_position ) );
	int count = 0;

	for ( i = 0; i < self->count; i ++ )
	{
		// Get the producer for this track
		mlt_producer producer = self->list[ i ]->producer;

		// If it's assigned and not a hidden track
		if ( producer != NULL )
		{
			// Get the properties of this producer
			mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );

			// Determine if it's a playlist
			mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );

			// Special case consideration of playlists
			if ( playlist != NULL )
			{
				for ( j = 0; j < mlt_playlist_count( playlist ); j ++ )
					count = add_unique( map, count, mlt_playlist_clip( playlist, mlt_whence_relative_start, j ) );
				count = add_unique( map, count, mlt_producer_get_out( producer ) + 1 );
			}
			else
			{
				count = add_unique( map, count, 0 );
				count = add_unique( map, count, mlt_producer_get_out( producer ) + 1 );
			}
		}
	}

	// Now sort the map
	qsort( map, count, sizeof( mlt_position ), position_compare );

	// Now locate the requested index
	switch( whence )
	{
		case mlt_whence_relative_start:
			if ( index < count )
				position = map[ index ];
			else
				position = map[ count - 1 ];
			break;

		case mlt_whence_relative_current:
			position = mlt_producer_position( MLT_MULTITRACK_PRODUCER( self ) );
			for ( i = 0; i < count - 2; i ++ )
				if ( position >= map[ i ] && position < map[ i + 1 ] )
					break;
			index += i;
			if ( index >= 0 && index < count )
				position = map[ index ];
			else if ( index < 0 )
				position = map[ 0 ];
			else
				position = map[ count - 1 ];
			break;

		case mlt_whence_relative_end:
			if ( index < count )
				position = map[ count - index - 1 ];
			else
				position = map[ 0 ];
			break;
	}

	// Free the map
	free( map );

	return position;
}
Esempio n. 3
0
/**
 * gom_command_builder_build_create:
 * @builder: (in): A #GomCommandBuilder.
 * @version: the version of the database.
 *
 * Builds a list of #GomCommand to update the table for the
 * resource_type associated with @builder up to @version.
 *
 * Returns: (element-type GomCommand) (transfer full): A #GList of #GomCommand.
 */
GList *
gom_command_builder_build_create (GomCommandBuilder *builder,
                                  guint              version)
{
   GomCommandBuilderPrivate *priv;
   GomResourceClass *klass;
   GomCommand *command;
   GList *ret = NULL;
   GString *str;
   GParamSpec *primary_pspec, **pspecs;
   guint n_pspecs;
   guint i;

   g_return_val_if_fail(GOM_IS_COMMAND_BUILDER(builder), NULL);
   g_return_val_if_fail(version >= 1, NULL);

   priv = builder->priv;

   klass = g_type_class_ref(priv->resource_type);

   primary_pspec = g_object_class_find_property(G_OBJECT_CLASS(klass),
                                                klass->primary_key);
   g_assert(primary_pspec);

   pspecs = g_object_class_list_properties(G_OBJECT_CLASS(klass), &n_pspecs);

   /* Create the table if it doesn't already exist*/
   if (version == 1) {
      str = g_string_new("CREATE TABLE IF NOT EXISTS ");
      add_table_name(str, klass);
      g_string_append(str, "(");
      add_pkey_column(str, klass);

      for (i = 0; i < n_pspecs; i++) {
         if (pspecs[i] != primary_pspec &&
             is_mapped(pspecs[i]) &&
             is_new_in_version(pspecs[i], version)) {
            g_string_append(str, ",");
            g_string_append_printf(str, "'%s' %s",
                                   pspecs[i]->name,
                                   sql_type_for_column (pspecs[i]));
            add_reference(str, pspecs[i]);
            add_unique(str, pspecs[i]);
            add_notnull(str, pspecs[i]);
         }
      }
      g_string_append(str, ")");
      command = g_object_new(GOM_TYPE_COMMAND,
                             "adapter", priv->adapter,
                             "sql", str->str,
                             NULL);
      ret = g_list_prepend(NULL, command);
      g_string_free(str, TRUE);

      goto out;
   }

   /* And now each of the columns for versions > 1 */
   for (i = 0; i < n_pspecs; i++) {
     if (pspecs[i] != primary_pspec &&
         is_mapped(pspecs[i]) &&
         is_new_in_version(pspecs[i], version)) {
       str = g_string_new("ALTER TABLE ");
       add_table_name(str, klass);
       g_string_append(str, " ADD COLUMN ");
       g_string_append_printf(str, "'%s' %s",
                              pspecs[i]->name,
                              sql_type_for_column (pspecs[i]));
       add_unique(str, pspecs[i]);
       add_notnull(str, pspecs[i]);
       add_reference(str, pspecs[i]);

       command = g_object_new(GOM_TYPE_COMMAND,
                              "adapter", priv->adapter,
                              "sql", str->str,
                              NULL);
       ret = g_list_prepend(ret, command);
       g_string_free(str, TRUE);
     }
   }

out:
   g_free(pspecs);

   g_type_class_unref(klass);

   return g_list_reverse(ret);;
}