Esempio n. 1
0
static	void cvtSS168K(const unsigned char* src, int ns, unsigned char* dst)
{
    TRACE("(%p, %d, %p)\n", src, ns, dst);

    while (ns--) {
	*dst++ = C168(R16(src));	src += 2;
	*dst++ = C168(R16(src));	src += 2;
    }
}
Esempio n. 2
0
static	void cvtMS168C(DWORD srcRate, const unsigned char* src, LPDWORD nsrc,
		       DWORD dstRate, unsigned char* dst, LPDWORD ndst)
{
    DWORD error = dstRate / 2;
    TRACE("(%d, %p, %p, %d, %p, %p)\n", srcRate, src, nsrc, dstRate, dst, ndst);

    while ((*ndst)--) {
        *dst++ = C168(R16(src));
        *dst++ = C168(R16(src));
        error = error + srcRate;
        while (error > dstRate) {
            src += 2;
            (*nsrc)--;
            if (*nsrc==0)
                return;
            error = error - dstRate;
        }
    }
}
Esempio n. 3
0
static	void cvtSSms16K(const ACMDRVSTREAMINSTANCE *adsi,
                        const unsigned char* src, LPDWORD nsrc,
                        unsigned char* dst, LPDWORD ndst)
{
    int                 ideltaL, ideltaR;
    int                 sample1L, sample2L;
    int                 sample1R, sample2R;
    ADPCMCOEFSET        coeffL, coeffR;
    int                 nsamp;
    int		        nsamp_blk = ((ADPCMWAVEFORMAT*)adsi->pwfxSrc)->wSamplesPerBlock;
    DWORD	        nblock = min(*nsrc / adsi->pwfxSrc->nBlockAlign,
                                     *ndst / (nsamp_blk * adsi->pwfxDst->nBlockAlign));

    *nsrc = nblock * adsi->pwfxSrc->nBlockAlign;
    *ndst = nblock * nsamp_blk * adsi->pwfxDst->nBlockAlign;

    nsamp_blk -= 2; /* see below for samples from block head */
    for (; nblock > 0; nblock--)
    {
        const unsigned char*    in_src = src;

        assert(*src <= 6);
        coeffL = MSADPCM_CoeffSet[*src++];
        assert(*src <= 6);
        coeffR = MSADPCM_CoeffSet[*src++];

        ideltaL  = R16(src);    src += 2;
        ideltaR  = R16(src);    src += 2;
        sample1L = R16(src);    src += 2;
        sample1R = R16(src);    src += 2;
        sample2L = R16(src);    src += 2;
        sample2R = R16(src);    src += 2;

        if(adsi->pwfxDst->wBitsPerSample == 8){
            /* store samples from block head */
            *dst = C168(sample2L);      ++dst;
            *dst = C168(sample2R);      ++dst;
            *dst = C168(sample1L);      ++dst;
            *dst = C168(sample1R);      ++dst;

            for (nsamp = nsamp_blk; nsamp > 0; nsamp--)
            {
                process_nibble(*src >> 4, &ideltaL, &sample1L, &sample2L, &coeffL);
                *dst = C168(sample1L); ++dst;
                process_nibble(*src++ & 0x0F, &ideltaR, &sample1R, &sample2R, &coeffR);
                *dst = C168(sample1R); ++dst;
            }
        }else if(adsi->pwfxDst->wBitsPerSample == 16){
Esempio n. 4
0
void AudioDeck::FillBuffers()
{
    int buffers_to_fill = cs->NeedsUpdate();
    unsigned int size;

    // If we don't need an update, still update the visualization stuff
    if (!buffers_to_fill) {
        // No update needed?
        if (this->vis && !this->pause) this->vis->bClear = false;

        UpdateVizJunk();

        if (this->isFinished && this->freeDeckOnFinish) {
            delete this;
            return;
        }
    }
    else
    {
        if (decodeData->outOfData&&bufferCountdown>0) {
            bufferCountdown--;
        }

        if (!bufferCountdown && !this->isFinished) {
            this->isFinished = true;
            this->pause = true;

            if (cs->IsOpen())
                cs->Close();

            if (this->freeDeckOnFinish)
                delete this;

            return;
        }
    }

    while (buffers_to_fill--)
    {
        unsigned char *data;
        unsigned long l = 1;
        unsigned long pos = 0;

        data = this->cs->GetBuffer(&size);

        // Prepad the buffer with silence!
        if (decodeData->bit == 8)
            memset(data,0x80,size); // unsigned!
        else
            memset(data,0,size); // signed (:

        // If the decoder says we're out of data...
        if (decodeData->outOfData)
        {
            // Write silence to vc
            memset(temp_waveL,0x80,576);
            memset(temp_waveR,0x80,576);

            while (pos<size) {

                vc.SetWrittenTime(this->writtenpos);

                vc.PutWaveLeft(temp_waveL);
                vc.PutWaveRight(temp_waveR);
                vc.SetEngineerData(0,0,0,0);

                vc.EndEntry();

                UpdateVizJunk();

                l = MIN(576,size-pos);

                unsigned long nlen;
                nlen = (unsigned long)(float)((float)l*1000.0f)/((float)(decodeData->samplerate*sampsize));
                totsamps += l;
                this->writtenpos = (totsamps*1000)/(decodeData->samplerate*sampsize);
                this->currentPosition += nlen;

                pos += l;
            }
        }
        else
        {
            if (this->vis) this->vis->bClear = false;
        }

        while (l && pos<size && !decodeData->outOfData) {

            // What to do if the Decoder says we're almost out of data?

            //			vc.NextFrame();
            //			vc.SetReadTime( cP->GetOutputTime() );
            //			vc.SetWriteTime( od->writtenpos );

            vc.SetWrittenTime( this->writtenpos );

            // If our engineer wants to set cached data, here is where we do it!
            /*if (oc->setcacheinfo)
             {
             //onu_deck_cable_s *cable, long *data1, long *data2, long *data3, long *data4
             long data[4];
             oc->setcacheinfo(oc,&data[0],&data[1],&data[2],&data[3]);
             vc.SetEngineerData(data[0],data[1],data[2],data[3]);
             }
             else
             vc.SetEngineerData(0,0,0,0);*/

            vc.SetEngineerData(0,0,0,0);

            l = this->decodeData->decoder->Render((size-pos<576*sampsize)?(size-pos):576*sampsize,(void*)((long)data+(long)pos),*this->decodeData);

            if (l >= 576*sampsize)
            {
                int i = 0;
                int samp = 0;

                if (decodeData->bit == 16)
                {
                    short *copybuf = (short*)((long)data+(long)pos);

                    for (i=0; i<576; i++, samp+=decodeData->ch)
                    {
                        temp_waveL[i] = C168(copybuf[samp]);

                        if (decodeData->ch == 1)
                            temp_waveR[i] = C168(copybuf[samp]);
                        else
                            temp_waveR[i] = C168(copybuf[samp+1]); // Stereo (:

                        //temp_waveL[i] = copybuf[samp] >> 8;
                        //temp_waveR[i] = copybuf[samp+1] >> 8;
                        //temp_waveL[i] = 0xFF;
                        //temp_waveR[i] = 0xFF;
                    }
                }
                else if (decodeData->bit == 8)
                {
                    unsigned char *copybuf = (unsigned char*)((long)data+(long)pos);

                    for (i=0; i<576; i++, samp+=decodeData->ch)
                    {
                        temp_waveL[i] = copybuf[samp];

                        if (decodeData->ch == 1)
                            temp_waveR[i] = copybuf[samp];
                        else
                            temp_waveR[i] = copybuf[samp+1]; // Stereo (:

                        //temp_waveL[i] = copybuf[samp] >> 8;
                        //temp_waveR[i] = copybuf[samp+1] >> 8;
                        //temp_waveL[i] = 0xFF;
                        //temp_waveR[i] = 0xFF;
                    }
                }

                vc.PutWaveLeft(temp_waveL);
                vc.PutWaveRight(temp_waveR);
            }
            else
            {
                vc.PutWaveLeft(temp_waveL);
                vc.PutWaveRight(temp_waveR);
            }

            vc.EndEntry();

            UpdateVizJunk();

            unsigned long nlen;
            nlen = (unsigned long)(float)((float)l*1000.0f)/((float)(decodeData->samplerate*sampsize));
            totsamps += l;
            this->writtenpos = (totsamps*1000)/(decodeData->samplerate*sampsize);
            this->currentPosition += nlen;

            pos += l;
        }

        this->cs->LockBuffer(size);

        /*			if (playbackPos >= targetLength)
         break;*/
    }
}