亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? plc.c

?? ppciaxclient softphone
?? C
字號:
/*
` * SpanDSP - a series of DSP components for telephony
 *
 * plc.c
 *
 * Written by Steve Underwood <steveu@coppice.org>
 *
 * Copyright (C) 2004 Steve Underwood
 *
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * This version may be optionally licenced under the GNU LGPL licence.
 * This version is disclaimed to DIGIUM for inclusion in the Asterisk project.
 */

/*! \file */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#include "plc.h"

#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE (!FALSE)
#endif

#if !defined(INT16_MAX)
#define INT16_MAX	(32767)
#define INT16_MIN	(-32767-1)
#endif

#if defined(_MSC_VER)
#define INLINE __inline
double rint(double x)
{
	if(x>0)
		return ceil(x);
	else
		return floor(x);
	return 0;
}
#endif
/* We do a straight line fade to zero volume in 50ms when we are filling in for missing data. */
#define ATTENUATION_INCREMENT       0.0025                              /* Attenuation per sample */

#define ms_to_samples(t)            (((t)*SAMPLE_RATE)/1000)

static INLINE int16_t fsaturate(double damp)
{
    if (damp > 32767.0)
	return  INT16_MAX;
    if (damp < -32768.0)
	return  INT16_MIN;
    return (int16_t) rint(damp);
}

