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

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

?? openlpc.c

?? 本源碼說明了聲音壓縮在工程中的使用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/************************************************************************\

  Low bitrate LPC CODEC derived from the public domain implementation 
  of Ron Frederick.
  
  The basic design is preserved, except for several bug fixes and
  the following modifications:
    
  1. The pitch detector operates on the (downsampled) signal, not on 
  the residue. This appears to yield better performances, and it
  lowers the processing load.
  2. Each frame is elongated by 50% prefixing it with the last half
  of the previous frame. This design, inherited from the original
  code for windowing purposes, is exploited in order to provide 
  two independent pitch analyses: on the first 2/3, and on the 
  second 2/3 of the elongated frame (of course, they overlap by 
  half):
      
  last half old frame	            new frame
  --------------------========================================
  <--------- first pitch region --------->
                      <--------- second pitch region  ------->
        
  Two voiced/unvoiced flags define the voicing status of each
  region; only one value for the period is retained (if both
  halves are voiced, the average is used).
  The two flags are used by the synthesizer for the halves of
  each frame to play back. Of course, this is non optimal but
  is good enough (a half-frame would be too short for measuring
  low pitches)
  3. The parameters (one float for the period (pitch), one for the
  gain, and ten for the LPC-10 filter) are quantized according 
  this procedure:
  - the period is logarithmically compressed, then quantized 
  as 8-bit unsigned int (6 would actually suffice)
  - the gain is logarithmically compressed (using a different
  formula), then quantized at 6-bit unsigned int. The two
  remaining bits are used for the voicing flags.
  - the first two LPC parameters (k[1] and k[2]) are multiplied
  by PI/2, and the arcsine of the result is quantized as
  6 and 5 bit signed integers. This has proved more effective
  than the log-area compression used by LPC-10.
  - the remaining eight LPC parameters (k[3]...k[10]) are
  quantized as, respectively, 5,4,4,3,3,3,3 and 2 bit signed
  integers.
  Finally, period and gain plus voicing flags are stored in the
  first two bytes of the 7-byte parameters block, and the quantized
  LPC parameters are packed into the remaining 5 bytes. Two bits
  remain unassigned, and can be used for error detection or other
  purposes.

  The frame lenght is actually variable, and is simply passed as 
  initialization parameter to lpc_init(): this allows to experiment
  with various frame lengths. Long frames reduce the bitrate, but
  exceeding 320 samples (i.e. 40 ms, at 8000 samples/s) tend to
  deteriorate the speech, that sounds like spoken by a person 
  affected by a stroke: the LPC parameters (modeling the vocal 
  tract) can't change fast enough for a natural-sounding synthesis.
  25 ms per frame already yields a quite tight compression, corresponding
  to 1000/40 * 7 * 8 = 1400 bps. The quality improves little with 
  frames shorter than 250 samples (32 frames/s), so this is a recommended
  compromise. The bitrate is 32 * 7 * 8 = 1792 bps.
  
  The synthesizer has been modified as well. For voiced subframes it 
  now uses a sawtooth excitation, instead of the original pulse train.
  This idea, copied from MELP, reduces the buzzing-noise artifacts.
  In order to compensate the non-white spectrum of the sawtooth, a 
  pre-emphasis is applied to the signal before the Durbin calculation.
  The filter has (in s-space) two zeroes at (640, 0) Hz and two poles 
  at (3200, 0) Hz. These filters have been handoded, and may not be 
  optimal. Two other filters (anti-hum high-pass with corner at 100 Hz,
  and pre-downsampling lowpass with corner at 300 Hz) are Butterworth
  designs produced by the MkFilter package by A.J. Fisher
  (http://www.cs.york.ac.uk/~fisher/mkfilter/).

  The C style has been ANSI-fied.

  Complexity: As any LPC CODEC, also this one is not very demanding:
  for real-time use analysis and synthesis takes each about 6 - 8% 
  of the CPU cycles on a Cy686/166, when the code is compiled with 
  MSVC++ 4.2 with /Ox or gcc with -O3.
  However, a floating point unit is absolutely required.


\************************************************************************/

#ifdef _MSC_VER
#pragma warning (disable:4711) /* to disable automatic inline warning */
#endif

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

