Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opus_uint16 #3

Open
vinnitu opened this issue Mar 31, 2021 · 2 comments
Open

opus_uint16 #3

vinnitu opened this issue Mar 31, 2021 · 2 comments

Comments

@vinnitu
Copy link

vinnitu commented Mar 31, 2021

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?

@erdgeist
Copy link

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.

@Zipdox2
Copy link

Zipdox2 commented Jun 6, 2023

Use opus_decode_float.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants