Stefano Guidoni : imaadp32: block align the adpcm extra data.

Alexandre Julliard julliard at winehq.org
Mon Mar 2 09:01:59 CST 2009


Module: wine
Branch: master
Commit: c7fb665a927270f86ae2efc2ed130265b45cf903
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c7fb665a927270f86ae2efc2ed130265b45cf903

Author: Stefano Guidoni <s.guidoni at tin.it>
Date:   Fri Feb 27 19:59:11 2009 +0100

imaadp32: block align the adpcm extra data.

---

 dlls/imaadp32.acm/imaadp32.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/dlls/imaadp32.acm/imaadp32.c b/dlls/imaadp32.acm/imaadp32.c
index dd3cc5d..4a8e3cb 100644
--- a/dlls/imaadp32.acm/imaadp32.c
+++ b/dlls/imaadp32.acm/imaadp32.c
@@ -775,6 +775,8 @@ static	LRESULT	ADPCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)
  */
 static	LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMSIZE adss)
 {
+    DWORD nblocks;
+
     switch (adss->fdwSize)
     {
     case ACM_STREAMSIZEF_DESTINATION:
@@ -782,14 +784,18 @@ static	LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMS
 	if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
 	    adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM)
         {
-	    /* don't take block overhead into account, doesn't matter too much */
-	    adss->cbSrcLength = adss->cbDstLength * 4;
+            nblocks = adss->cbDstLength / adsi->pwfxDst->nBlockAlign;
+            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 &&
                  adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
         {
-	    FIXME("misses the block header overhead\n");
-	    adss->cbSrcLength = 256 + adss->cbDstLength / 4;
+            nblocks = adss->cbDstLength / (adsi->pwfxDst->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxSrc)->wSamplesPerBlock);
+            if (nblocks == 0)
+                return ACMERR_NOTPOSSIBLE;
+            adss->cbSrcLength = nblocks * adsi->pwfxSrc->nBlockAlign;
 	}
         else
         {
@@ -801,14 +807,24 @@ static	LRESULT ADPCM_StreamSize(const ACMDRVSTREAMINSTANCE *adsi, PACMDRVSTREAMS
 	if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
 	    adsi->pwfxDst->wFormatTag == WAVE_FORMAT_IMA_ADPCM)
         {
-	    FIXME("misses the block header overhead\n");
-	    adss->cbDstLength = 256 + adss->cbSrcLength / 4;
+            nblocks = adss->cbSrcLength / (adsi->pwfxSrc->nBlockAlign * ((IMAADPCMWAVEFORMAT*)adsi->pwfxDst)->wSamplesPerBlock);
+            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 &&
                  adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
         {
-	    /* don't take block overhead into account, doesn't matter too much */
-	    adss->cbDstLength = adss->cbSrcLength * 4;
+            nblocks = adss->cbSrcLength / adsi->pwfxSrc->nBlockAlign;
+            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
         {




More information about the wine-cvs mailing list