libresample
libresample copied to clipboard
opus_uint16
Hi.
I have next flow on my app
encoded opus data -> decode with opus_decode() -> resample 44100 -> send to bluetooth in sbc codec
I want to use libresample but in your code in/out data it *float, but opus_decode give me opus_uint16(uint16_t) and sbc as I known wants uint16 too.
What do you recommend me to do?
I've had similar requirements and wrote an implementation in c++
https://github.com/erdgeist/libresample/blob/master/cpp/resampler.h
if C++ is fine with you, just use it. If not, the main thing to do is to change the API for resample_process to consume short * instead of float * and then change all references to members of the inBuffer and outBuffer arrays adding a cast to float
For example:
https://github.com/erdgeist/libresample/blob/6714bfb530ae4d979227f19b62859a198be4acbf/src/resample.c#L247
hp->X[hp->Xread + i] = (float)inBuffer[(*inBufferUsed) + i];
and
https://github.com/erdgeist/libresample/blob/6714bfb530ae4d979227f19b62859a198be4acbf/src/resample.c#L214
outBuffer[outSampleCount+i] = (short)hp->Y[i];
and here, too:
https://github.com/erdgeist/libresample/blob/6714bfb530ae4d979227f19b62859a198be4acbf/src/resample.c#L322
and you should be fine.
Use opus_decode_float.