⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcmconverter.c

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 C
📖 第 1 页 / 共 3 页
字号:
	*dst++ = I(apd->last[0].b, src[0], r);
	*dst++ = I(apd->last[1].b, src[1], r);
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

/* the conversion routines with rate conversion are labelled cvt<X><Y><N><M>C
 * where :
 * <X> is the (M)ono/(S)tereo configuration of  input channel
 * <Y> is the (M)ono/(S)tereo configuration of output channel
 * <N> is the number of bits of  input channel (8 or 16)
 * <M> is the number of bits of output channel (8 or 16)
 *
 */
static	void cvtSM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
		      unsigned char* dst, LPDWORD ndst)
{
    double   	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->last[1].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            *dst++ = I(M8(apd->last[0].b, apd->last[1].b), M8(src[0], src[1]), r);
        else
            *dst++ = M8(apd->last[0].b, apd->last[1].b);
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
		      unsigned char* dst, LPDWORD ndst)
{
    double	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            dst[0] = dst[1] = I(apd->last[0].b, src[0], r);
        else
            dst[0] = dst[1] = apd->last[0].b;
	dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
		      unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            *dst++ = I(apd->last[0].b, src[0], r);
        else
            *dst++ = apd->last[0].b;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
		       unsigned char* dst, LPDWORD ndst)
{
    double	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->last[1].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));
        else
            W16(dst, C816(apd->last[0].b));
        dst += 2;
        if (*nsrc)	/* don't go off end of data */
	    W16(dst, I(C816(apd->last[1].b), C816(src[1]), r));
        else
	    W16(dst, C816(apd->last[1].b));
        dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->last[1].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            W16(dst, I(M16(C816(apd->last[0].b), C816(apd->last[1].b)),
                       M16(C816(src[0]), C816(src[1])), r));
        else
            W16(dst, M16(C816(apd->last[0].b), C816(apd->last[1].b)));
	dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    short	v;
    TRACE("(%p, %p, %p->(%ld), %p, %p->(%ld))\n", apd, src, nsrc, *nsrc, dst, ndst, *ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    v = I(C816(apd->last[0].b), C816(src[0]), r);
        else
            v = C816(apd->last[0].b);
	W16(dst, v);		dst += 2;
	W16(dst, v);		dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].b = *src++;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));
        else
            W16(dst, C816(apd->last[0].b));
	dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->last[1].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc) {	/* don't go off end of data */
	    *dst++ = C168(I(apd->last[0].s, R16(src)  , r));
	    *dst++ = C168(I(apd->last[1].s, R16(src+2), r));
        } else {
	    *dst++ = C168(apd->last[0].s);
	    *dst++ = C168(apd->last[1].s);
        }
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->last[1].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    *dst++ = C168(I(M16(apd->last[0].s, apd->last[1].s),
			    M16(R16(src), R16(src + 2)), r));
        else
	    *dst++ = C168(M16(apd->last[0].s, apd->last[1].s));
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}


static	void cvtMS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    dst[0] = dst[1] = C168(I(apd->last[0].s, R16(src), r));
        else
	    dst[0] = dst[1] = C168(apd->last[0].s);
        dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}


static	void cvtMM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    *dst++ = C168(I(apd->last[0].s, R16(src), r));
        else
	    *dst++ = C168(apd->last[0].s);
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->last[1].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    W16(dst, I(apd->last[0].s, R16(src), r));
        else
	    W16(dst, apd->last[0].s);
        dst += 2;
        if (*nsrc)	/* don't go off end of data */
	    W16(dst, I(apd->last[1].s, R16(src+2), r));
        else
	    W16(dst, apd->last[1].s);
        dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtSM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->last[1].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
            W16(dst, I(M16(apd->last[0].s, apd->last[1].s),
 		       M16(R16(src), R16(src+2)), r));
        else
            W16(dst, M16(apd->last[0].s, apd->last[1].s));
 	dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    short	v;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    v = I(apd->last[0].s, R16(src), r);
        else
	    v = apd->last[0].s;
	W16(dst, v);		dst += 2;
	W16(dst, v);		dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void cvtMM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
			unsigned char* dst, LPDWORD ndst)
{
    double     	r;
    TRACE("(%p, %p, %p, %p, %p)\n", apd, src, nsrc, dst, ndst);

    while (*nsrc != 0 && *ndst != 0) {
	while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
	    if (*nsrc == 0) return;
	    apd->last[0].s = R16(src);	src += 2;
	    apd->srcPos++;
	    (*nsrc)--;
	}
	/* now do the interpolation */
        if (*nsrc)	/* don't go off end of data */
	    W16(dst, I(apd->last[0].s, R16(src), r));
        else
	    W16(dst, apd->last[0].s);
        dst += 2;
	apd->dstPos += apd->dstIncr;
	(*ndst)--;
    }
}

static	void (*PCM_ConvertChangeRate[16])(AcmPcmData* apd,
					  const unsigned char* src, LPDWORD nsrc,
					  unsigned char* dst, LPDWORD ndst) = {
    cvtSS88C,   cvtSM88C,   cvtMS88C,   cvtMM88C,
    cvtSS816C,	cvtSM816C,  cvtMS816C,  cvtMM816C,
    cvtSS168C,	cvtSM168C,  cvtMS168C,  cvtMM168C,
    cvtSS1616C, cvtSM1616C, cvtMS1616C, cvtMM1616C,
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -