void UnsharpEngine::init_packages() { for(int i = 0; i < get_total_packages(); i++) { UnsharpPackage *pkg = (UnsharpPackage*)get_package(i); pkg->y1 = src->get_h() * i / get_total_packages(); pkg->y2 = src->get_h() * (i + 1) / get_total_packages(); } }
void ThresholdEngine::init_packages() { for(int i = 0; i < get_total_packages(); i++) { ThresholdPackage *package = (ThresholdPackage*)get_package(i); package->start = data->get_h() * i / get_total_packages(); package->end = data->get_h() * (i + 1) / get_total_packages(); } }
void BurnServer::init_packages() { for(int i = 0; i < get_total_packages(); i++) { BurnPackage *package = (BurnPackage*)get_package(i); package->row1 = plugin->input_ptr->get_h() * i / get_total_packages(); package->row2 = plugin->input_ptr->get_h() * (i + 1) / get_total_packages(); } }
void BlendMacroblock::init_packages() { for(int i = 0; i < get_total_packages(); i++) { BlendPackage *pkg = (BlendPackage*)get_package(i); pkg->number0 = plugin->invalid_blocks.size() * i / get_total_packages(); pkg->number1 = plugin->invalid_blocks.size() * (i + 1) / get_total_packages(); } }
void HueEngine::init_packages() { for(int i = 0; i < LoadServer::get_total_packages(); i++) { HuePackage *pkg = (HuePackage*)get_package(i); pkg->row1 = plugin->input->get_h() * i / LoadServer::get_total_packages(); pkg->row2 = plugin->input->get_h() * (i + 1) / LoadServer::get_total_packages(); } }
void OpticFlow::init_packages() { //printf("OpticFlow::init_packages %d %d\n", __LINE__, get_total_packages()); for(int i = 0; i < get_total_packages(); i++) { OpticFlowPackage *pkg = (OpticFlowPackage*)get_package(i); pkg->macroblock0 = plugin->total_macroblocks * i / get_total_packages(); pkg->macroblock1 = plugin->total_macroblocks * (i + 1) / get_total_packages(); } }
void Warp::init_packages() { int out_h = plugin->frames[0]->get_h(); for(int i = 0; i < get_total_packages(); i++) { WarpPackage *pkg = (WarpPackage*)get_package(i); pkg->y1 = out_h * i / get_total_packages(); pkg->y2 = out_h * (i + 1) / get_total_packages(); } }
void ChromaKeyServer::init_packages() { for(int i = 0; i < get_total_packages(); i++) { ChromaKeyPackage *pkg = (ChromaKeyPackage*)get_package(i); pkg->y1 = plugin->input->get_h() * i / get_total_packages(); pkg->y2 = plugin->input->get_h() * (i + 1) / get_total_packages(); } }
void BlurZoomServer::init_packages() { for(int i = 0; i < get_total_packages(); i++) { BlurZoomPackage *package = (BlurZoomPackage*)get_package(i); package->row1 = plugin->input_ptr->get_h() / get_total_packages() * i; package->row2 = package->row1 + plugin->input_ptr->get_h() / get_total_packages(); if(i >= get_total_packages() - 1) package->row2 = plugin->input_ptr->get_h(); } }
void PhotoScaleEngine::init_packages() { for(int i = 0; i < get_total_packages(); i++) { PhotoScalePackage *package = (PhotoScalePackage*)get_package(i); package->side = i; } top_border = 0; bottom_border = 0; left_border = 0; right_border = 0; }
static bool init_update(struct update_info *info) { struct dstr user_agent = {0}; info->curl = curl_easy_init(); if (!info->curl) { warn("Could not initialize Curl"); return false; } info->local_package = get_package(info->local, "package.json"); info->cache_package = get_package(info->cache, "package.json"); obs_data_t *metadata = get_package(info->cache, "meta.json"); if (metadata) { const char *etag = obs_data_get_string(metadata, "etag"); if (etag) { struct dstr if_none_match = { 0 }; dstr_copy(&if_none_match, "If-None-Match: "); dstr_cat(&if_none_match, etag); info->etag_local = bstrdup(etag); info->header = curl_slist_append(info->header, if_none_match.array); } obs_data_release(metadata); } dstr_copy(&user_agent, "User-Agent: "); dstr_cat(&user_agent, info->user_agent); info->header = curl_slist_append(info->header, user_agent.array); dstr_free(&user_agent); return true; }
static void test_cr_db_add_primary_pkg(TestData *testdata, G_GNUC_UNUSED gconstpointer test_data) { GError *err = NULL; gchar *path; cr_SqliteDb *db; cr_Package *pkg; GTimer *timer = g_timer_new(); gdouble topen, tadd, tclean, tmp; // Create new db path = g_strconcat(testdata->tmp_dir, "/", TMP_PRIMARY_NAME, NULL); g_timer_start(timer); db = cr_db_open_primary(path, &err); topen = g_timer_elapsed(timer, NULL); g_assert(db); g_assert(!err); g_assert(g_file_test(path, G_FILE_TEST_EXISTS)); // Load package pkg = get_package(); // Add package tmp = g_timer_elapsed(timer, NULL); cr_db_add_pkg(db, pkg, &err); tadd = g_timer_elapsed(timer, NULL) - tmp; g_assert(!err); tmp = g_timer_elapsed(timer, NULL); cr_db_close(db, &err); tclean = g_timer_elapsed(timer, NULL) - tmp; //printf("Stats:\nOpen: %f\nAdd: %f\nCleanup: %f\nSum: %f\n", // topen, tadd, tclean, (tadd + tclean)); // Cleanup g_timer_stop(timer); g_timer_destroy(timer); g_free(path); g_assert(!err); }
void ScopeEngine::init_packages() { for(int i = 0; i < LoadServer::get_total_packages(); i++) { ScopePackage *pkg = (ScopePackage*)get_package(i); pkg->row1 = gui->output_frame->get_h() * i / LoadServer::get_total_packages(); pkg->row2 = gui->output_frame->get_h() * (i + 1) / LoadServer::get_total_packages(); } for(int i = 0; i < get_total_clients(); i++) { ScopeUnit *unit = (ScopeUnit*)get_client(i); for(int j = 0; j < HIST_SECTIONS; j++) bzero(unit->bins[j], sizeof(int) * TOTAL_BINS); } }
void HistogramEngine::init_packages() { for(int i = 0; i < get_total_packages(); i++) { HistogramPackage *package = (HistogramPackage*)get_package(i); package->start = data->get_h() * i / get_total_packages(); package->end = data->get_h() * (i + 1) / get_total_packages(); } // Initialize clients here in case some don't get run. for(int i = 0; i < get_total_clients(); i++) { HistogramUnit *unit = (HistogramUnit*)get_client(i); for(int i = 0; i < 5; i++) bzero(unit->accum[i], sizeof(int64_t) * HISTOGRAM_RANGE); } }
static void parse_requires_private (Package *pkg, const char *str, const char *path) { GSList *parsed; GSList *iter; char *trimmed; if (pkg->requires_private) { verbose_error ("Requires.private field occurs twice in '%s'\n", path); exit (1); } trimmed = trim_and_sub (pkg, str, path); parsed = parse_module_list (pkg, trimmed, path); g_free (trimmed); iter = parsed; while (iter != NULL) { Package *req; RequiredVersion *ver = iter->data; req = get_package (ver->name); if (req == NULL) { verbose_error ("Package '%s', required by '%s', not found\n", ver->name, pkg->name ? pkg->name : path); exit (1); } if (pkg->required_versions == NULL) pkg->required_versions = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (pkg->required_versions, ver->name, ver); pkg->requires_private = g_slist_prepend (pkg->requires_private, req); iter = g_slist_next (iter); } g_slist_free (parsed); }
static void packages_foreach (gpointer key, gpointer value, gpointer data) { Package *pkg = get_package (key); if (pkg != NULL) { char *pad; pad = g_strnfill (GPOINTER_TO_INT (data) - strlen (pkg->key), ' '); printf ("%s%s%s - %s\n", pkg->key, pad, pkg->name, pkg->description); g_free (pad); } }
static void test_cr_db_dbinfo_update(TestData *testdata, G_GNUC_UNUSED gconstpointer test_data) { GError *err = NULL; gchar *path; cr_SqliteDb *db; cr_Package *pkg; // Create new db path = g_strconcat(testdata->tmp_dir, "/", TMP_PRIMARY_NAME, NULL); db = cr_db_open_primary(path, &err); g_assert(db); g_assert(!err); g_assert(g_file_test(path, G_FILE_TEST_EXISTS)); // Try cr_db_dbinfo_update cr_db_dbinfo_update(db, "foochecksum", &err); g_assert(!err); // Load package pkg = get_package(); // Add package cr_db_add_pkg(db, pkg, &err); g_assert(!err); // Try cr_db_dbinfo_update again cr_db_dbinfo_update(db, "foochecksum", &err); g_assert(!err); // Cleanup cr_package_free(pkg); g_free(path); cr_db_close(db, &err); g_assert(!err); }
void FrameWriter::init_packages() { for(int i = 0, layer = 0, number = 0; i < get_total_packages(); i++) { FrameWriterPackage *package = (FrameWriterPackage*)get_package(i); package->input = frames[layer][number]; package->path = file->create_path(package->input->get_number()); // printf("FrameWriter::init_packages 1 %p %d %s\n", // package->input, // package->input->get_number(), // package->path); number++; if(number >= len) { layer++; number = 0; } } }
void Color3WayEngine::init_packages() { #if 0 printf("Color3WayEngine::init_packages %d\n", __LINE__); for(int i = 0; i <= 255; i++) { printf("%f\t%f\t%f\n", SHADOW_CURVE((float)i / 255), MIDTONE_CURVE((float)i / 255), HIGHLIGHT_CURVE((float)i / 255)); } #endif for(int i = 0; i < LoadServer::get_total_packages(); i++) { Color3WayPackage *pkg = (Color3WayPackage*)get_package(i); pkg->row1 = plugin->get_input()->get_h() * i / LoadServer::get_total_packages(); pkg->row2 = plugin->get_input()->get_h() * (i + 1) / LoadServer::get_total_packages(); } }
void IVTCEngine::init_packages() { int increment = plugin->input->get_h() / get_total_packages(); increment /= 2; increment *= 2; if(!increment) increment = 2; int y1 = 0; for(int i = 0; i < get_total_packages(); i++) { IVTCPackage *package = (IVTCPackage*)get_package(i); package->y1 = y1; y1 += increment; if(y1 > plugin->input->get_h()) y1 = plugin->input->get_h(); package->y2 = y1; } for(int i = 0; i < get_total_clients(); i++) { IVTCUnit *unit = (IVTCUnit*)get_client(i); unit->clear_totals(); } }
int main (int argc, char **argv) { static int want_my_version = 0; static int want_version = 0; static int want_libs = 0; static int want_cflags = 0; static int want_l_libs = 0; static int want_L_libs = 0; static int want_other_libs = 0; static int want_I_cflags = 0; static int want_other_cflags = 0; static int want_list = 0; static int want_static_lib_list = ENABLE_INDIRECT_DEPS; static int want_short_errors = 0; static int want_uninstalled = 0; static char *variable_name = NULL; static int want_exists = 0; static int want_provides = 0; static int want_requires = 0; static int want_requires_private = 0; static char *required_atleast_version = NULL; static char *required_exact_version = NULL; static char *required_max_version = NULL; static char *required_pkgconfig_version = NULL; static int want_silence_errors = 0; static int want_variable_list = 0; GString *str; GSList *packages = NULL; char *search_path; char *pcbuilddir; gboolean need_newline; FILE *log = NULL; GError *error = NULL; GOptionContext *opt_context; GOptionEntry options_table[] = { { "version", 0, 0, G_OPTION_ARG_NONE, &want_my_version, "output version of pkg-config", NULL }, { "modversion", 0, 0, G_OPTION_ARG_NONE, &want_version, "output version for package", NULL }, { "atleast-pkgconfig-version", 0, 0, G_OPTION_ARG_STRING, &required_pkgconfig_version, "require given version of pkg-config", "VERSION" }, { "libs", 0, 0, G_OPTION_ARG_NONE, &want_libs, "output all linker flags", NULL }, { "static", 0, 0, G_OPTION_ARG_NONE, &want_static_lib_list, "output linker flags for static linking", NULL }, { "short-errors", 0, 0, G_OPTION_ARG_NONE, &want_short_errors, "print short errors", NULL }, { "libs-only-l", 0, 0, G_OPTION_ARG_NONE, &want_l_libs, "output -l flags", NULL }, { "libs-only-other", 0, 0, G_OPTION_ARG_NONE, &want_other_libs, "output other libs (e.g. -pthread)", NULL }, { "libs-only-L", 0, 0, G_OPTION_ARG_NONE, &want_L_libs, "output -L flags", NULL }, { "cflags", 0, 0, G_OPTION_ARG_NONE, &want_cflags, "output all pre-processor and compiler flags", NULL }, { "cflags-only-I", 0, 0, G_OPTION_ARG_NONE, &want_I_cflags, "output -I flags", NULL }, { "cflags-only-other", 0, 0, G_OPTION_ARG_NONE, &want_other_cflags, "output cflags not covered by the cflags-only-I option", NULL }, { "variable", 0, 0, G_OPTION_ARG_STRING, &variable_name, "get the value of variable named NAME", "NAME" }, { "define-variable", 0, 0, G_OPTION_ARG_CALLBACK, &define_variable_cb, "set variable NAME to VALUE", "NAME=VALUE" }, { "exists", 0, 0, G_OPTION_ARG_NONE, &want_exists, "return 0 if the module(s) exist", NULL }, { "print-variables", 0, 0, G_OPTION_ARG_NONE, &want_variable_list, "output list of variables defined by the module", NULL }, { "uninstalled", 0, 0, G_OPTION_ARG_NONE, &want_uninstalled, "return 0 if the uninstalled version of one or more module(s) " "or their dependencies will be used", NULL }, { "atleast-version", 0, 0, G_OPTION_ARG_STRING, &required_atleast_version, "return 0 if the module is at least version VERSION", "VERSION" }, { "exact-version", 0, 0, G_OPTION_ARG_STRING, &required_exact_version, "return 0 if the module is at exactly version VERSION", "VERSION" }, { "max-version", 0, 0, G_OPTION_ARG_STRING, &required_max_version, "return 0 if the module is at no newer than version VERSION", "VERSION" }, { "list-all", 0, 0, G_OPTION_ARG_NONE, &want_list, "list all known packages", NULL }, { "debug", 0, 0, G_OPTION_ARG_NONE, &want_debug_spew, "show verbose debug information", NULL }, { "print-errors", 0, 0, G_OPTION_ARG_NONE, &want_verbose_errors, "show verbose information about missing or conflicting packages," "default if --cflags or --libs given on the command line", NULL }, { "silence-errors", 0, 0, G_OPTION_ARG_NONE, &want_silence_errors, "be silent about errors (default unless --cflags or --libs" "given on the command line)", NULL }, { "errors-to-stdout", 0, 0, G_OPTION_ARG_NONE, &want_stdout_errors, "print errors from --print-errors to stdout not stderr", NULL }, { "print-provides", 0, 0, G_OPTION_ARG_NONE, &want_provides, "print which packages the package provides", NULL }, { "print-requires", 0, 0, G_OPTION_ARG_NONE, &want_requires, "print which packages the package requires", NULL }, { "print-requires-private", 0, 0, G_OPTION_ARG_NONE, &want_requires_private, "print which packages the package requires for static linking", NULL }, #ifdef G_OS_WIN32 { "dont-define-prefix", 0, 0, G_OPTION_ARG_NONE, &dont_define_prefix, "don't try to override the value of prefix for each .pc file found with " "a guesstimated value based on the location of the .pc file", NULL }, { "prefix-variable", 0, 0, G_OPTION_ARG_STRING, &prefix_variable, "set the name of the variable that pkg-config automatically sets", "PREFIX" }, { "msvc-syntax", 0, 0, G_OPTION_ARG_NONE, &msvc_syntax, "output -l and -L flags for the Microsoft compiler (cl)", NULL }, #endif { NULL, 0, 0, 0, NULL, NULL, NULL } }; /* This is here so that we get debug spew from the start, * during arg parsing */ if (getenv ("PKG_CONFIG_DEBUG_SPEW")) { want_debug_spew = TRUE; want_verbose_errors = TRUE; want_silence_errors = FALSE; debug_spew ("PKG_CONFIG_DEBUG_SPEW variable enabling debug spew\n"); } /* Get the built-in search path */ init_pc_path (); if (pkg_config_pc_path == NULL) { /* Even when we override the built-in search path, we still use it later * to add pc_path to the virtual pkg-config package. */ verbose_error ("Failed to get default search path\n"); exit (1); } search_path = getenv ("PKG_CONFIG_PATH"); if (search_path) { add_search_dirs(search_path, G_SEARCHPATH_SEPARATOR_S); } if (getenv("PKG_CONFIG_LIBDIR") != NULL) { add_search_dirs(getenv("PKG_CONFIG_LIBDIR"), G_SEARCHPATH_SEPARATOR_S); } else { add_search_dirs(pkg_config_pc_path, G_SEARCHPATH_SEPARATOR_S); } pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR"); if (pcsysrootdir) { define_global_variable ("pc_sysrootdir", pcsysrootdir); } else { define_global_variable ("pc_sysrootdir", "/"); } pcbuilddir = getenv ("PKG_CONFIG_TOP_BUILD_DIR"); if (pcbuilddir) { define_global_variable ("pc_top_builddir", pcbuilddir); } else { /* Default appropriate for automake */ define_global_variable ("pc_top_builddir", "$(top_builddir)"); } if (getenv ("PKG_CONFIG_DISABLE_UNINSTALLED")) { debug_spew ("disabling auto-preference for uninstalled packages\n"); disable_uninstalled = TRUE; } /* Parse options */ opt_context = g_option_context_new (NULL); g_option_context_add_main_entries (opt_context, options_table, NULL); if (!g_option_context_parse(opt_context, &argc, &argv, &error)) { fprintf (stderr, "%s\n", error->message); return 1; } /* Error printing is determined as follows: * - for --cflags, --libs, etc. it's on by default * and --silence-errors can turn it off * - for --exists, --max-version, etc. and no options * at all, it's off by default and --print-errors * will turn it on */ if (want_my_version || want_version || want_libs || want_cflags || want_l_libs || want_L_libs || want_other_libs || want_I_cflags || want_other_cflags || want_list || want_variable_list) { debug_spew ("Error printing enabled by default due to use of --version, --libs, --cflags, --libs-only-l, --libs-only-L, --libs-only-other, --cflags-only-I, --cflags-only-other or --list. Value of --silence-errors: %d\n", want_silence_errors); if (want_silence_errors && getenv ("PKG_CONFIG_DEBUG_SPEW") == NULL) want_verbose_errors = FALSE; else want_verbose_errors = TRUE; } else { debug_spew ("Error printing disabled by default, value of --print-errors: %d\n", want_verbose_errors); /* Leave want_verbose_errors unchanged, reflecting --print-errors */ } if (want_verbose_errors) debug_spew ("Error printing enabled\n"); else debug_spew ("Error printing disabled\n"); if (want_static_lib_list) enable_private_libs(); else disable_private_libs(); /* honor Requires.private if any Cflags are requested or any static * libs are requested */ if (want_I_cflags || want_other_cflags || want_cflags || want_requires_private || want_exists || (want_static_lib_list && (want_libs || want_l_libs || want_L_libs))) enable_requires_private(); /* ignore Requires if no Cflags or Libs are requested */ if (!want_I_cflags && !want_other_cflags && !want_cflags && !want_libs && !want_l_libs && !want_L_libs && !want_requires && !want_exists) disable_requires(); if (want_my_version) { printf ("%s\n", VERSION); return 0; } if (required_pkgconfig_version) { if (compare_versions (VERSION, required_pkgconfig_version) >= 0) return 0; else return 1; } package_init (); if (want_list) { print_package_list (); return 0; } /* Collect packages from remaining args */ str = g_string_new (""); while (argc > 1) { argc--; argv++; g_string_append (str, *argv); g_string_append (str, " "); } g_option_context_free (opt_context); g_strstrip (str->str); if (getenv("PKG_CONFIG_LOG") != NULL) { log = fopen (getenv ("PKG_CONFIG_LOG"), "a"); if (log == NULL) { fprintf (stderr, "Cannot open log file: %s\n", getenv ("PKG_CONFIG_LOG")); exit (1); } } { gboolean failed = FALSE; GSList *reqs; GSList *iter; reqs = parse_module_list (NULL, str->str, "(command line arguments)"); iter = reqs; while (iter != NULL) { Package *req; RequiredVersion *ver = iter->data; /* override requested versions with cmdline options */ if (required_exact_version) { g_free (ver->version); ver->comparison = EQUAL; ver->version = g_strdup (required_exact_version); } else if (required_atleast_version) { g_free (ver->version); ver->comparison = GREATER_THAN_EQUAL; ver->version = g_strdup (required_atleast_version); } else if (required_max_version) { g_free (ver->version); ver->comparison = LESS_THAN_EQUAL; ver->version = g_strdup (required_max_version); } if (want_short_errors) req = get_package_quiet (ver->name); else req = get_package (ver->name); if (log != NULL) { if (req == NULL) fprintf (log, "%s NOT-FOUND", ver->name); else fprintf (log, "%s %s %s", ver->name, comparison_to_str (ver->comparison), (ver->version == NULL) ? "(null)" : ver->version); fprintf (log, "\n"); } if (req == NULL) { failed = TRUE; verbose_error ("No package '%s' found\n", ver->name); goto nextiter; } if (!version_test (ver->comparison, req->version, ver->version)) { failed = TRUE; verbose_error ("Requested '%s %s %s' but version of %s is %s\n", ver->name, comparison_to_str (ver->comparison), ver->version, req->name, req->version); if (req->url) verbose_error ("You may find new versions of %s at %s\n", req->name, req->url); goto nextiter; } packages = g_slist_prepend (packages, req); nextiter: iter = g_slist_next (iter); } if (log != NULL) { fclose (log); } if (failed) { return 1; } if (want_variable_list) { GSList *tmp; tmp = packages; while (tmp != NULL) { Package *pkg = tmp->data; g_hash_table_foreach(pkg->vars, &print_hashtable_key, NULL); tmp = g_slist_next (tmp); if (tmp) printf ("\n"); } need_newline = FALSE; } } g_string_free (str, TRUE); packages = g_slist_reverse (packages); if (packages == NULL) { fprintf (stderr, "Must specify package names on the command line\n"); exit (1); } if (want_exists) return 0; /* if we got here, all the packages existed. */ if (want_uninstalled) { /* See if > 0 pkgs (including dependencies recursively) were uninstalled */ GSList *tmp; tmp = packages; while (tmp != NULL) { Package *pkg = tmp->data; if (pkg_uninstalled (pkg)) return 0; tmp = g_slist_next (tmp); } return 1; } if (want_version) { GSList *tmp; tmp = packages; while (tmp != NULL) { Package *pkg = tmp->data; printf ("%s\n", pkg->version); tmp = g_slist_next (tmp); } } if (want_provides) { GSList *tmp; tmp = packages; while (tmp != NULL) { Package *pkg = tmp->data; char *key; key = pkg->key; while (*key == '/') key++; if (strlen(key) > 0) printf ("%s = %s\n", key, pkg->version); tmp = g_slist_next (tmp); } } if (want_requires) { GSList *pkgtmp; for (pkgtmp = packages; pkgtmp != NULL; pkgtmp = g_slist_next (pkgtmp)) { Package *pkg = pkgtmp->data; GSList *reqtmp; /* process Requires: */ for (reqtmp = pkg->requires; reqtmp != NULL; reqtmp = g_slist_next (reqtmp)) { Package *deppkg = reqtmp->data; RequiredVersion *req; req = g_hash_table_lookup(pkg->required_versions, deppkg->key); if ((req == NULL) || (req->comparison == ALWAYS_MATCH)) printf ("%s\n", deppkg->key); else printf ("%s %s %s\n", deppkg->key, comparison_to_str(req->comparison), req->version); } } } if (want_requires_private) { GSList *pkgtmp; for (pkgtmp = packages; pkgtmp != NULL; pkgtmp = g_slist_next (pkgtmp)) { Package *pkg = pkgtmp->data; GSList *reqtmp; /* process Requires.private: */ for (reqtmp = pkg->requires_private; reqtmp != NULL; reqtmp = g_slist_next (reqtmp)) { Package *deppkg = reqtmp->data; RequiredVersion *req; if (g_slist_find (pkg->requires, reqtmp->data)) continue; req = g_hash_table_lookup(pkg->required_versions, deppkg->key); if ((req == NULL) || (req->comparison == ALWAYS_MATCH)) printf ("%s\n", deppkg->key); else printf ("%s %s %s\n", deppkg->key, comparison_to_str(req->comparison), req->version); } } } /* Print all flags; then print a newline at the end. */ need_newline = FALSE; if (variable_name) { char *str = packages_get_var (packages, variable_name); printf ("%s", str); g_free (str); need_newline = TRUE; } if (want_I_cflags) { char *str = packages_get_I_cflags (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_other_cflags) { char *str = packages_get_other_cflags (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_cflags) { char *str = packages_get_all_cflags (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } if (want_l_libs) { char *str = packages_get_l_libs (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_L_libs) { char *str = packages_get_L_libs (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_other_libs) { char *str = packages_get_other_libs (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_libs) { char *str = packages_get_all_libs (packages); printf ("%s ", str); g_free (str); need_newline = TRUE; } if (need_newline) printf ("\n"); return 0; }
static gboolean process_package_args (const char *cmdline, GList **packages, FILE *log) { gboolean success = TRUE; GList *reqs; reqs = parse_module_list (NULL, cmdline, "(command line arguments)"); if (reqs == NULL) { fprintf (stderr, "Must specify package names on the command line\n"); fflush (stderr); return FALSE; } for (; reqs != NULL; reqs = g_list_next (reqs)) { Package *req; RequiredVersion *ver = reqs->data; /* override requested versions with cmdline options */ if (required_exact_version) { g_free (ver->version); ver->comparison = EQUAL; ver->version = g_strdup (required_exact_version); } else if (required_atleast_version) { g_free (ver->version); ver->comparison = GREATER_THAN_EQUAL; ver->version = g_strdup (required_atleast_version); } else if (required_max_version) { g_free (ver->version); ver->comparison = LESS_THAN_EQUAL; ver->version = g_strdup (required_max_version); } if (want_short_errors) req = get_package_quiet (ver->name); else req = get_package (ver->name); if (log != NULL) { if (req == NULL) fprintf (log, "%s NOT-FOUND\n", ver->name); else fprintf (log, "%s %s %s\n", ver->name, comparison_to_str (ver->comparison), (ver->version == NULL) ? "(null)" : ver->version); } if (req == NULL) { success = FALSE; verbose_error ("No package '%s' found\n", ver->name); continue; } if (!version_test (ver->comparison, req->version, ver->version)) { success = FALSE; verbose_error ("Requested '%s %s %s' but version of %s is %s\n", ver->name, comparison_to_str (ver->comparison), ver->version, req->name, req->version); if (req->url) verbose_error ("You may find new versions of %s at %s\n", req->name, req->url); continue; } *packages = g_list_prepend (*packages, req); } *packages = g_list_reverse (*packages); return success; }
void MotionScan::init_packages() { // Set package coords //printf("MotionScan::init_packages %d %d\n", __LINE__, get_total_packages()); for(int i = 0; i < get_total_packages(); i++) { MotionScanPackage *pkg = (MotionScanPackage*)get_package(i); pkg->block_x1 = block_x1; pkg->block_x2 = block_x2; pkg->block_y1 = block_y1; pkg->block_y2 = block_y2; pkg->scan_x1 = scan_x1; pkg->scan_x2 = scan_x2; pkg->scan_y1 = scan_y1; pkg->scan_y2 = scan_y2; pkg->step = i; pkg->difference1 = 0; pkg->difference2 = 0; pkg->dx = 0; pkg->dy = 0; pkg->valid = 1; if(!subpixel) { pkg->search_x = pkg->scan_x1 + (pkg->step % x_steps) * (scan_x2 - scan_x1) / x_steps; pkg->search_y = pkg->scan_y1 + (pkg->step / x_steps) * (scan_y2 - scan_y1) / y_steps; pkg->sub_x = 0; pkg->sub_y = 0; } else { pkg->sub_x = pkg->step % (OVERSAMPLE * 2); pkg->sub_y = pkg->step / (OVERSAMPLE * 2); if(horizontal_only) { pkg->sub_y = 0; } if(vertical_only) { pkg->sub_x = 0; } pkg->search_x = pkg->scan_x1 + pkg->sub_x / OVERSAMPLE + 1; pkg->search_y = pkg->scan_y1 + pkg->sub_y / OVERSAMPLE + 1; pkg->sub_x %= OVERSAMPLE; pkg->sub_y %= OVERSAMPLE; // printf("MotionScan::init_packages %d i=%d search_x=%d search_y=%d sub_x=%d sub_y=%d\n", // __LINE__, // i, // pkg->search_x, // pkg->search_y, // pkg->sub_x, // pkg->sub_y); } // printf("MotionScan::init_packages %d %d,%d %d,%d %d,%d\n", // __LINE__, // scan_x1, // scan_x2, // scan_y1, // scan_y2, // pkg->search_x, // pkg->search_y); } }
void MotionScan::scan_frame(VFrame *previous_frame, VFrame *current_frame, int global_range_w, int global_range_h, int global_block_w, int global_block_h, double block_x, double block_y, int frame_type, int tracking_type, int action_type, int horizontal_only, int vertical_only, int source_position, int total_steps, int total_dx, int total_dy, int global_origin_x, int global_origin_y) { this->previous_frame_arg = previous_frame; this->current_frame_arg = current_frame; this->horizontal_only = horizontal_only; this->vertical_only = vertical_only; this->previous_frame = previous_frame_arg; this->current_frame = current_frame_arg; this->global_origin_x = global_origin_x; this->global_origin_y = global_origin_y; subpixel = 0; cache.remove_all_objects(); // Single macroblock int w = current_frame->get_w(); int h = current_frame->get_h(); // Initial search parameters int scan_w = w * global_range_w / 100; int scan_h = h * global_range_h / 100; int block_w = w * global_block_w / 100; int block_h = h * global_block_h / 100; // Location of block in previous frame block_x1 = (int)(w * block_x / 100 - block_w / 2); block_y1 = (int)(h * block_y / 100 - block_h / 2); block_x2 = (int)(w * block_x / 100 + block_w / 2); block_y2 = (int)(h * block_y / 100 + block_h / 2); // Offset to location of previous block. This offset needn't be very accurate // since it's the offset of the previous image and current image we want. if(frame_type == MotionScan::TRACK_PREVIOUS) { block_x1 += total_dx / OVERSAMPLE; block_y1 += total_dy / OVERSAMPLE; block_x2 += total_dx / OVERSAMPLE; block_y2 += total_dy / OVERSAMPLE; } skip = 0; switch(tracking_type) { // Don't calculate case MotionScan::NO_CALCULATE: dx_result = 0; dy_result = 0; skip = 1; break; case MotionScan::LOAD: { // Load result from disk char string[BCTEXTLEN]; sprintf(string, "%s%06d", MOTION_FILE, source_position); //printf("MotionScan::scan_frame %d %s\n", __LINE__, string); FILE *input = fopen(string, "r"); if(input) { int temp = fscanf(input, "%d %d", &dx_result, &dy_result); // HACK //dx_result *= 2; //dy_result *= 2; //printf("MotionScan::scan_frame %d %d %d\n", __LINE__, dx_result, dy_result); fclose(input); skip = 1; } break; } // Scan from scratch default: skip = 0; break; } if(!skip && test_match) { if(previous_frame->data_matches(current_frame)) { printf("MotionScan::scan_frame: data matches. skipping.\n"); dx_result = 0; dy_result = 0; skip = 1; } } // Perform scan if(!skip) { //printf("MotionScan::scan_frame %d\n", __LINE__); // Location of block in current frame int origin_offset_x = this->global_origin_x * w / 100; int origin_offset_y = this->global_origin_y * h / 100; int x_result = block_x1 + origin_offset_x; int y_result = block_y1 + origin_offset_y; // printf("MotionScan::scan_frame 1 %d %d %d %d %d %d %d %d\n", // block_x1 + block_w / 2, // block_y1 + block_h / 2, // block_w, // block_h, // block_x1, // block_y1, // block_x2, // block_y2); while(1) { // Cache needs to be cleared if downsampling is used because the sums of // different downsamplings can't be compared. // Subpixel never uses the cache. // cache.remove_all_objects(); scan_x1 = x_result - scan_w / 2; scan_y1 = y_result - scan_h / 2; scan_x2 = x_result + scan_w / 2; scan_y2 = y_result + scan_h / 2; // Zero out requested values if(horizontal_only) { scan_y1 = block_y1; scan_y2 = block_y1 + 1; } if(vertical_only) { scan_x1 = block_x1; scan_x2 = block_x1 + 1; } // printf("MotionScan::scan_frame 1 %d %d %d %d %d %d %d %d\n", // block_x1, // block_y1, // block_x2, // block_y2, // scan_x1, // scan_y1, // scan_x2, // scan_y2); // Clamp the block coords before the scan so we get useful scan coords. clamp_scan(w, h, &block_x1, &block_y1, &block_x2, &block_y2, &scan_x1, &scan_y1, &scan_x2, &scan_y2, 0); // printf("MotionScan::scan_frame 1 %d block_x1=%d block_y1=%d block_x2=%d block_y2=%d\n scan_x1=%d scan_y1=%d scan_x2=%d scan_y2=%d\n x_result=%d y_result=%d\n", // __LINE__, // block_x1, // block_y1, // block_x2, // block_y2, // scan_x1, // scan_y1, // scan_x2, // scan_y2, // x_result, // y_result); // Give up if invalid coords. if(scan_y2 <= scan_y1 || scan_x2 <= scan_x1 || block_x2 <= block_x1 || block_y2 <= block_y1) break; // For subpixel, the top row and left column are skipped if(subpixel) { //printf("MotionScan::scan_frame %d %d %d\n", __LINE__, x_result, y_result); // Scan every subpixel in a 2 pixel * 2 pixel square total_pixels = (2 * OVERSAMPLE) * (2 * OVERSAMPLE); this->total_steps = total_pixels; // These aren't used in subpixel this->x_steps = OVERSAMPLE * 2; this->y_steps = OVERSAMPLE * 2; set_package_count(this->total_steps); process_packages(); // Get least difference int64_t min_difference = -1; for(int i = 0; i < get_total_packages(); i++) { MotionScanPackage *pkg = (MotionScanPackage*)get_package(i); //printf("MotionScan::scan_frame %d search_x=%d search_y=%d sub_x=%d sub_y=%d diff1=%lld diff2=%lld\n", //__LINE__, pkg->search_x, pkg->search_y, pkg->sub_x, pkg->sub_y, pkg->difference1, pkg->difference2); if(pkg->difference1 < min_difference || min_difference == -1) { min_difference = pkg->difference1; // The sub coords are 1 pixel up & left of the block coords x_result = pkg->search_x * OVERSAMPLE + pkg->sub_x; y_result = pkg->search_y * OVERSAMPLE + pkg->sub_y; // Fill in results dx_result = block_x1 * OVERSAMPLE - x_result; dy_result = block_y1 * OVERSAMPLE - y_result; //printf("MotionScan::scan_frame %d dx_result=%d dy_result=%d diff=%lld\n", //__LINE__, dx_result, dy_result, min_difference); } if(pkg->difference2 < min_difference) { min_difference = pkg->difference2; x_result = pkg->search_x * OVERSAMPLE - pkg->sub_x; y_result = pkg->search_y * OVERSAMPLE - pkg->sub_y; dx_result = block_x1 * OVERSAMPLE - x_result; dy_result = block_y1 * OVERSAMPLE - y_result; //printf("MotionScan::scan_frame %d dx_result=%d dy_result=%d diff=%lld\n", //__LINE__, dx_result, dy_result, min_difference); } } break; } else // Single pixel { total_pixels = (scan_x2 - scan_x1) * (scan_y2 - scan_y1); this->total_steps = MIN(total_steps, total_pixels); if(this->total_steps == total_pixels) { x_steps = scan_x2 - scan_x1; y_steps = scan_y2 - scan_y1; } else { x_steps = (int)sqrt(this->total_steps); y_steps = (int)sqrt(this->total_steps); } // Use downsampled images // if(scan_x2 - scan_x1 > x_steps * 4 || // scan_y2 - scan_y1 > y_steps * 4) // { // printf("MotionScan::scan_frame %d total_pixels=%d total_steps=%d x_steps=%d y_steps=%d x y steps=%d\n", // __LINE__, // total_pixels, // total_steps, // x_steps, // y_steps, // x_steps * y_steps); // // if(!downsampled_previous || // !downsampled_previous->equivalent(previous_frame_arg)) // { // delete downsampled_previous; // downsampled_previous = new VFrame(*previous_frame_arg); // } // // if(!downsampled_current || // !downsampled_current->equivalent(current_frame_arg)) // { // delete downsampled_current; // downsampled_current = new VFrame(*current_frame_arg); // } // // // if(!downsample) // downsample = new DownSampleServer(get_total_clients(), // get_total_clients()); // downsample->process_frame(downsampled_previous, // previous_frame_arg, // 1, // 1, // 1, // 1, // (scan_y2 - scan_y1) / y_steps, // (scan_x2 - scan_x1) / x_steps, // 0, // 0); // downsample->process_frame(downsampled_current, // current_frame_arg, // 1, // 1, // 1, // 1, // (scan_y2 - scan_y1) / y_steps, // (scan_x2 - scan_x1) / x_steps, // 0, // 0); // this->previous_frame = downsampled_previous; // this->current_frame = downsampled_current; // } // printf("MotionScan::scan_frame %d this->total_steps=%d\n", // __LINE__, // this->total_steps); set_package_count(this->total_steps); process_packages(); // Get least difference int64_t min_difference = -1; for(int i = 0; i < get_total_packages(); i++) { MotionScanPackage *pkg = (MotionScanPackage*)get_package(i); //printf("MotionScan::scan_frame %d search_x=%d search_y=%d sub_x=%d sub_y=%d diff1=%lld diff2=%lld\n", //__LINE__, pkg->search_x, pkg->search_y, pkg->sub_x, pkg->sub_y, pkg->difference1, pkg->difference2); if(pkg->difference1 < min_difference || min_difference == -1) { min_difference = pkg->difference1; x_result = pkg->search_x; y_result = pkg->search_y; x_result *= OVERSAMPLE; y_result *= OVERSAMPLE; //printf("MotionScan::scan_frame %d x_result=%d y_result=%d diff=%lld\n", //__LINE__, block_x1 * OVERSAMPLE - x_result, block_y1 * OVERSAMPLE - y_result, pkg->difference1); } } // If a new search is required, rescale results back to pixels. if(this->total_steps >= total_pixels) { // Single pixel accuracy reached. Now do exhaustive subpixel search. if(action_type == MotionScan::STABILIZE || action_type == MotionScan::TRACK || action_type == MotionScan::NOTHING) { //printf("MotionScan::scan_frame %d %d %d\n", __LINE__, x_result, y_result); x_result /= OVERSAMPLE; y_result /= OVERSAMPLE; scan_w = 2; scan_h = 2; subpixel = 1; } else { // Fill in results and quit dx_result = block_x1 * OVERSAMPLE - x_result; dy_result = block_y1 * OVERSAMPLE - y_result; //printf("MotionScan::scan_frame %d %d %d\n", __LINE__, dx_result, dy_result); break; } } else // Reduce scan area and try again { scan_w = (scan_x2 - scan_x1) / 2; scan_h = (scan_y2 - scan_y1) / 2; x_result /= OVERSAMPLE; y_result /= OVERSAMPLE; } } } dx_result *= -1; dy_result *= -1; } //printf("MotionScan::scan_frame %d\n", __LINE__); if(vertical_only) dx_result = 0; if(horizontal_only) dy_result = 0; // Write results if(tracking_type == MotionScan::SAVE) { char string[BCTEXTLEN]; sprintf(string, "%s%06d", MOTION_FILE, source_position); FILE *output = fopen(string, "w"); if(output) { fprintf(output, "%d %d\n", dx_result, dy_result); fclose(output); } else { printf("MotionScan::scan_frame %d: save coordinate failed", __LINE__); } } // printf("MotionScan::scan_frame %d dx=%.2f dy=%.2f\n", // __LINE__, // (float)this->dx_result / OVERSAMPLE, // (float)this->dy_result / OVERSAMPLE); }