// Select a decoder from the given list for the given codec. The selection // can be influenced by the selection string, which can specify a priority // list of preferred decoders. // This returns a list of decoders to try, with the preferred decoders first. // The selection string corresponds to --vd/--ad directly, and has the // following syntax: // selection = [<entry> ("," <entry>)*] // entry = <family> ":" <decoder> // prefer decoder // entry = <family> ":*" // prefer all decoders // entry = "+" <family> ":" <decoder> // force a decoder // entry = "-" <family> ":" <decoder> // exclude a decoder // entry = "-" // don't add fallback decoders // Forcing a decoder means it's added even if the codec mismatches. struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, const char *codec, const char *selection) { struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list); struct mp_decoder_list *remove = talloc_zero(NULL, struct mp_decoder_list); if (!codec) codec = "unknown"; bool stop = false; bstr sel = bstr0(selection); while (sel.len) { bstr entry; bstr_split_tok(sel, ",", &entry, &sel); if (bstr_equals0(entry, "-")) { stop = true; break; } bool force = bstr_eatstart0(&entry, "+"); bool exclude = !force && bstr_eatstart0(&entry, "-"); struct mp_decoder_list *dest = exclude ? remove : list; bstr family, decoder; if (!bstr_split_tok(entry, ":", &family, &decoder)) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Decoders must be specified as " "'family:decoder' for the --ad/--vd options.\n"); break; } if (bstr_equals0(decoder, "*")) { for (int n = 0; n < all->num_entries; n++) { struct mp_decoder_entry *cur = &all->entries[n]; if (bstr_equals0(family, cur->family)) add_new(dest, cur, codec); } } else { add_new(dest, find_decoder(all, family, decoder), force ? NULL : codec); } } if (!stop) { // Add the remaining codecs which haven't been added yet for (int n = 0; n < all->num_entries; n++) add_new(list, &all->entries[n], codec); } for (int n = 0; n < remove->num_entries; n++) { struct mp_decoder_entry *ex = &remove->entries[n]; struct mp_decoder_entry *del = find_decoder(list, bstr0(ex->family), bstr0(ex->decoder)); if (del) { int index = del - &list->entries[0]; MP_TARRAY_REMOVE_AT(list->entries, list->num_entries, index); } } talloc_free(remove); return list; }
// selection is a ","-separated list of decoders, all in the given family. struct mp_decoder_list *mp_select_decoder_list(struct mp_decoder_list *all, const char *codec, const char *family, const char *selection) { struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list); bstr sel = bstr0(selection); while (sel.len) { bstr decoder; bstr_split_tok(sel, ",", &decoder, &sel); add_new(list, find_decoder(all, bstr0(family), decoder), codec); } return list; }
bool add_new_always(std::size_t& added, thread_queue* addfrom, std::unique_lock<mutex_type> &lk, bool steal = false) { HPX_ASSERT(lk.owns_lock()); #ifdef HPX_HAVE_THREAD_CREATION_AND_CLEANUP_RATES util::tick_counter tc(add_new_time_); #endif if (0 == addfrom->new_tasks_count_.load(boost::memory_order_relaxed)) return false; // create new threads from pending tasks (if appropriate) boost::int64_t add_count = -1; // default is no constraint // if we are desperate (no work in the queues), add some even if the // map holds more than max_count if (HPX_LIKELY(max_count_)) { std::size_t count = thread_map_.size(); if (max_count_ >= count + min_add_new_count) { //-V104 HPX_ASSERT(max_count_ - count < static_cast<std::size_t>((std::numeric_limits <boost::int64_t>::max)())); add_count = static_cast<boost::int64_t>(max_count_ - count); if (add_count < min_add_new_count) add_count = min_add_new_count; if (add_count > max_add_new_count) add_count = max_add_new_count; } else if (work_items_.empty()) { add_count = min_add_new_count; // add this number of threads max_count_ += min_add_new_count; // increase max_count //-V101 } else { return false; } } std::size_t addednew = add_new(add_count, addfrom, lk, steal); added += addednew; return addednew != 0; }
t_grille *get_data(char *link, int *i, int *j) { int fd; char *line; char **pars; t_grille *grille; fd = open(link, O_RDONLY); *j = 0; grille = NULL; while ((line = get_next_line(fd))) { pars = my_str_to_wordtab(line); (*i) = -1; while (pars[++*i] != '\0' && ((*i)) < WIDTH) grille = add_new(grille, (*i), (*j), my_getnbr(pars[(*i)]) / 2); free(line); (*j)++; } return (grille); }
bool add_new_if_possible(std::size_t& added, thread_queue* addfrom, std::unique_lock<mutex_type> &lk, bool steal = false) { HPX_ASSERT(lk.owns_lock()); #ifdef HPX_HAVE_THREAD_CREATION_AND_CLEANUP_RATES util::tick_counter tc(add_new_time_); #endif if (0 == addfrom->new_tasks_count_.load(boost::memory_order_relaxed)) return false; // create new threads from pending tasks (if appropriate) boost::int64_t add_count = -1; // default is no constraint // if the map doesn't hold max_count threads yet add some // FIXME: why do we have this test? can max_count_ ever be zero? if (HPX_LIKELY(max_count_)) { std::size_t count = thread_map_.size(); if (max_count_ >= count + min_add_new_count) { //-V104 HPX_ASSERT(max_count_ - count < static_cast<std::size_t>((std::numeric_limits <boost::int64_t>::max)())); add_count = static_cast<boost::int64_t>(max_count_ - count); if (add_count < min_add_new_count) add_count = min_add_new_count; } else { return false; } } std::size_t addednew = add_new(add_count, addfrom, lk, steal); added += addednew; return addednew != 0; }
//*****************MOT************************************************************** //Constructeur tout bête Mot::Mot(string s, int No, int i){ if (!s.empty()){ name = s; add_new(No, i); } }
void mp_append_decoders(struct mp_decoder_list *list, struct mp_decoder_list *a) { for (int n = 0; n < a->num_entries; n++) add_new(list, &a->entries[n], NULL); }