/*---------------------------------------------------------------------------*/ void uip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst) { uint8_t best = 0; /* number of bit in common with best match */ uint8_t n = 0; uip_ds6_addr_t *matchaddr = NULL; if(!uip_is_addr_link_local(dst) && (!uip_is_addr_mcast(dst) || uip_is_addr_routable_mcast(dst))) { /* find longest match */ for(locaddr = uip_ds6_if.addr_list; locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) { /* Only preferred global (not link-local) addresses */ if(locaddr->isused && locaddr->state == ADDR_PREFERRED && !uip_is_addr_link_local(&locaddr->ipaddr)) { n = get_match_length(dst, &locaddr->ipaddr); if(n >= best) { best = n; matchaddr = locaddr; } } } } else { matchaddr = uip_ds6_get_link_local(ADDR_PREFERRED); } /* use the :: (unspecified address) as source if no match found */ if(matchaddr == NULL) { uip_create_unspecified(src); } else { uip_ipaddr_copy(src, &matchaddr->ipaddr); } }
int SRAssembler::do_alignment(int round, int lib_idx, int idx) { Library lib = this->libraries[lib_idx]; logger->info("Aligning: round = " + int2str(round) + " Lib (" + int2str(lib_idx+1) + "/" + int2str(this->libraries.size()) + "), Reads (" + int2str(idx) + "/" + int2str(lib.get_num_parts()) + ")"); Aligner* aligner = get_aligner(round); string program_name = aligner->get_program_name(); if (round == 1) program_name += "_init"; Params params = this->read_param_file(program_name); aligner->do_alignment(get_index_name(round), get_type(round), get_match_length(round), get_mismatch_allowed(round), lib.get_split_file_name(idx, aligner->get_format()), params, get_output_file_name(round, lib_idx, idx)); int ret = aligner->parse_output(get_output_file_name(round, lib_idx, idx), mapped_reads, lib.get_split_file_name(idx, lib.get_format()), lib.get_matched_left_read_name(round, idx), lib.get_matched_right_read_name(round, idx), fastq_format, lib.get_format()); string cmd = "rm -f " + get_output_file_name(round, lib_idx, idx); save_mapped_reads(round); run_shell_command(cmd); return ret; }
static int single_side_pattern_match(sample **audio_buf, const audio_format **audio_fmt, int nbufs, int missing, int consec_lost) { sample *pat, *dst; uint16_t match_length; int remain, bytes_per_sample, buffer_samples, match_samples; if ((audio_buf[missing - 1] == NULL) || (nbufs < 2)) { debug_msg("no prior audio\n"); return FALSE; } bytes_per_sample = audio_fmt[missing]->bits_per_sample * audio_fmt[missing]->channels / 8; buffer_samples = audio_fmt[missing - 1]->bytes_per_block / bytes_per_sample * audio_fmt[missing - 1]->channels; match_samples = MATCH_WINDOW * audio_fmt[missing - 1]->channels, match_length = get_match_length(audio_buf[missing - 1], buffer_samples, match_samples, audio_fmt[missing - 1]->sample_rate); remain = buffer_samples; pat = audio_buf[missing-1] + (remain - match_length); dst = audio_buf[missing]; while(remain > 0) { match_length = min(remain, match_length); memcpy(dst, pat, match_length * sizeof(sample)); remain -= match_length; dst += match_length; } if (consec_lost > 0) { fade_buffer(audio_buf[missing], audio_fmt[missing], consec_lost); } return TRUE; }
/*---------------------------------------------------------------------------*/ void uip_netif_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst) { u8_t best = 0; /* number of bit in common with best match*/ u8_t n = 0; u8_t index = 0; if(!uip_is_addr_link_local(dst) && !uip_is_addr_mcast(dst)) { for(i = 1; i < UIP_CONF_NETIF_MAX_ADDRESSES; ++i) { if(uip_netif_physical_if.addresses[i].state == PREFERRED){ n = get_match_length(dst, &(uip_netif_physical_if.addresses[i].ipaddr)); if(n >= best){ best = n; index = i; } } } } uip_ipaddr_copy(src, &(uip_netif_physical_if.addresses[index].ipaddr)); return; }