Hello!
I have a C++ code here that deals with Opus.
This code is surely NOT correct.
I am looking for somebody who can guess what the correct code should be.
Please only place a bid if you have any idea of what the correct code should be.
I think you also need to read a bit of the Opus documentation.
To make it clear again: My code is most probally VERY VERY WRONG.
I want to feed encoded bytes and have shorts returned.
If you can do this crazy task, you can be sure to get a greating rating as well.
Thank you very much.
int FrameByteCount(int uFrameCount)
{
int iInputChannels=1;
int iBitrate = 16;
int iBytesPerSample = (iBitrate / 8) * iInputChannels;
return uFrameCount * iBytesPerSample;
}
void COpusCodec::Decode(unsigned char* uEncoded, short* uDecoded, unsigned int uLen)
{
int segmentFrames = 960;
int bytesPerSegment = FrameByteCount(segmentFrames);
int byteCap = bytesPerSegment;
//this is not C++ code, and I don't know if it is needed.
int segmentCount = (int)[login to view URL]((decimal)[login to view URL]() / byteCap);
// we can not decode everything in one rush. We need to split it into packets and decode each packet
// but I am not sure if I do it correctly. Most probally not.
for (int i = 0; i < segmentCount; i++)
{
unsigned char segment[1920];
int iCount=0;
for (int j = 0; j < 1920; j++)
{
segment[j] = uEncoded[(i*byteCap) + j];
iCount++;
}
unsigned char decoded[1920];//most probally wrong
int len;
int frame_size=opus_decode(dec, segment, len, decoded, max_size, 0);
//now we have to put this part of the decoded data into the final "decoded" shorts somehow
}
}