static void save_history(plc_state_t *s, int16_t *buf, int len)
{
    if (len >= PLC_HISTORY_LEN)
    {
        /* Just keep the last part of the new data, starting at the beginning of the buffer */
        memcpy(s->history, buf + len - PLC_HISTORY_LEN, sizeof(int16_t)*PLC_HISTORY_LEN);
        s->buf_ptr = 0;
        return;
    }
    if (s->buf_ptr + len > PLC_HISTORY_LEN)
    {
        /* Wraps around - must break into two sections */
        memcpy(s->history + s->buf_ptr, buf, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
        len -= (PLC_HISTORY_LEN - s->buf_ptr);
        memcpy(s->history, buf + (PLC_HISTORY_LEN - s->buf_ptr), sizeof(int16_t)*len);
        s->buf_ptr = len;
        return;
    }
    /* Can use just one section */
    memcpy(s->history + s->buf_ptr, buf, sizeof(int16_t)*len);
    s->buf_ptr += len;
}
/*- End of function --------------------------------------------------------*/

static void normalise_history(plc_state_t *s)
{
    int16_t tmp[PLC_HISTORY_LEN];

    if (s->buf_ptr == 0)
        return;
    memcpy(tmp, s->history, sizeof(int16_t)*s->buf_ptr);
    memcpy(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
    memcpy(s->history + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t)*s->buf_ptr);
    s->buf_ptr = 0;
}
/*- End of function --------------------------------------------------------*/

static int __inline amdf_pitch(int min_pitch, int max_pitch, int16_t amp[], int len)
{
    int i;
    int j;
    int acc;
    int min_acc;
    int pitch;

    pitch = min_pitch;
    min_acc = INT_MAX;
    for (i = max_pitch;  i <= min_pitch;  i++)
    {
        acc = 0;
        for (j = 0;  j < len;  j++)
            acc += abs(amp[i + j] - amp[j]);
        if (acc < min_acc)
        {
            min_acc = acc;
            pitch = i;
        }
    }
    return pitch;
}
/*- End of function --------------------------------------------------------*/

int plc_rx(plc_state_t *s, int16_t amp[], int len)
{
    int i;
    int pitch_overlap;
    float old_step;
    float new_step;
    float old_weight;
    float new_weight;
    float gain;
    
    if (s->missing_samples)
    {
        /* Although we have a real signal, we need to smooth it to fit well
           with the synthetic signal we used for the previous block */

        /* The start of the real data is overlapped with the next 1/4 cycle
           of the synthetic data. */
        pitch_overlap = s->pitch >> 2;
        if (pitch_overlap > len)
            pitch_overlap = len;
        gain = 1.0 - s->missing_samples*ATTENUATION_INCREMENT;
        if (gain < 0.0)
            gain = 0.0;
        new_step = 1.0/pitch_overlap;
        old_step = new_step*gain;
        new_weight = new_step;
        old_weight = (1.0 - new_step)*gain;
        for (i = 0;  i < pitch_overlap;  i++)
        {
            amp[i] = fsaturate(old_weight*s->pitchbuf[s->pitch_offset] + new_weight*amp[i]);
            if (++s->pitch_offset >= s->pitch)
                s->pitch_offset = 0;
            new_weight += new_step;
            old_weight -= old_step;
            if (old_weight < 0.0)
                old_weight = 0.0;
        }
        s->missing_samples = 0;
    }
    save_history(s, amp, len);
    return len;
}
/*- End of function --------------------------------------------------------*/

int plc_fillin(plc_state_t *s, int16_t amp[], int len)
{
    int i;
    int pitch_overlap;
    float old_step;
    float new_step;
    float old_weight;
    float new_weight;
    float gain;
    int16_t *orig_amp;
    int orig_len;

    orig_amp = amp;
    orig_len = len;
    if (s->missing_samples == 0)
    {
        /* As the gap in real speech starts we need to assess the last known pitch,
           and prepare the synthetic data we will use for fill-in */
        normalise_history(s);
        s->pitch = amdf_pitch(PLC_PITCH_MIN, PLC_PITCH_MAX, s->history + PLC_HISTORY_LEN - CORRELATION_SPAN - PLC_PITCH_MIN, CORRELATION_SPAN);
        /* We overlap a 1/4 wavelength */
        pitch_overlap = s->pitch >> 2;
        /* Cook up a single cycle of pitch, using a single of the real signal with 1/4
           cycle OLA'ed to make the ends join up nicely */
        /* The first 3/4 of the cycle is a simple copy */
        for (i = 0;  i < s->pitch - pitch_overlap;  i++)
            s->pitchbuf[i] = s->history[PLC_HISTORY_LEN - s->pitch + i];
        /* The last 1/4 of the cycle is overlapped with the end of the previous cycle */
        new_step = 1.0/pitch_overlap;
        new_weight = new_step;
        for (  ;  i < s->pitch;  i++)
        {
            s->pitchbuf[i] = s->history[PLC_HISTORY_LEN - s->pitch + i]*(1.0 - new_weight) + s->history[PLC_HISTORY_LEN - 2*s->pitch + i]*new_weight;
            new_weight += new_step;
        }
        /* We should now be ready to fill in the gap with repeated, decaying cycles
           of what is in pitchbuf */

        /* We need to OLA the first 1/4 wavelength of the synthetic data, to smooth
           it into the previous real data. To avoid the need to introduce a delay
           in the stream, reverse the last 1/4 wavelength, and OLA with that. */
        gain = 1.0;
        new_step = 1.0/pitch_overlap;
        old_step = new_step;
        new_weight = new_step;
        old_weight = 1.0 - new_step;
        for (i = 0;  i < pitch_overlap && i < len;  i++)
        {
            amp[i] = fsaturate(old_weight*s->history[PLC_HISTORY_LEN - 1 - i] + new_weight*s->pitchbuf[i]);
            new_weight += new_step;
            old_weight -= old_step;
            if (old_weight < 0.0)
                old_weight = 0.0;
        }
        s->pitch_offset = i;
    }
    else
    {
        gain = 1.0 - s->missing_samples*ATTENUATION_INCREMENT;
        i = 0;
    }
    for (  ;  gain > 0.0  &&  i < len;  i++)
    {
        amp[i] = s->pitchbuf[s->pitch_offset]*gain;
        gain -= ATTENUATION_INCREMENT;
        if (++s->pitch_offset >= s->pitch)
            s->pitch_offset = 0;
    }
    for (  ;  i < len;  i++)
        amp[i] = 0;
    s->missing_samples += orig_len;
    save_history(s, amp, len);
    return len;
}
/*- End of function --------------------------------------------------------*/

plc_state_t *plc_init(plc_state_t *s)
{
    memset(s, 0, sizeof(*s));
    return s;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩另类视频免费观看 | 另类调教123区| 亚洲欧美综合另类在线卡通| 国产亚洲欧美色| 亚洲欧洲av另类| 欧美高清在线一区| 国产亚洲成aⅴ人片在线观看| 日韩一区二区高清| 精品国产一区a| 久久亚洲精精品中文字幕早川悠里| 日韩一区二区免费高清| 欧美电视剧在线看免费| 26uuu久久天堂性欧美| 国产亚洲欧洲997久久综合| 国产欧美日产一区| 亚洲欧美激情在线| 亚洲福利视频导航| 久久aⅴ国产欧美74aaa| 国内精品久久久久影院薰衣草| 久久99国产精品麻豆| 国产成人午夜精品5599| 成人国产在线观看| 欧美亚洲国产一区二区三区va| 欧美日韩国产首页| 精品成人一区二区三区四区| 日本一区二区三区四区 | 91国偷自产一区二区开放时间 | 国产激情一区二区三区| 色香色香欲天天天影视综合网| 在线亚洲一区观看| 精品少妇一区二区三区在线视频| 久久久久国产精品人| 亚洲精品视频在线| 蜜桃视频在线观看一区二区| 欧美日韩国产另类一区| 欧美精品一区二区久久婷婷| 国产精品不卡一区二区三区| 天天色综合天天| 白白色亚洲国产精品| 欧美一区二区三区四区在线观看| 欧美激情一区二区| 日韩av一级片| 一本色道久久综合狠狠躁的推荐 | 国产午夜精品福利| 亚洲综合男人的天堂| 国产一区在线观看视频| 欧美三级资源在线| 日本一区免费视频| 久久精品久久精品| 欧美综合天天夜夜久久| 国产精品伦理一区二区| 免费成人在线视频观看| 欧美网站一区二区| 国产精品国产馆在线真实露脸| 日本欧美一区二区三区乱码| 91成人网在线| 最新久久zyz资源站| 国产乱码精品一区二区三区五月婷| 欧美日韩在线播放三区四区| 中文字幕一区二区三区在线不卡| 久久99久久精品欧美| 欧美日韩一区不卡| 亚洲自拍偷拍九九九| 91视频在线观看| 国产精品久久久久7777按摩| 国产一区二区视频在线| 欧美www视频| 男女性色大片免费观看一区二区| 欧美亚洲综合网| 亚洲男女一区二区三区| 99re视频精品| 亚洲欧美色图小说| 91美女蜜桃在线| 亚洲精品国产a| 国产亚洲精品免费| 极品美女销魂一区二区三区免费| 日韩一区二区三区四区五区六区| 亚洲国产精品久久不卡毛片| 欧美视频一区二区三区四区 | 精品亚洲免费视频| 欧美不卡一二三| 麻豆精品视频在线观看| 精品国产一区二区国模嫣然| 国产精品影视在线| 国产精品久久夜| 91视频观看视频| 亚洲国产日产av| 日韩欧美一级在线播放| 激情综合色播激情啊| 国产日产欧美精品一区二区三区| 国产成人精品亚洲日本在线桃色 | 日本韩国精品在线| 亚洲午夜精品在线| 精品日韩在线一区| 暴力调教一区二区三区| 亚洲一区在线视频| 精品国产一区二区三区av性色| 国产精品123区| 亚洲柠檬福利资源导航| 欧美高清视频不卡网| 久久黄色级2电影| 中文字幕在线一区免费| 欧美亚洲国产怡红院影院| 日韩不卡在线观看日韩不卡视频| 久久婷婷国产综合精品青草| av在线不卡免费看| 蜜桃久久av一区| 中文字幕中文字幕在线一区| 欧美人动与zoxxxx乱| 国产激情一区二区三区四区| 亚洲制服丝袜一区| 久久综合色播五月| 色悠悠亚洲一区二区| 麻豆精品视频在线观看| 亚洲欧美电影一区二区| 日韩午夜激情视频| 色综合久久88色综合天天6| 久久不见久久见免费视频7| 中文字幕五月欧美| 精品久久久久久最新网址| 91香蕉视频黄| 国产精品一区二区在线观看不卡 | 成人欧美一区二区三区黑人麻豆| 在线电影一区二区三区| 91免费版在线| 久久超碰97中文字幕| 亚洲成人在线观看视频| 中文字幕的久久| 欧美精品一区二区三区蜜臀| 欧美日韩你懂得| 一本色道久久综合亚洲aⅴ蜜桃| 国内精品免费**视频| 日产国产高清一区二区三区| 亚洲精品视频自拍| 中文字幕一区二| 国产丝袜美腿一区二区三区| 日韩欧美一卡二卡| 在线不卡免费欧美| 欧美日韩一级黄| 在线视频你懂得一区| 97国产精品videossex| 成人黄色综合网站| 国产成人免费9x9x人网站视频| 美脚の诱脚舐め脚责91| 日韩国产欧美在线视频| 亚洲6080在线| 天天综合网 天天综合色| 亚洲国产美国国产综合一区二区| 国产精品久久久久久久久免费桃花| 欧美精品一区二区三| 亚洲国产精品久久不卡毛片| 综合色中文字幕| 国产精品伦理一区二区| 亚洲四区在线观看| 国产精品女上位| 亚洲欧美激情插| 亚洲精品一二三四区| 亚洲综合久久av| 日韩精品视频网站| 美女国产一区二区三区| 激情综合亚洲精品| 高清在线不卡av| 成人h动漫精品一区二| 91在线视频免费91| 欧美午夜精品久久久久久超碰 | 欧美成人性战久久| xf在线a精品一区二区视频网站| 日韩三级视频在线看| 欧美成人video| 亚洲国产精品精华液ab| 日韩美女啊v在线免费观看| 亚洲免费在线视频一区 二区| 亚洲韩国精品一区| 裸体在线国模精品偷拍| 国产丶欧美丶日本不卡视频| 99视频一区二区| 欧美天堂亚洲电影院在线播放| 欧美丰满少妇xxxxx高潮对白 | 亚洲国产精品成人综合| 自拍偷自拍亚洲精品播放| 一区二区三区色| 免费在线观看精品| 福利一区二区在线| 欧美伊人久久久久久久久影院| 欧美日韩免费在线视频| 精品少妇一区二区三区日产乱码| 欧美国产丝袜视频| 亚洲一区二区三区四区中文字幕| 麻豆成人综合网| 91亚洲永久精品| 欧美大肚乱孕交hd孕妇| 亚洲六月丁香色婷婷综合久久| 日韩av一级片| 91在线精品一区二区| 日韩欧美国产精品| 亚洲欧美福利一区二区| 国产精品一区二区男女羞羞无遮挡| 色噜噜狠狠色综合欧洲selulu | 狠狠v欧美v日韩v亚洲ⅴ| 色婷婷av一区二区三区软件|