static String get_blank_prefix( CharSource *i ) { String result; int ch = i->peek(); while (is_noise(ch)) { result.push( i->get() ); ch = i->peek(); } // i.peek() is not one of noises return result; }
static void process_image_data(struct fp_img_dev *dev, char **output, int *output_height) { //pixman stuff taken from libfprint/pixman.c, adapted for my purposes. pixman_image_t *orig, *resized; pixman_transform_t transform; struct vfs0050_dev *vfs_dev = dev->priv; struct vfs0050_line *line, *calibration_line; char *buf = malloc(vfs_dev->scanbuf_idx); int lines = vfs_dev->scanbuf_idx / VFS0050_FRAME_SIZE; int i, x, sum, last_sum, diff; int new_height; //just grab one around middle, there should be 100 calibration_line = (struct vfs0050_line *) ((char *) vfs_dev->calbuf + (50 * VFS0050_FRAME_SIZE)); new_height = 0; for (i = 0; i < lines; i++) { line = (struct vfs0050_line *) ((char *) vfs_dev->scanbuf + (i * VFS0050_FRAME_SIZE)); if (!is_noise(line)) memcpy(buf + (new_height++ * VFS0050_IMG_WIDTH), line->row, VFS0050_IMG_WIDTH); else fp_dbg("removed noise at line: %d\n", i); } orig = pixman_image_create_bits(PIXMAN_a8, VFS0050_IMG_WIDTH, new_height, (uint32_t *) buf, VFS0050_IMG_WIDTH); new_height *= VFS0050_SCALE_FACTOR; //scale for resized image resized = pixman_image_create_bits(PIXMAN_a8, VFS0050_IMG_WIDTH, new_height, NULL, VFS0050_IMG_WIDTH); pixman_transform_init_identity(&transform); pixman_transform_scale(NULL, &transform, pixman_int_to_fixed(1), pixman_double_to_fixed(0.2)); pixman_image_set_transform(orig, &transform); pixman_image_set_filter(orig, PIXMAN_FILTER_BEST, NULL, 0); pixman_image_composite32(PIXMAN_OP_SRC, orig, NULL, resized, 0, 0, 0, 0, 0, 0, VFS0050_IMG_WIDTH, new_height ); memcpy(buf, pixman_image_get_data(resized), VFS0050_IMG_WIDTH * new_height); pixman_image_unref(orig); pixman_image_unref(resized); *output_height = new_height; *output = buf; }
static String get_string( CharSource *i ) { String result; int ch = i->peek(); if (is_singleton(ch)) { result.push(i->get()); } else { while ((ch != EOF) && (!is_noise(ch)) && (!is_singleton(ch))) { if (is_escape(ch)) { i->get(); ch = i->peek(); } if (ch != EOF) { result.push( i->get() ); ch = i->peek(); } } } return result; }
void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, uint16_t frame_len) { uint8_t g, b, sfb; uint8_t group = 0; uint16_t nshort = frame_len/8; uint16_t i, k; real_t tmp; if (ics->ms_mask_present >= 1) { for (g = 0; g < ics->num_window_groups; g++) { for (b = 0; b < ics->window_group_length[g]; b++) { for (sfb = 0; sfb < ics->max_sfb; sfb++) { /* If intensity stereo coding or noise substitution is on for a particular scalefactor band, no M/S stereo decoding is carried out. */ if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) { for (i = ics->swb_offset[sfb]; i < ics->swb_offset[sfb+1]; i++) { k = (group*nshort) + i; tmp = l_spec[k] - r_spec[k]; l_spec[k] = l_spec[k] + r_spec[k]; r_spec[k] = tmp; } } } group++; } } } }
bool Formants::calc() { if (is_noise()) return false; if (!sound_calc_formants(sound, &opts)) abort(); f1 = 0; for (size_t i = 0; i < sound->n_samples; i += 1) f1 += sound_get_f1(sound, i); f2 = 0; for (size_t i = 0; i < sound->n_samples; i += 1) f2 += sound_get_f2(sound, i); f1 /= sound->n_samples; f2 /= sound->n_samples; return f1 >= F1_MIN && f1 <= F1_MAX && f2 >= F2_MIN && f2 <= F2_MAX; }
bool mspectrumcondition::condition(mspectrum &_s) { /* * bail out if conditioning has been turned off */ if(m_bUsePhosphoDetection) { if(!find_loss(_s,98.0,3.0)) { return false; } } _s.m_vMINeutral.clear(); sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz); if(_s.m_dMH < 1.0 && !_s.m_vMI.empty()) { m_bCharge = true; if(_s.m_fZ == 2.0) { _s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.2; } else if(_s.m_fZ == 3.0) { _s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.7; } } if(_s.m_vdStats.size() == 0) { vector<mi>::iterator itMI = _s.m_vMI.begin(); vector<mi>::iterator itEnd = _s.m_vMI.end(); double dSum = 0.0; double dMax = 0.0; while(itMI != itEnd) { if(dMax < itMI->m_fI) { dMax = itMI->m_fI; } dSum += itMI->m_fI; itMI++; } _s.m_vdStats.push_back(dSum); _s.m_vdStats.push_back(dMax); _s.m_vdStats.push_back(m_fFactor); } if(_s.m_fZ > m_fMaxZ) { return false; } if(!m_bCondition) { return true; } /* * check the parent ion charge and return false if it is too large */ if(m_bUseNoiseSuppression) { /* * check the parent ion mass against the minimum mass allowed (about 600.0 is usually safe) */ if(m_bUseMinMass) { if(_s.m_dMH < m_fMinMass) return false; } if(m_bUseChargeSuppression) { if((long)(_s.m_fZ+0.5) > m_lMaxCharge) { return false; } } } size_t tSize = _s.m_vMI.size(); size_t a = 0; float fMaxI = 0; /* * this method doesn't really remove isotopes: it cleans up multiple intensities within one Dalton * of each other. */ // sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz); if(m_bUseIsotopes) { remove_isotopes(_s); } /* * remove ions near the parent ion m/z */ if(m_bUseParent) { remove_parent(_s); } /* * remove low mass immonium ions prior to normalization */ if(m_bUseLowestMass) { remove_low_masses(_s); } /* * normalize the spectrum */ vector<mi>::iterator itMI = _s.m_vMI.begin(); vector<mi>::iterator itEnd = _s.m_vMI.end(); double dSum = 0.0; double dMax = 0.0; while(itMI != itEnd) { if(dMax < itMI->m_fI) { dMax = itMI->m_fI; } dSum += itMI->m_fI; itMI++; } _s.m_vdStats.clear(); _s.m_vdStats.push_back(dSum); _s.m_vdStats.push_back(dMax); _s.m_vdStats.push_back(m_fFactor); if(m_bUseDynamicRange) { dynamic_range(_s); } if(m_bUseNeutralLoss) { remove_neutral(_s); } /* * reject the spectrum if there aren't enough peaks */ if(m_bUseMinSize) { if((long)_s.m_vMI.size() < m_lMinSize) return false; } /* * check to see if the spectrum has the characteristics of noise */ if(m_bUseNoiseSuppression) { if(is_noise(_s)) { return false; } } /* * retrieve the N most intense peaks */ if(m_bUseIsotopes) { clean_isotopes(_s); } if(m_bUseMaxPeaks) { sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMI); remove_small(_s); } sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz); itMI = _s.m_vMI.begin(); itEnd = _s.m_vMI.end(); dSum = 0.0; dMax = 0.0; while(itMI != itEnd) { if(dMax < itMI->m_fI) { dMax = itMI->m_fI; } dSum += itMI->m_fI; itMI++; } _s.m_vdStats[0] = dSum*m_fFactor; _s.m_vdStats[1] = dMax*m_fFactor; _s.m_vdStats[2] = m_fFactor; return true; }