- fix the AMR parsing
This commit is contained in:
parent
5ddd7bbeed
commit
028ce8b982
|
|
@ -147,11 +147,6 @@ static AmrPayload parseAmrPayload(AmrPayloadInfo& input)
|
|||
continue;
|
||||
}
|
||||
|
||||
/*std::cout << "New AMR speech frame: frame type = " << int(FT)
|
||||
<< ", mode = " << int(f.mMode)
|
||||
<< ", octet-aligned = " << input.mOctetAligned
|
||||
<< ", timestamp = " << static_cast<int>(f.mTimestamp) << std::endl;*/
|
||||
|
||||
if (input.mWideband && f.mFrameType == 15)
|
||||
{
|
||||
// DTX, no sense to decode the data
|
||||
|
|
@ -164,6 +159,12 @@ static AmrPayload parseAmrPayload(AmrPayloadInfo& input)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!f.mGoodQuality)
|
||||
{
|
||||
// Bad quality, frame is damaged
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t bitsLength = input.mWideband ? amrwb_framelenbits[f.mFrameType] : amrnb_framelenbits[f.mFrameType];
|
||||
size_t byteLength = input.mWideband ? amrwb_framelen[f.mFrameType] : amrnb_framelen[f.mFrameType];
|
||||
|
||||
|
|
@ -630,6 +631,7 @@ int AmrWbCodec::decodePlain(std::span<const uint8_t> input, std::span<uint8_t> o
|
|||
return 0;
|
||||
|
||||
short* dataOut = (short*)output.data();
|
||||
size_t dataOutSizeInBytes = 0;
|
||||
for (AmrFrame& frame: ap.mFrames)
|
||||
{
|
||||
memset(dataOut, 0, static_cast<size_t>(pcmLength()));
|
||||
|
|
@ -638,9 +640,10 @@ int AmrWbCodec::decodePlain(std::span<const uint8_t> input, std::span<uint8_t> o
|
|||
{
|
||||
D_IF_decode(mDecoderCtx, (const unsigned char*)frame.mData->data(), (short*)dataOut, 0);
|
||||
dataOut += pcmLength() / 2;
|
||||
dataOutSizeInBytes += pcmLength();
|
||||
}
|
||||
}
|
||||
return pcmLength() * ap.mFrames.size();
|
||||
return dataOutSizeInBytes;
|
||||
}
|
||||
|
||||
int AmrWbCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
|
|
|
|||
Loading…
Reference in New Issue