[WINEMP3.ACM] Sync with Wine 3.0. CORE-14225

This commit is contained in:
Amine Khaldi 2018-01-20 13:52:52 +01:00
parent a5cb9a0a8d
commit c8f158b700
2 changed files with 19 additions and 78 deletions

View file

@ -215,7 +215,6 @@ static void MPEG3_Reset(PACMDRVSTREAMINSTANCE adsi, AcmMpeg3Data* aad)
*/ */
static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi) static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
{ {
LRESULT error = MMSYSERR_NOTSUPPORTED;
AcmMpeg3Data* aad; AcmMpeg3Data* aad;
int err; int err;
@ -239,18 +238,6 @@ static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEG) && adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEG) &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM)
{ {
if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3)
{
MPEGLAYER3WAVEFORMAT *formatmp3 = (MPEGLAYER3WAVEFORMAT *)adsi->pwfxSrc;
if (adsi->pwfxSrc->cbSize < MPEGLAYER3_WFX_EXTRA_BYTES ||
formatmp3->wID != MPEGLAYER3_ID_MPEG)
{
error = ACMERR_NOTPOSSIBLE;
goto theEnd;
}
}
/* resampling or mono <=> stereo not available /* resampling or mono <=> stereo not available
* MPEG3 algo only define 16 bit per sample output * MPEG3 algo only define 16 bit per sample output
*/ */
@ -271,10 +258,13 @@ static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
mpg123_param(aad->mh, MPG123_ADD_FLAGS, MPG123_IGNORE_INFOFRAME, 0); mpg123_param(aad->mh, MPG123_ADD_FLAGS, MPG123_IGNORE_INFOFRAME, 0);
#endif #endif
} }
/* no encoding yet
else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM && else if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM &&
adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3) (adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEGLAYER3 ||
*/ adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEG))
{
WARN("Encoding to MPEG is not supported\n");
goto theEnd;
}
else goto theEnd; else goto theEnd;
MPEG3_Reset(adsi, aad); MPEG3_Reset(adsi, aad);
@ -283,7 +273,7 @@ static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
theEnd: theEnd:
HeapFree(GetProcessHeap(), 0, aad); HeapFree(GetProcessHeap(), 0, aad);
adsi->dwDriver = 0L; adsi->dwDriver = 0L;
return error; return MMSYSERR_NOTSUPPORTED;
} }
/*********************************************************************** /***********************************************************************
@ -749,54 +739,19 @@ static LRESULT MPEG3_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
case 1: case 1:
aftd->dwFormatTag = WAVE_FORMAT_MPEGLAYER3; aftd->dwFormatTag = WAVE_FORMAT_MPEGLAYER3;
aftd->cbFormatSize = sizeof(MPEGLAYER3WAVEFORMAT); aftd->cbFormatSize = sizeof(MPEGLAYER3WAVEFORMAT);
aftd->cStandardFormats = NUM_MPEG3_FORMATS; aftd->cStandardFormats = 0;
lstrcpyW(aftd->szFormatTag, szMpeg3); lstrcpyW(aftd->szFormatTag, szMpeg3);
break; break;
case 2: case 2:
aftd->dwFormatTag = WAVE_FORMAT_MPEG; aftd->dwFormatTag = WAVE_FORMAT_MPEG;
aftd->cbFormatSize = sizeof(MPEG1WAVEFORMAT); aftd->cbFormatSize = sizeof(MPEG1WAVEFORMAT);
aftd->cStandardFormats = NUM_MPEG3_FORMATS; aftd->cStandardFormats = 0;
lstrcpyW(aftd->szFormatTag, szMpeg); lstrcpyW(aftd->szFormatTag, szMpeg);
break; break;
} }
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
} }
static void fill_in_mp3(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
{
MPEGLAYER3WAVEFORMAT* mp3wfx = (MPEGLAYER3WAVEFORMAT*)wfx;
wfx->nAvgBytesPerSec = bit_rate / 8;
if (cbwfx >= sizeof(WAVEFORMATEX))
wfx->cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
if (cbwfx >= sizeof(MPEGLAYER3WAVEFORMAT))
{
mp3wfx->wID = MPEGLAYER3_ID_MPEG;
mp3wfx->fdwFlags = MPEGLAYER3_FLAG_PADDING_OFF;
mp3wfx->nBlockSize = (bit_rate * 144) / wfx->nSamplesPerSec;
mp3wfx->nFramesPerBlock = 1;
mp3wfx->nCodecDelay = 0x0571;
}
}
static void fill_in_mpeg(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
{
MPEG1WAVEFORMAT* mp3wfx = (MPEG1WAVEFORMAT*)wfx;
wfx->nAvgBytesPerSec = bit_rate / 8;
if (cbwfx >= sizeof(WAVEFORMATEX))
wfx->cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);
if (cbwfx >= sizeof(MPEG1WAVEFORMAT))
{
mp3wfx->fwHeadLayer = ACM_MPEG_LAYER3;
mp3wfx->dwHeadBitrate = wfx->nAvgBytesPerSec * 8;
mp3wfx->fwHeadMode = ACM_MPEG_JOINTSTEREO;
mp3wfx->fwHeadModeExt = 0xf;
mp3wfx->wHeadEmphasis = 1;
mp3wfx->fwHeadFlags = ACM_MPEG_ID_MPEG1;
}
}
/*********************************************************************** /***********************************************************************
* MPEG3_FormatDetails * MPEG3_FormatDetails
* *
@ -827,16 +782,8 @@ static LRESULT MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
break; break;
case WAVE_FORMAT_MPEGLAYER3: case WAVE_FORMAT_MPEGLAYER3:
case WAVE_FORMAT_MPEG: case WAVE_FORMAT_MPEG:
if (afd->dwFormatIndex >= NUM_MPEG3_FORMATS) return ACMERR_NOTPOSSIBLE; WARN("Encoding to MPEG is not supported\n");
afd->pwfx->nChannels = MPEG3_Formats[afd->dwFormatIndex].nChannels; return ACMERR_NOTPOSSIBLE;
afd->pwfx->nSamplesPerSec = MPEG3_Formats[afd->dwFormatIndex].rate;
afd->pwfx->wBitsPerSample = MPEG3_Formats[afd->dwFormatIndex].nBits;
afd->pwfx->nBlockAlign = 1;
if (afd->dwFormatTag == WAVE_FORMAT_MPEGLAYER3)
fill_in_mp3(afd->cbwfx, afd->pwfx, 192000);
else
fill_in_mpeg(afd->cbwfx, afd->pwfx, 192000);
break;
default: default:
WARN("Unsupported tag %08x\n", afd->dwFormatTag); WARN("Unsupported tag %08x\n", afd->dwFormatTag);
return MMSYSERR_INVALPARAM; return MMSYSERR_INVALPARAM;
@ -869,18 +816,15 @@ static LRESULT MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels; adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels;
if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC)) if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NSAMPLESPERSEC))
adfs->pwfxDst->nSamplesPerSec = adfs->pwfxSrc->nSamplesPerSec; adfs->pwfxDst->nSamplesPerSec = adfs->pwfxSrc->nSamplesPerSec;
if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE)) if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WBITSPERSAMPLE))
{ adfs->pwfxDst->wBitsPerSample = 16;
if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM)
adfs->pwfxDst->wBitsPerSample = 4;
else
adfs->pwfxDst->wBitsPerSample = 16;
}
if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG)) if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_WFORMATTAG))
{ {
if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM)
adfs->pwfxDst->wFormatTag = WAVE_FORMAT_MPEGLAYER3; {
WARN("Encoding to MPEG is not supported\n");
return ACMERR_NOTPOSSIBLE;
}
else else
adfs->pwfxDst->wFormatTag = WAVE_FORMAT_PCM; adfs->pwfxDst->wFormatTag = WAVE_FORMAT_PCM;
} }
@ -896,12 +840,9 @@ static LRESULT MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign; adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * adfs->pwfxDst->nBlockAlign;
break; break;
case WAVE_FORMAT_MPEG: case WAVE_FORMAT_MPEG:
adfs->pwfxDst->nBlockAlign = 1;
fill_in_mpeg(adfs->cbwfxDst, adfs->pwfxDst, 192000);
break;
case WAVE_FORMAT_MPEGLAYER3: case WAVE_FORMAT_MPEGLAYER3:
adfs->pwfxDst->nBlockAlign = 1; WARN("Encoding to MPEG is not supported\n");
fill_in_mp3(adfs->cbwfxDst, adfs->pwfxDst, 192000); return ACMERR_NOTPOSSIBLE;
break; break;
default: default:
FIXME("\n"); FIXME("\n");

View file

@ -198,7 +198,7 @@ reactos/dll/win32/wbemdisp # Synced to Wine-3.0
reactos/dll/win32/wbemprox # Synced to Wine-3.0 reactos/dll/win32/wbemprox # Synced to Wine-3.0
reactos/dll/win32/windowscodecs # Synced to Wine-3.0 reactos/dll/win32/windowscodecs # Synced to Wine-3.0
reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.16 reactos/dll/win32/winemp3.acm # Synced to Wine-3.0
reactos/dll/win32/wing32 # Synced to WineStaging-2.9 reactos/dll/win32/wing32 # Synced to WineStaging-2.9
reactos/dll/win32/winhttp # Synced to WineStaging-2.16 reactos/dll/win32/winhttp # Synced to WineStaging-2.16
reactos/dll/win32/wininet # Synced to WineStaging-2.16 reactos/dll/win32/wininet # Synced to WineStaging-2.16