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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? plc.c

?? ppciaxclient softphone
?? C
字號(hào):
/*
` * 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 ------------------------------------------------------------*/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
青青草国产精品97视觉盛宴| 久久久久久久久久久电影| 久久国产精品99久久人人澡| 中文字幕高清一区| 欧美日韩一区视频| 国产91精品免费| 五月婷婷久久综合| 国产精品污www在线观看| 日韩一区二区三区电影在线观看| gogogo免费视频观看亚洲一| 久久精品国产久精国产爱| 亚洲欧美一区二区在线观看| 精品国产乱码久久久久久蜜臀| 在线观看免费一区| 成人午夜又粗又硬又大| 久久97超碰国产精品超碰| 亚洲制服欧美中文字幕中文字幕| 欧美激情一区三区| 久久亚洲精品小早川怜子| 欧美日韩国产小视频在线观看| 成人涩涩免费视频| 精品一区二区三区在线观看国产 | 7777精品伊人久久久大香线蕉 | 在线免费观看不卡av| 国产盗摄视频一区二区三区| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲精选在线视频| 国产精品久久久久久久裸模| 国产欧美一区二区在线| 欧美大片在线观看| 在线播放91灌醉迷j高跟美女| 欧美亚州韩日在线看免费版国语版| 成人免费视频一区二区| 国产精品亚洲一区二区三区在线| 美国av一区二区| 免费日韩伦理电影| 久久国产视频网| 久久激情综合网| 激情都市一区二区| 国产麻豆精品视频| 国产凹凸在线观看一区二区| 国产成人精品亚洲777人妖| 精品一区二区久久| 韩国精品久久久| 国产最新精品精品你懂的| 国产一区二区三区综合| 国产精品一二三在| 成人亚洲一区二区一| 99久久精品国产导航| 91亚洲国产成人精品一区二三| 97精品视频在线观看自产线路二| 97精品久久久午夜一区二区三区 | 午夜精品久久久久久久久| **性色生活片久久毛片| 国产精品伦一区二区三级视频| 久久久高清一区二区三区| 国产亚洲欧美日韩俺去了| 国产欧美一区在线| 亚洲视频香蕉人妖| 樱花草国产18久久久久| 国产成人午夜片在线观看高清观看| 韩国毛片一区二区三区| 成人免费毛片app| 91在线精品一区二区| 精品污污网站免费看| 欧美一区二区视频网站| 久久精品亚洲国产奇米99| 成人欧美一区二区三区白人| 亚洲成av人综合在线观看| 日韩精品亚洲一区| 国产精品77777竹菊影视小说| 成人午夜碰碰视频| 在线一区二区三区做爰视频网站| 欧美精品在线观看播放| 久久嫩草精品久久久精品| 国产精品剧情在线亚洲| 亚洲成人av一区二区| 久久爱www久久做| 97超碰欧美中文字幕| 欧美群妇大交群中文字幕| 精品久久久久99| 亚洲免费av网站| 蜜桃免费网站一区二区三区 | 欧美日韩国产免费一区二区| 精品久久人人做人人爽| 中文字幕制服丝袜成人av | 懂色av一区二区三区蜜臀| 91香蕉视频mp4| 日韩免费在线观看| 亚洲日本成人在线观看| 免费一区二区视频| av中文一区二区三区| 在线成人av影院| 国产精品成人一区二区三区夜夜夜| 日韩精品福利网| 99精品欧美一区二区三区综合在线| 欧美一区二区三区精品| 亚洲欧洲另类国产综合| 韩国一区二区视频| 精品视频在线看| 中文字幕一区二区三区色视频| 老司机精品视频在线| 在线精品视频免费播放| 欧美激情综合网| 久久99精品久久久久久久久久久久| 色综合色综合色综合色综合色综合| 欧美xxxxx牲另类人与| 亚洲综合一区二区| 不卡一二三区首页| 2014亚洲片线观看视频免费| 五月激情综合网| 91黄色在线观看| 麻豆成人免费电影| 91精品福利视频| 国产精品国产三级国产专播品爱网| 亚洲大型综合色站| 午夜婷婷国产麻豆精品| 欧美浪妇xxxx高跟鞋交| 国产91精品精华液一区二区三区| 国产另类ts人妖一区二区| 欧美日韩国产a| 又紧又大又爽精品一区二区| 成人av在线资源网| 国产色爱av资源综合区| 国产在线视频精品一区| 日韩欧美中文字幕一区| 亚洲va欧美va天堂v国产综合| 色综合久久88色综合天天| 国产精品二区一区二区aⅴ污介绍| 国产一区三区三区| 日韩欧美精品在线视频| 免费在线视频一区| 日韩三级高清在线| 蜜臀av亚洲一区中文字幕| 7777精品伊人久久久大香线蕉超级流畅| 亚洲综合区在线| 日本韩国欧美在线| 一级女性全黄久久生活片免费| 91捆绑美女网站| 国产精品的网站| 成人午夜视频网站| 91黄色免费版| 91亚洲国产成人精品一区二区三| 国产精品无码永久免费888| 日韩激情视频在线观看| 亚洲在线观看免费| 五月天中文字幕一区二区| 亚洲第一会所有码转帖| 亚洲五月六月丁香激情| 亚洲精品在线免费观看视频| 91超碰这里只有精品国产| 国产高清精品网站| 岛国精品在线观看| 亚洲国产sm捆绑调教视频| 国产婷婷色一区二区三区四区| 日韩三级视频中文字幕| 欧美一区三区四区| 日韩欧美高清一区| 久久久久综合网| 亚洲天堂网中文字| 亚洲免费资源在线播放| 午夜欧美电影在线观看| 夜夜嗨av一区二区三区四季av| 一个色综合av| 精品亚洲porn| 91精品福利视频| 精品奇米国产一区二区三区| 国产精品电影院| 久久国产精品99精品国产| 国产精品一区三区| 日韩欧美在线不卡| 26uuu亚洲综合色| 欧美韩国日本综合| 亚洲一区二区三区影院| 韩国av一区二区三区四区| 色综合久久中文综合久久97| 丁香婷婷综合五月| 夜夜嗨av一区二区三区四季av| 日韩欧美亚洲国产精品字幕久久久| 国产精品亚洲一区二区三区在线 | 欧美日韩亚洲综合一区| 天堂一区二区在线| 欧美福利电影网| 欧美成人激情免费网| 99在线精品观看| 日韩高清一区二区| 欧美丰满少妇xxxbbb| 亚洲国产精品综合小说图片区| 国产精品一级黄| 久久精品综合网| 欧洲中文字幕精品| 国产呦精品一区二区三区网站| 亚洲综合久久久久| 国产亚洲一区二区在线观看| 欧美日韩精品是欧美日韩精品| 丁香五精品蜜臀久久久久99网站| 日本视频在线一区| 依依成人综合视频| 国产精品久久久一区麻豆最新章节| 91精品国产欧美一区二区18|