关于ACM音频压缩的问题,200分 ,在线等(100分)

  • 主题发起人 主题发起人 wuchunhua
  • 开始时间 开始时间
W

wuchunhua

Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我写的acm音频压缩的代码 程序执行到注名的地方就退出 没有执行音频格式转换
//---------------------------------------------------
// adm音频压缩
//---------------------------------------------------
function TForm1.AudioConvert2(pIn: pbyte;
lInChannes: integer;
lInBitsPerSample: integer;
lInSamplesperSecond: integer;
lInBufferSize: integer;
pOut: pbyte;
lOutChannes: integer;
lOutBitsPerSample: integer;
lOutSamplesperSecond: integer;
var lOutBufferSize: integer): boolean ;
var
mmr: MMRESULT ;
acmStreamHandler: pHACMSTREAM ;
maxSize: DWORD ;
pInFormat, pOutFormat: pWAVEFORMATEX;
acmheader: pACMSTREAMHEADER ;
suggestedDestSize: DWORD ;
begin

result := false;
mmr := MMSYSERR_NOERROR ;
//acmStreamHandler := new(pHACMSTREAM) ;
acmStreamHandler := nil ;

maxSize := 0 ;
mmr := acmMetrics(0, ACM_METRIC_MAX_SIZE_FORMAT, maxSize);
if mmr <> MMSYSERR_NOERROR then

exit;

GetMem(pInFormat, maxSize);
GetMem(pOutFormat, maxSize);

pInFormat^.wFormatTag := WAVE_FORMAT_PCM;
pInFormat^.nChannels := lInChannes;
pInFormat^.nSamplesPerSec := lInSamplesperSecond;
pInFormat^.wBitsPerSample := lInBitsPerSample;
pInFormat^.nBlockAlign := pInFormat^.nChannels*pInFormat^.wBitsPerSample div 8;
pInFormat^.nAvgBytesPerSec := pInFormat^.nSamplesPerSec * pInFormat^.nBlockAlign;
pInFormat^.cbSize := 0;

pOutFormat^.wFormatTag := WAVE_FORMAT_PCM;
pOutFormat^.nChannels := lOutChannes;
pOutFormat^.nSamplesPerSec := lOutSamplesperSecond;
pOutFormat^.wBitsPerSample := lOutBitsPerSample;
pOutFormat^.nBlockAlign := pOutFormat^.nChannels*pOutFormat^.wBitsPerSample div 8;
pOutFormat^.nAvgBytesPerSec := pOutFormat^.nSamplesPerSec * pOutFormat^.nBlockAlign;
pOutFormat^.cbSize := 0;

mmr := acmStreamOpen(acmStreamHandler, 0, pInFormat^, pOutFormat^, 0, 0, 0, 0);
freeMem(pInFormat);
freeMem(pOutFormat);
//=====程序执行到下面退出========================================
if mmr <> MMSYSERR_NOERROR then

exit;

GetMem(acmheader,sizeof(pACMSTREAMHEADER));
suggestedDestSize := 0;
lOutBufferSize:=acmStreamSize(acmStreamHandler^, lInBufferSize, suggestedDestSize, ACM_STREAMSIZEF_SOURCE);
if suggestedDestSize > lOutBufferSize then

exit;

// Build ACM header on buffer
acmheader.cbStruct := sizeof(pACMSTREAMHEADER);
acmheader.cbSrcLength := lInBufferSize;
acmheader.pbSrc := pIn;
acmheader.cbDstLength := lOutBufferSize;
acmheader.pbDst := pOut;

// Prepare the buffer for ACM
mmr := acmStreamPrepareHeader(acmStreamHandler^, acmheader^, 0);
if mmr = MMSYSERR_NOERROR then

begin

mmr := acmStreamConvert(acmStreamHandler^, acmheader^, ACM_STREAMCONVERTF_BLOCKALIGN);
if mmr = MMSYSERR_NOERROR then

lOutBufferSize := acmheader.cbDstLengthUsed;
// Unprepare ACM header
acmStreamUnprepareHeader(acmStreamHandler^, acmheader^, 0);
end;


if acmStreamHandler <> nil then

acmStreamClose(acmStreamHandler^, 0);
acmStreamHandler := nil ;
result:= mmr = MMSYSERR_NOERROR;
end;
 
你用directshow来实现吧,挺简单的。
 
请问楼上的 你有没有例子 可以提供一个否?
 
为什么不用G729
 
多人接受答案了。
 
后退
顶部