コード例 #1
0
static void mel_loglookup_with_offset(front_cep *cepobj,
                                      front_channel *channel)
/*
**  pwr spect -> filter bank output */
{
  int ii;

  if (channel->shift > 0)
    for (ii = 0; ii < channel->num_freq; ii++)
    {
      channel->filterbank[ii] = (cepdata) log_lookup(&cepobj->logtab,
                                (int)(channel->filterbank[ii] +
                                      SHIFT_DOWN(cepobj->mel_offset[ii], channel->shift)),
                                channel->shift);
    }
  else
    for (ii = 0; ii < channel->num_freq; ii++)
    {
      channel->filterbank[ii] = (cepdata) log_lookup(&cepobj->logtab,
                                (int)(channel->filterbank[ii] +
                                      SHIFT_UP(cepobj->mel_offset[ii], -channel->shift)),
                                channel->shift);
    }

  return;
}
コード例 #2
0
ファイル: logfs.c プロジェクト: fenster/xv6-staus-treffert
int
log_writei(struct inode *ip, char *src, uint off, uint n)
{
  uint tot, m, i, j;
  struct buf *tbp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
      return -1;
    return devsw[ip->major].write(ip, src, n);
  }

  if(off + n < off)
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;


  b_index = 0; // new xfer, start keeping track of open bufs

  /* allocate all space needed */
  for(i=0, j=off; i<n; i+=m, j+=m){
    log_bmap(ip, j/BSIZE);
    m = min(n - i, BSIZE - j%BSIZE);
  }

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    bp[b_index] = bread(ip->dev, log_lookup(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(bp[b_index]->data + off%BSIZE, src, m);
    b_index++;
  }

  if(n > 0 && off > ip->size){
    ip->size = off;
    log_iupdate(ip);
  }

  log_start();
  for(i = 0; i < b_index; i++){
    bwrite(bp[i]);
    brelse(bp[i]);
  }

  log_end();

  return n;

}