#include "openlpc.h"
#include "ftol.h"

#define PREEMPH

#define bcopy(a, b, n)	  memmove(b, a, n)
#ifdef _MSC_VER
  #define M_PI (3.1415926535897932384626433832795)
#endif

#define LPC_FILTORDER		10
#define FS		8000.0	/* Sampling rate */
#define MAXWINDOW	1000	/* Max analysis window length */

typedef struct openlpc_e_state{
	float   s[MAXWINDOW], y[MAXWINDOW], h[MAXWINDOW];
    int     framelen, buflen;
    float   xv1[3], yv1[3], 
            xv2[2], yv2[2], 
			xv3[1], yv3[3], 
			xv4[2], yv4[2];
    float   w[MAXWINDOW], r[LPC_FILTORDER+1];
} openlpc_e_state_t;

typedef struct openlpc_d_state{
		float Oldper, OldG, Oldk[LPC_FILTORDER + 1];
        float bp[LPC_FILTORDER+1];
        float exc;
		int pitchctr, framelen, buflen;
} openlpc_d_state_t;

#define FC		200.0	/* Pitch analyzer filter cutoff */
#define DOWN		5	/* Decimation for pitch analyzer */
#define MINPIT		40.0	/* Minimum pitch (observed: 74) */
#define MAXPIT		320.0	/* Maximum pitch (observed: 250) */

#define MINPER		(int)(FS/(DOWN*MAXPIT)+.5)	/* Minimum period  */
#define MAXPER		(int)(FS/(DOWN*MINPIT)+.5)	/* Maximum period  */

#define REAL_MINPER	 (DOWN*MINPER) /* converted to samples units */

#define WSCALE		1.5863	/* Energy loss due to windowing */

#define BITS_FOR_LPC 38

#define ARCSIN_Q /* provides better quantization of first two k[] at low bitrates */

#if BITS_FOR_LPC == 38
/* (38 bit LPC-10, 2.7 Kbit/s @ 20ms, 2.4 Kbit/s @ 22.5 ms */
static int parambits[LPC_FILTORDER] = {6,5,5,4,4,3,3,3,3,2};
#elif BITS_FOR_LPC == 32
/* (32 bit LPC-10, 2.4 Kbit/s, not so good */
static int parambits[LPC_FILTORDER] = {5,5,5,4,3,3,2,2,2,1};
#else /* BITS_FOR_LPC == 80	*/
/* 80-bit LPC10, 4.8 Kbit/s */
static int parambits[LPC_FILTORDER] = {8,8,8,8,8,8,8,8,8,8};
#endif

static float logmaxminper;
static int sizeofparm;	/* computed by lpc_init */

static void auto_correl1(float *w, int n, float *r)
{
    int i, k;
    
    for (k=0; k <= MAXPER; k++, n--) {
        r[k] = 0.0;
        for (i=0; i < n; i++) {
            r[k] += (w[i] *  w[i+k]);
        }
    }
}

static void auto_correl2(float *w, int n, float *r)
{
    int i, k;
    
    for (k=0; k <= LPC_FILTORDER; k++, n--) {
        r[k] = 0.0;
        for (i=0; i < n; i++) {
            r[k] += (w[i] *  w[i+k]);
        }
    }
}

static void durbin(float r[], int p, float k[], float *g)
{
    int i, j;
    float a[LPC_FILTORDER+1], at[LPC_FILTORDER+1], e;
    
    for (i=0; i <= p; i++) a[i] = at[i] = 0.0;
    
    e = r[0];
    for (i=1; i <= p; i++) {
        k[i] = -r[i];
        for (j=1; j < i; j++) {
            at[j] = a[j];
            k[i] -= a[j] * r[i-j];
        }
        if (e == 0) {  /* fix by John Walker */
            *g = 0;
            return;
        }
        k[i] /= e;
        a[i] = k[i];
        for (j=1; j < i; j++) a[j] = at[j] + k[i] * at[i-j];
        e *= 1.0f - k[i]*k[i];
    }
    if (e < 0) {
        e = 0; /* fix by John Walker */
    }
    *g = (float)sqrt(e);
}

/* Enzo's streamlined pitch extractor - on the signal, not the residue */

static void calc_pitch(float w[], int len, float *per)
{
    int i, j, rpos;
    float d[MAXWINDOW/DOWN], r[MAXPER+1], rmax;
    float rval, rm, rp;
    float x, y;
    float vthresh;
    int goneneg;
    float lowthresh;
    
    /* decimation */
    for (i=0, j=0; i < len; i+=DOWN) 
        d[j++] = w[i];
    
    auto_correl1(d, len/DOWN, r); 
    
    /* find peak between MINPER and MAXPER */
    x = 1;
    rpos = 0;
    rmax = 0.0;
    goneneg = 0;
    
    lowthresh = 0.; 
    
    for (i = 1; i <= MAXPER; i++) {
        rm = r[i-1];
        rp = r[i+1];
        y = rm+r[i]+rp; /* find max of integral from i-1 to i+1 */
        if (y > rmax && r[i] > rm && r[i] > rp &&  i > MINPER) {
            rmax = y;
            rpos = i;
        }
    }
    
    /* consider adjacent values */
    rm = r[rpos-1];
    rp = r[rpos+1];
    
#if 0
    {
        float a, b, c, x, y;
        /* parabolic interpolation */
        a = 0.5f * rm - rmax + 0.5f * rp;
        b = -0.5f*rm*(2.0f*rpos+1.0f) + 2.0f*rpos*rmax + 0.5f*rp*(1.0f-2.0f*rpos);
        c = 0.5f*rm*(rpos*rpos+rpos) + rmax*(1.0f-rpos*rpos) + 0.5f*rp*(rpos*rpos-rpos);
        
        /* find max of interpolating parabole */
        x = -b / (2.0f * a);
        y = a*x*x + b*x + c;
        
        rmax = y;
        /* normalize, so that 0. < rval < 1. */ 
        rval = (r[0] == 0 ? 1.0f : rmax / r[0]);
    }
#else
    if(rpos > 0) {
        x = ((rpos-1)*rm + rpos*r[rpos] + (rpos+1)*rp)/(rm+r[rpos]+rp); 
    }
    /* normalize, so that 0. < rval < 1. */ 
    rval = (r[0] == 0 ? 0 : r[rpos] / r[0]);
#endif
    
    /* periods near the low boundary and at low volumes
    are usually spurious and 
    manifest themselves as annoying mosquito buzzes */
    
    *per = 0;	/* default: unvoiced */
    if ( x > MINPER &&  /* x could be < MINPER or even < 0 if pos == MINPER */
        x < (MAXPER+1) /* same story */
        ) {
        
        vthresh = 0.6f; 
        if(r[0] > 0.002)	   /* at low volumes (< 0.002), prefer unvoiced */ 
            vthresh = 0.25;       /* drop threshold at high volumes */
        
        if(rval > vthresh)
            *per = x * DOWN;
    }
}

/* Initialization of various parameters */

openlpc_encoder_state *create_openlpc_encoder_state(void)
{
    openlpc_encoder_state *state;
    
    state = (openlpc_encoder_state *)malloc(sizeof(openlpc_encoder_state));
    
    return state;
}


void init_openlpc_encoder_state(openlpc_encoder_state *st, int framelen)
{
    int i, j;
    
    st->framelen = framelen;
    
    st->buflen = framelen*3/2;
    /*  (st->buflen > MAXWINDOW) return -1;*/
    
    for(i=0, j=0; i<sizeof(parambits)/sizeof(parambits[0]); i++) {
        j += parambits[i];
    }
    sizeofparm = (j+7)/8 + 2;
    for (i = 0; i < st->buflen; i++) {
        st->s[i] = 0.0;
        st->h[i] = (float)(WSCALE*(0.54 - 0.46 * cos(2 * M_PI * i / (st->buflen-1.0))));
    }
    /* init the filters */
    st->xv1[0] = st->xv1[1] = st->xv1[2] = st->yv1[0] = st->yv1[1] = st->yv1[2] = 0.0f;
    st->xv2[0] = st->xv2[1] = st->yv2[0] = st->yv2[1] = 0.0f;
    st->xv3[0] = st->yv3[0] = st->yv3[1] = st->yv3[2] = 0.0f;
    st->xv4[0] = st->xv4[1] = st->yv4[0] = st->yv4[1] = 0.0f;
    
    logmaxminper = (float)log((float)MAXPER/MINPER);
    
}

void destroy_openlpc_encoder_state(openlpc_encoder_state *st)
{
    if(st != NULL)
    {
        free(st);
        st = NULL;
    }
}

/* LPC Analysis (compression) */

int openlpc_encode(const short *buf, unsigned char *parm, openlpc_encoder_state *st)
{
    int i, j;
    float per, gain, k[LPC_FILTORDER+1];
    float per1, per2;
    float xv10, xv11, xv12, yv10, yv11, yv12,
        xv20, xv21, yv20, yv21,
        xv30, yv30, yv31, yv32,
        xv40, xv41, yv40, yv41;
    
    xv10 = st->xv1[0];
    xv11 = st->xv1[1];
    xv12 = st->xv1[2];
    yv10 = st->yv1[0];
    yv11 = st->yv1[1];
    yv12 = st->yv1[2];
    xv30 = st->xv3[0];
    yv30 = st->yv3[0];
    yv31 = st->yv3[1];
    yv32 = st->yv3[2];
    /* convert short data in buf[] to signed lin. data in s[] and prefilter */
    for (i=0, j=st->buflen - st->framelen; i < st->framelen; i++, j++) {
        
        float u = (float)(buf[i]/32768.0f);
        
        /* Anti-hum 2nd order Butterworth high-pass, 100 Hz corner frequency */
        /* Digital filter designed by mkfilter/mkshape/gencode   A.J. Fisher
        mkfilter -Bu -Hp -o 2 -a 0.0125 -l -z */
        
        xv10 = xv11;
        xv11 = xv12; 
        xv12 = (float)(u * 0.94597831f); /* /GAIN */
        
        yv10 = yv11;
        yv11 = yv12; 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久er热在这里只有精品66| 欧美大片免费久久精品三p| 欧美日韩在线亚洲一区蜜芽| 欧美xxxxx牲另类人与| 亚洲一级电影视频| 国产98色在线|日韩| 日韩视频免费观看高清在线视频| 亚洲欧美在线观看| 国产99久久久国产精品| 日韩一区二区三区在线观看| 夜夜爽夜夜爽精品视频| 成人动漫一区二区三区| 亚洲精品在线一区二区| 奇米影视在线99精品| 欧美日韩一级视频| 亚洲精品菠萝久久久久久久| 成人精品gif动图一区| 久久久久久久久久久黄色| 精品影视av免费| 在线成人av影院| 日日欢夜夜爽一区| 欧美巨大另类极品videosbest| 亚洲在线免费播放| 欧美色欧美亚洲另类二区| 亚洲另类在线制服丝袜| 色噜噜狠狠成人中文综合| 国产精品视频第一区| 成人av在线影院| 1024国产精品| 91同城在线观看| 亚洲精品国产一区二区精华液| 色婷婷综合久久久中文字幕| 亚洲欧美日韩国产综合| 91久久精品国产91性色tv| 亚洲女同ⅹxx女同tv| 色网站国产精品| 亚洲国产一区视频| 日韩一区二区电影| 国产中文字幕一区| 中文字幕免费一区| 91视频在线观看| 亚洲精品久久7777| 欧美猛男男办公室激情| 久久9热精品视频| 国产日产欧产精品推荐色| av在线播放一区二区三区| 亚洲激情图片小说视频| 欧美三级电影在线看| 美女在线一区二区| 中文字幕av一区二区三区| 91网上在线视频| 日韩高清不卡一区二区三区| 精品免费日韩av| 99精品在线免费| 午夜免费久久看| 久久精品一区蜜桃臀影院| proumb性欧美在线观看| 亚洲大片精品永久免费| 久久久久久99久久久精品网站| av成人免费在线| 日韩av一区二区三区四区| 久久日韩粉嫩一区二区三区| 色一区在线观看| 国产一区二区网址| 亚洲综合自拍偷拍| 久久综合av免费| 欧美无砖专区一中文字| 国产成人免费视频一区| 午夜天堂影视香蕉久久| 欧美激情中文字幕| 日韩午夜三级在线| 91久久久免费一区二区| 国产成人av一区二区三区在线观看| 亚洲一区二区免费视频| 日本一区二区三区国色天香| 91精品久久久久久久91蜜桃| av中文字幕在线不卡| 精品一区二区三区在线播放 | 久久综合色8888| 在线影院国内精品| 国产精品456露脸| 视频一区二区欧美| 亚洲美女电影在线| 亚洲国产精品成人综合| 欧美成人r级一区二区三区| 日本久久电影网| 懂色一区二区三区免费观看| 男人操女人的视频在线观看欧美| 亚洲精品视频一区| 国产精品情趣视频| 久久久久久9999| 精品人在线二区三区| 777午夜精品视频在线播放| 91在线你懂得| 成人毛片在线观看| 国产成人精品网址| 国产在线精品一区二区三区不卡 | 欧美高清精品3d| 色8久久精品久久久久久蜜| 成人免费视频播放| 风间由美一区二区三区在线观看| 久久不见久久见中文字幕免费| 亚洲在线观看免费| 亚洲综合在线电影| 一区二区三区小说| 亚洲男女一区二区三区| 亚洲欧美综合另类在线卡通| 国产精品免费看片| 亚洲特黄一级片| 亚洲天堂网中文字| 亚洲精品视频观看| 亚洲国产精品一区二区久久恐怖片 | 欧洲av在线精品| 91无套直看片红桃| 欧洲另类一二三四区| 欧美视频在线不卡| 在线成人小视频| 欧美一区二区视频免费观看| 制服丝袜亚洲精品中文字幕| 91精品国产入口在线| 精品国精品国产| 欧美国产乱子伦| 亚洲丝袜另类动漫二区| 亚洲影视在线观看| 日本中文字幕一区| 国产精品 欧美精品| 成人av在线电影| 日本精品一区二区三区四区的功能| 色噜噜狠狠色综合中国| 67194成人在线观看| 久久久久久久久久久电影| 国产精品免费av| 亚洲成精国产精品女| 久久99国产精品久久99果冻传媒 | 亚洲成人你懂的| 麻豆精品精品国产自在97香蕉| 国产乱子轮精品视频| 99vv1com这只有精品| 欧美夫妻性生活| 国产日韩影视精品| 亚洲在线免费播放| 国产真实乱子伦精品视频| 91视频国产资源| 91精品国产综合久久婷婷香蕉| 国产偷v国产偷v亚洲高清| 亚洲精品美腿丝袜| 久久成人免费电影| 91黄视频在线| 精品国产污网站| 亚洲黄色尤物视频| 国产精品一区一区三区| 欧美亚洲综合在线| 国产性色一区二区| 午夜视频一区在线观看| 成人av午夜电影| 日韩欧美一区二区不卡| 亚洲精品日产精品乱码不卡| 国产专区综合网| 欧美剧情片在线观看| 国产精品日韩成人| 精品一区二区三区免费毛片爱| 99精品一区二区| 久久久噜噜噜久久中文字幕色伊伊| 一区二区三区在线看| 国产成人aaa| 精品国产免费人成电影在线观看四季| 亚洲欧洲日韩在线| 国产麻豆视频精品| 欧美电视剧在线看免费| 午夜久久久久久久久| 99精品热视频| 久久久国产午夜精品| 日本vs亚洲vs韩国一区三区 | 欧美大尺度电影在线| 亚洲美腿欧美偷拍| 成人h动漫精品一区二区| 精品福利在线导航| 日本sm残虐另类| 欧美三级视频在线| 一区二区三区四区蜜桃| 成人avav影音| 国产日韩三级在线| 国产成人在线网站| 久久精品一区二区| 精品亚洲免费视频| 日韩小视频在线观看专区| 天天色综合成人网| 欧美二区乱c少妇| 天堂一区二区在线| 91精品免费在线| 日本欧美肥老太交大片| 日韩一区二区视频在线观看| 午夜精品久久久久久久99水蜜桃 | 色综合视频在线观看| 亚洲欧洲国产日本综合| 成人成人成人在线视频| 中文字幕一区二区三区在线不卡 | 日韩欧美一级在线播放| 六月丁香婷婷色狠狠久久| 日韩精品一区二区三区四区视频 |