Пример #1
0
void adapt_frame()
{
    static real
	input [NUPDATE*IDIM],
	synth [NUPDATE*IDIM],
	lg [NUPDATE];
    int gx;	/* Index for log_gains */
    
    FFASE(shifts[0])
    {
	CIRCOPY(synth,synspeech,dec_end,NUPDATE*IDIM,QSIZE);
	bsf_adapter (synth, sf_coeff_next);
	sf_coeff_obsolete_p = 1;
					SPDEBUG(15,sf_coeff, LPC+1);
    }

    FFASE(shifts[1])
    {
	gx = dec_end/IDIM;
	CIRCOPY(lg, log_gains, gx, NUPDATE, QSIZE/IDIM);
	gain_adapter(lg, gp_coeff_next);
	gp_coeff_obsolete_p = 1;
					SPDEBUG(13,gp_coeff, LPCLG+1);
    }

    FFASE(shifts[2])
    {
	CIRCOPY(input,thequeue,dec_end,NUPDATE*IDIM,QSIZE);
	pwf_adapter(input, pwf_z_coeff_next, pwf_p_coeff_next);
	pwf_z_coeff_obsolete_p = 1;
    }
	
    FFASE(shifts[3])
    {
	iresp_vcalc(sf_coeff_next, pwf_z_coeff_next, pwf_p_coeff_next, 
		    imp_resp_next);
	SPDEBUG(14,imp_resp, IDIM);
	shape_conv(imp_resp_next, shape_energy_next);
	shape_energy_obsolete_p = 1;
	imp_resp_obsolete_p = 1;
    }
}
Пример #2
0
void encode_vector(int ignore)
{
    int ix;	/* Computed Codebook Index */
    int vx;    	/* Index of Recently Read Vector  */
    int lgx;	/* Logarithmic Gain Index */

    static real QMEM *vector;	/* recently read vector in the queue */

    static real
	zero_response[IDIM],
	weighted_speech[IDIM],
	target[IDIM],
	normtarg[IDIM],
	cb_vec[IDIM],
	pn[IDIM];
    static real	gain =1.0, scale=1.0;
    
    vector = vector_end - IDIM;
    if (vector < thequeue)
	vector += QSIZE;
    vx = vector-thequeue;

    if (pwf_z_coeff_obsolete_p) {
	UPDATE(pwf_z_coeff); UPDATE(pwf_p_coeff);
    }
    				SPDEBUG(10,vector, IDIM);
    pwfilter2(vector, weighted_speech);
    				SPDEBUG(1,weighted_speech, IDIM);
    UPDATE(sf_coeff);
    zresp(zero_response);
    				SPDEBUG(2,zero_response, IDIM);
    sub_sig(weighted_speech, zero_response, target);
    				SPDEBUG(3,target, IDIM);
    scale = 1.0 / gain;
    sig_scale(scale, target, normtarg);
    				SPDEBUG(4,normtarg, IDIM);
    UPDATE(imp_resp);
    trev_conv(imp_resp, normtarg, pn);
    				SPDEBUG(6, pn, IDIM);
    UPDATE(shape_energy);
    ix = cb_index(pn);
    put_index(ix);
    cb_excitation(ix, cb_vec);
    				SPDEBUG(7, cb_vec, IDIM);
    sig_scale(gain, cb_vec, qspeech+vx);
    				SPDEBUG(8, qspeech+vx, IDIM);
    UPDATE(gp_coeff);
    lgx = vx/IDIM;
    gain = predict_gain(qspeech+vx, log_gains + lgx);
    				SPDEBUG(11, &gain, 1);
    				SPDEBUG(12, log_gains+lgx, 1);
    mem_update(qspeech+vx, synspeech+vx);
    				SPDEBUG(9, synspeech+vx, IDIM);
    dec_end = vx+IDIM;
    if (dec_end >= QSIZE)
	dec_end -= QSIZE;
    NEXT_FFASE;
}
Пример #3
0
/*
 * sppp_dlunitdatareq()
 *
 * MT-Perimeters:
 *    shared inner, shared outer.
 *
 * Description:
 *    Handle DL_UNITDATA_REQ request, called by sppp_mproto. This procedure
 *    gets called for M_PROTO (DLPI) style of transmission. The fact that we
 *    have acknowledged IP's fastpath probing (DL_IOC_HDR_INFO) does not
 *    guarantee that IP will always transmit via M_DATA, and it merely implies
 *    that such situation _may_ happen. In other words, IP may decide to use
 *    M_PROTO (DLPI) for data transmission should it decide to do so.
 *    Therefore, we should never place any restrictions or checks against
 *    streams marked with SPS_FASTPATH, since it is legal for this procedure
 *    to be entered with or without the bit set.
 */
