imaadp32: block align the adpcm extra data.

This commit is contained in:
Stefano Guidoni 2009-02-27 19:59:11 +01:00 committed by Alexandre Julliard
parent 5c130c813a
commit c7fb665a92

View File

@ -775,6 +775,8 @@ static LRESULT ADPCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)
*/ */
static LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMSIZE adss) static LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMSIZE adss)
{ {
DWORD nblocks;
switch (adss->fdwSize) switch (adss->fdwSize)
{ {
case ACM_STREAMSIZEF_DESTINATION: case ACM_STREAMSIZEF_DESTINATION:
@ -782,14 +784,18 @@ static LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMS
if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM && if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM) adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM)
{ {
/* don't take block overhead into account, doesn't matter too much */ nblocks = adss->cbDstLength / adsi->pwfxDst->nBlockAlign;
adss->cbSrcLength = adss->cbDstLength * 4; if (nblocks == 0)
return ACMERR_NOTPOSSIBLE;
adss->cbSrcLength = nblocks * adsi->pwfxSrc->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxDst)->wSamplesPerBlock;
} }
else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_IMA_ADPCM && else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_IMA_ADPCM &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
{ {
FIXME("misses the block header overhead\n"); nblocks = adss->cbDstLength / (adsi->pwfxDst->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxSrc)->wSamplesPerBlock);
adss->cbSrcLength = 256 + adss->cbDstLength / 4; if (nblocks == 0)
return ACMERR_NOTPOSSIBLE;
adss->cbSrcLength = nblocks * adsi->pwfxSrc->nBlockAlign;
} }
else else
{ {
@ -801,14 +807,24 @@ static LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMS
if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM && if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM) adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM)
{ {
FIXME("misses the block header overhead\n"); nblocks = adss->cbSrcLength / (adsi->pwfxSrc->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxDst)->wSamplesPerBlock);
adss->cbDstLength = 256 + adss->cbSrcLength / 4; if (nblocks == 0)
return ACMERR_NOTPOSSIBLE;
if (adss->cbSrcLength % (adsi->pwfxSrc->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxDst)->wSamplesPerBlock))
/* Round block count up. */
nblocks++;
adss->cbDstLength = nblocks * adsi->pwfxDst->nBlockAlign;
} }
else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_IMA_ADPCM && else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_IMA_ADPCM &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
{ {
/* don't take block overhead into account, doesn't matter too much */ nblocks = adss->cbSrcLength / adsi->pwfxSrc->nBlockAlign;
adss->cbDstLength = adss->cbSrcLength * 4; if (nblocks == 0)
return ACMERR_NOTPOSSIBLE;
if (adss->cbSrcLength % adsi->pwfxSrc->nBlockAlign)
/* Round block count up. */
nblocks++;
adss->cbDstLength = nblocks * adsi->pwfxDst->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxSrc)->wSamplesPerBlock;
} }
else else
{ {