Comments (2)
Hi @Lighty0410 :)
I'm surprised by that API. PCM data is not bytes, it's (signed) int16 or float32. I don't know this lib, but I did some digging, and it casts the char * pcm buffer to a INT_PCM *
type array here: https://github.com/winlinvip/go-fdkaac/blob/2654f5a0cc2e3e9584a0c7f5ccae9d64f3bf957d/fdkaac/dec.go#L127
If you look at the backing C library, it defines INT_PCM
as a SHORT
here: https://github.com/mstorsjo/fdk-aac/blob/f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990/libSYS/include/machine_type.h#L226 , which is a "Data type representing 2 byte signed integer on all supported".
Basically, this is a raw pointer cast without checking the byte order. I don't think this is safe, and even if it were, it's unnecessary, because they could just accept an int16[] instead of a byte[] to begin with and do away with the cast.
Honestly you're probably best off forking this lib, fixing the API and removing that cast. You can always submit a PR, see if they want it.
While you're at it, I would advise removing the allocation of the pcm buffer in the wrapper lib. You want the user of the lib to pass their buffer to your decoder (like the underlying C library does, and io.Reader, and this lib). This allows you to allocate once and reuse that buffer over and over again. See https://github.com/winlinvip/go-fdkaac/blob/2654f5a0cc2e3e9584a0c7f5ccae9d64f3bf957d/fdkaac/dec.go#L361 .
Good luck!
from opus.
Closing this ticket.
from opus.
Related Issues (20)
- transfer pcm to opus HOT 2
- run error HOT 2
- Forward error correction flag in decode (decode_fec flag) HOT 9
- How to find sample rate of a stream? HOT 2
- How can I play opus codec audio by using portaudio? HOT 1
- Opus 1.3 release,would we update to new version? HOT 1
- There is a difference between an opus stream (which is an ogg/opus stream) and raw opus data. .opus files are really .ogg files with opus data, which this package doesn't provide a way to write. It does have a reader for it (Stream type), but no writer yet (never bothered to because I haven't needed it so far, but feel free to submit a PR). HOT 2
- transfer pcm to raw opus HOT 7
- "checkptr: unsafe pointer arithmetic" when using go race detector HOT 1
- How to complie in cross platform? HOT 5
- Inconsistent types in README HOT 1
- encoder: invalid argument HOT 1
- Amplify ogg stream? HOT 2
- How to destroy en(de)coder state? HOT 2
- Get audio from microphone and encode to ogg HOT 1
- Strange distortion when decoding HOT 6
- implicit declaration of function 'OPUS_GET_IN_DTX' HOT 8
- wasm env HOT 2
- Question: is it possible to build against libopus v1.5.(2) to be able to use the new features #108 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus.