?? psearch_fast.c
字號:
/**************************************************************************
*
* ROUTINE
* psearch
*
* FUNCTION
* find pitch VQ parameters
*
* SYNOPSIS
* subroutine psearch(l)
***************************************************************************/
#define TRUE 1
#define FALSE 0
#define LEN 5 /* *length of truncated impulse response */
#define MAXBUFPTR MMAX + MAXNO + 2 * MAXLP + MAXNP - 1
#define byte_maxbufptr 4*(MMAX + MAXNO + 2 * MAXLP + MAXNP - 1)
#define byte_maxlp 4*MAXLP
#define byte_maxpd 4*MAXPD
#define mmin(A,B) ((A)<(B)?(A):(B))
#define mmax(A,B) ((A)>(B)?(A):(B))
#include <stdio.h>
#include <math.h>
#include "ccsub.h"
static int submult[MAXPD][4] =
{
#include "submult.h" /* *load pitch submultiple delay table */
};
extern int idb, no, nseg, pindex, tauptr, minptr;
extern int plevel1, plevel2, frame;
extern float e0[MAXLP];
extern float bb[MAXNP+1], d1a[MAXPA];
extern float h[MAXLP], pdelay[MAXPD];
extern char ptype[10], pstype[10];
extern float selec_ad[MAXLP]; /* selected pitch ex. from ad codebook by psearch*/
psearch(l)
int l;
{
int i, m, lag, start;
int first, bigptr, subptr, topptr, maxptr, bufptr;
static int oldptr = {1};
float g[MAXPD], match[MAXPD], emax, pgain(), pitchencode();
int nrange;
float selec_ad_tmp[MAXLP];
float y[MAXLP];
register float temp;
int j;
/* See warning below ---------------- \/ max (MAXL, MAXLP) */
float v0[MAXBUFPTR], v0shift[MAXLP], frac;
/* */
/* *choose type of pitch delay search: */
/* *two stage hierarchical search of integer and neighboring */
/* *noninteger delays */
/* nrange = 3; */
nrange = 1;
/* *initialize arrays */
/*
for (i = 0; i < MAXBUFPTR; i++) v0[i] = 0.0;
for (i = 0; i < MAXLP; i++) v0shift[i] = 0.0;
for (i = 0; i < MAXPD; i++) g[i] = match[i] = 0.0;
*/
memset( v0, 0, byte_maxbufptr);
memset( v0shift, 0, byte_maxlp);
memset( g, 0, byte_maxpd);
memset( match, 0, byte_maxpd);
/* *update adaptive code book (pitch memory) */
movefr(idb, d1a, &v0[bufptr - idb - l]);
/* *initial conditions */
if (nseg == 1)
{
bb[2] = 0.0;
bb[0] = MMIN;
}
else
{
start = bufptr - l + 1;
/* *find allowable pointer range (minptr to maxptr) */
if ((nseg % 2) == 0)
{
/* *delta delay coding on even subframes */
minptr = oldptr - (plevel2/2 - 1);
maxptr = oldptr + (plevel2/2);
if (minptr < 0)
{
minptr = 0;
maxptr = plevel2 - 1;
}
if (maxptr > plevel1 - 1)
{
maxptr = plevel1 - 1;
minptr = plevel1 - plevel2;
}
topptr = minptr;
emax = match[topptr];
first = TRUE;
for (i = minptr; i <= maxptr; i++)
{
m = (int) pdelay[i];
frac = pdelay[i] - m;
if (fabs(frac) < 1.e-4)
{
lag = start - m;
g[i] = pgain(&v0[lag-1], l, first, m, LEN, &match[i]);
first = FALSE;
}
else
match[i] = 0.0;
if (match[i] > emax)
{
topptr = i;
emax = match[topptr];
}
}
tauptr = topptr;
}
else
{
/* *full range coding on odd subframes */
minptr = 0;
maxptr = plevel1 - 1;
topptr = minptr;
emax = match[topptr];
first = TRUE;
for (i = minptr; i <= maxptr; i++)
{
m = (int) pdelay[i];
frac = pdelay[i] - m;
if (fabs(frac) < 1.e-4)
{
lag = start - m;
g[i] = pgain(&v0[lag-1], l, first, m, LEN, &match[i]);
first = FALSE;
}
else
match[i] = 0.0;
if (match[i] > emax)
{
topptr = i;
emax = match[topptr];
}
}
tauptr = topptr;
for (i = 1; i <= submult[topptr][0]; i++)
{
bigptr = submult[topptr][i];
for (subptr = mmax(submult[topptr][i] - 8, minptr); subptr <=
mmin(submult[topptr][i] + 8, maxptr); subptr++)
{
if (match[subptr] > match[bigptr])
bigptr = subptr;
}
if (match[bigptr] >= 0.88 * match[topptr])
{
tauptr = bigptr;
}
}
}
bigptr = tauptr;
for (i = mmax(tauptr - nrange, minptr); i <= mmin(tauptr + nrange, maxptr); i++)
{
if (i != tauptr)
{
m = (int) pdelay[i];
frac = pdelay[i] - m;
lag = start - m;
if (fabs(frac) > 1.e-4)
{
delay(v0, start, l, frac, m, v0shift);
g[i] = pgain(v0shift, l, TRUE, 70, LEN, &match[i]);
movefr(l, v0shift, selec_ad_tmp);
}
if (match[i] > match[tauptr])
{
bigptr = i;
movefr(l, selec_ad_tmp, selec_ad);
/* i += 10; */
}
}
}
tauptr = bigptr;
/* *place pitch parameters in common bb "structure" */
bb[2] = g[tauptr];
bb[0] = pdelay[tauptr];
/* *save pitch pointer to determine delta delay */
oldptr = tauptr;
}
/* *pitch quantization bb[2] */
bb[2] = pitchencode(bb[2], &pindex);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -