Stefano Guidoni : imaadp32: Fixed adpcm_FormatSuggest.

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


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

Author: Stefano Guidoni <s.guidoni at tin.it>
Date:   Sun Mar  1 00:10:15 2009 +0100

imaadp32: Fixed adpcm_FormatSuggest.

---

 dlls/imaadp32.acm/imaadp32.c |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/dlls/imaadp32.acm/imaadp32.c b/dlls/imaadp32.acm/imaadp32.c
index 4a8e3cb..9ad577e 100644
--- a/dlls/imaadp32.acm/imaadp32.c
+++ b/dlls/imaadp32.acm/imaadp32.c
@@ -123,6 +123,30 @@ static	DWORD	ADPCM_GetFormatIndex(const WAVEFORMATEX *wfx)
     return 0xFFFFFFFF;
 }
 
+static void     init_wfx_ima_adpcm(IMAADPCMWAVEFORMAT* awfx/*, DWORD nba*/)
+{
+    register WAVEFORMATEX*      pwfx = &awfx->wfx;
+
+    /* we assume wFormatTag, nChannels, nSamplesPerSec and wBitsPerSample
+     * have been initialized... */
+
+    if (pwfx->wFormatTag != WAVE_FORMAT_IMA_ADPCM) {FIXME("wrong FT\n"); return;}
+    if (ADPCM_GetFormatIndex(pwfx) == 0xFFFFFFFF) {FIXME("wrong fmt\n"); return;}
+
+    switch (pwfx->nSamplesPerSec)
+    {
+    case  8000: pwfx->nBlockAlign = 256 * pwfx->nChannels;   break;
+    case 11025: pwfx->nBlockAlign = 256 * pwfx->nChannels;   break;
+    case 22050: pwfx->nBlockAlign = 512 * pwfx->nChannels;   break;
+    case 44100: pwfx->nBlockAlign = 1024 * pwfx->nChannels;  break;
+    default: /*pwfx->nBlockAlign = nba;*/  break;
+    }
+    pwfx->cbSize = sizeof(WORD);
+
+    awfx->wSamplesPerBlock = (pwfx->nBlockAlign - (4 * pwfx->nChannels) * 2) / pwfx->nChannels + 1;
+    pwfx->nAvgBytesPerSec = (pwfx->nSamplesPerSec * pwfx->nBlockAlign) / awfx->wSamplesPerBlock;
+}
+
 /***********************************************************************
  *           R16
  *
@@ -612,6 +636,7 @@ static	LRESULT	ADPCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
     /* some tests ... */
     if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
 	adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
+	adfs->pwfxSrc->wFormatTag == adfs->pwfxDst->wFormatTag ||
 	ADPCM_GetFormatIndex(adfs->pwfxSrc) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
     /* FIXME: should do those tests against the real size (according to format tag */
 
@@ -636,22 +661,21 @@ static	LRESULT	ADPCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
             adfs->pwfxDst->wFormatTag = WAVE_FORMAT_PCM;
     }
 
-    /* check if result is ok */
-    if (ADPCM_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
-
     /* recompute other values */
     switch (adfs->pwfxDst->wFormatTag)
     {
     case WAVE_FORMAT_PCM:
         adfs->pwfxDst->nBlockAlign = (adfs->pwfxDst->nChannels * adfs->pwfxDst->wBitsPerSample) / 8;
         adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign;
+        /* check if result is ok */
+        if (ADPCM_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
         break;
     case WAVE_FORMAT_IMA_ADPCM:
-        adfs->pwfxDst->nBlockAlign = 1024;
+        init_wfx_ima_adpcm((IMAADPCMWAVEFORMAT*)adfs->pwfxDst);
         /* FIXME: not handling header overhead */
-        adfs->pwfxDst->nAvgBytesPerSec = ((adfs->pwfxDst->nSamplesPerSec * 4) / 8) * adfs->pwfxSrc->nChannels;
-        ((IMAADPCMWAVEFORMAT*)adfs->pwfxDst)->wSamplesPerBlock = (1024 - 4 * adfs->pwfxSrc->nChannels) * (2 / adfs->pwfxSrc->nChannels) + 1;
         TRACE("setting spb=%u\n", ((IMAADPCMWAVEFORMAT*)adfs->pwfxDst)->wSamplesPerBlock);
+        /* check if result is ok */
+        if (ADPCM_GetFormatIndex(adfs->pwfxDst) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
         break;
     default:
         FIXME("\n");




More information about the wine-cvs mailing list