static int
sppp_dlunitdatareq(queue_t *q, mblk_t *mp, spppstr_t *sps)
{
	sppa_t		*ppa;
	mblk_t		*hdrmp;
	mblk_t		*pktmp;
	dl_unitdata_req_t *dludp;
	int		dladdroff;
	int		dladdrlen;
	int		msize;
	int		error = 0;
	boolean_t	is_promisc;

	ASSERT(q != NULL && q->q_ptr != NULL);
	ASSERT(mp != NULL && mp->b_rptr != NULL);
	ASSERT((MTYPE(mp) == M_PCPROTO) || (MTYPE(mp) == M_PROTO));
	dludp = (dl_unitdata_req_t *)mp->b_rptr;
	dladdroff = dludp->dl_dest_addr_offset;
	dladdrlen = dludp->dl_dest_addr_length;
	ASSERT(sps != NULL);
	ASSERT(!IS_SPS_PIOATTACH(sps));
	ASSERT(sps->sps_dlstate == DL_IDLE);
	ASSERT(q->q_ptr == sps);
	/*
	 * If this stream is not attached to any ppas, then discard data
	 * coming down through this stream.
	 */
	ppa = sps->sps_ppa;
	if (ppa == NULL) {
		DBGERROR((CE_CONT, "DLPI unitdata: no attached ppa\n"));
		error = ENOLINK;
	} else if (mp->b_cont == NULL) {
		DBGERROR((CE_CONT, "DLPI unitdata: missing data\n"));
		error = EPROTO;
	}
	if (error != 0) {
		dluderrorind(q, mp, mp->b_rptr + dladdroff, dladdrlen,
		    DL_BADDATA, error);
		return (0);
	}
	ASSERT(mp->b_cont->b_rptr != NULL);
	/*
	 * Check if outgoing packet size is larger than allowed. We use
	 * msgdsize to count all of M_DATA blocks in the message.
	 */
	msize = msgdsize(mp);
	if (msize > ppa->ppa_mtu) {
		/* Log, and send it anyway */
		mutex_enter(&ppa->ppa_sta_lock);
		ppa->ppa_otoolongs++;
		mutex_exit(&ppa->ppa_sta_lock);
	}
	if (IS_SPS_KDEBUG(sps)) {
		SPDEBUG(PPP_DRV_NAME
		    "/%d: DL_UNITDATA_REQ (%d bytes) sps=0x%p flags=0x%b "
		    "ppa=0x%p flags=0x%b\n", sps->sps_mn_id, msize,
		    (void *)sps, sps->sps_flags, SPS_FLAGS_STR,
		    (void *)ppa, ppa->ppa_flags, PPA_FLAGS_STR);
	}
	/* Allocate a message (M_DATA) to contain PPP header bytes. */
	if ((hdrmp = allocb(PPP_HDRLEN, BPRI_MED)) == NULL) {
		mutex_enter(&ppa->ppa_sta_lock);
		ppa->ppa_allocbfail++;
		mutex_exit(&ppa->ppa_sta_lock);
		DBGERROR((CE_CONT,
		    "DLPI unitdata: can't allocate header buffer\n"));
		dluderrorind(q, mp, mp->b_rptr + dladdroff, dladdrlen,
		    DL_SYSERR, ENOSR);
		return (0);
	}
	/*
	 * Should there be any promiscuous stream(s), send the data up
	 * for each promiscuous stream that we recognize.
	 */
	rw_enter(&ppa->ppa_sib_lock, RW_READER);
	is_promisc = ppa->ppa_promicnt;
	if (is_promisc) {
		ASSERT(ppa->ppa_streams != NULL);
		sppp_dlprsendup(ppa->ppa_streams, mp->b_cont, sps->sps_sap,
		    B_FALSE);
	}
	rw_exit(&ppa->ppa_sib_lock);
	/* Discard DLPI header and keep only IP payload (mp->b_cont). */
	pktmp = mp->b_cont;
	mp->b_cont = NULL;
	freemsg(mp);
	mp = hdrmp;

	*(uchar_t *)mp->b_wptr++ = PPP_ALLSTATIONS;
	*(uchar_t *)mp->b_wptr++ = PPP_UI;
	*(uchar_t *)mp->b_wptr++ = ((uint16_t)sps->sps_sap >> 8) & 0xff;
	*(uchar_t *)mp->b_wptr++ = ((uint16_t)sps->sps_sap) & 0xff;
	ASSERT(MBLKL(mp) == PPP_HDRLEN);

	linkb(mp, pktmp);
	/*
	 * Only time-stamp the packet with hrtime if the upper stream
	 * is configured to do so.
	 */
	if (IS_PPA_TIMESTAMP(ppa)) {
		ppa->ppa_lasttx = gethrtime();
	}
	/*
	 * Just put this back on the queue and allow the write service
	 * routine to handle it.  We're nested too deeply here to
	 * rewind the stack sufficiently to prevent overflow.  This is
	 * the slow path anyway.
	 */
	if (putq(q, mp) == 0) {
		mutex_enter(&ppa->ppa_sta_lock);
		ppa->ppa_oqdropped++;
		mutex_exit(&ppa->ppa_sta_lock);
		freemsg(mp);
	} else {
		qenable(q);
	}
	return (0);
}