-
Notifications
You must be signed in to change notification settings - Fork 189
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
Enable aptX (HD) decoding support using standalone codec extracted from ffmpeg. #253
Conversation
https://github.com/pali/libopenaptx also derives the aptx code from the FFmpeg project. Why another library? Furthermore, the aptx decoder samples contain 24 bit signed integers stored as 32 bit signed integers. Your code right-shifts the 24 bit samples into 16 bit samples, am I right? |
Using Raspbian Stretch (9.11) and default apt repositories I found this issue compiling
So I had to upgrade it manually. This took more than an hour on a Pi 3. After this, I configured it with I'll check if could be something about my setup. Edit.: Apparently I'm missing |
@joerg-krause I didn't notice that library before, but whatever :) @dmcallejo I'll change the minimum CMake version required. Edit: it's not caused by RTP header. Anyway, please test aptX behaviour. |
After my previous observation (#241 (comment)) I found that a lot of parity check error happens at the time of the crackling noise and much much more error follows it. It stucks in the error. To reproduce it just put the following code in the
The first parity error happens after 3-5 minutes of audio playing. Isn't there an automatic error correction feature in the data link layer of bluetooth? If the answer is yes then how can I turn it on? |
@t123yh Downscaling 24-bit to 16-bit means you're losing quality. @gpeter12 This probably means that you're not receiving all packets, so the aptx synchronization fails. You can add some synchronization handling, e.g. like pali did in his aptx decoder. |
Hi @t123yh , I've been testing extensively the build and I can confirm that there's no bug with the volume control. I've used it for long sessions (4 hours of continuous play) and no problems at all. |
Hi @t123yh, Thank you for your help. |
@gpeter12 The internal of bluez-alsa uses 16bit samples. We will have to change all There's one thing I'm not very sure of: why this could not get merged. Maybe I should rebase it to the latest master? |
Firstly, sorry for not responding earlier :/. The reason why this PR has not been merged is mainly due to maintenance problem. This project for the last two years has been used commercially with the requirement of apt-X support. Unfortunately, ffmpeg can not be used in such way due to legal issues. In order to "allow" community to use apt-X encoding, there is a shim library openaptx, which implements commercial apt-X API (API is not a patent subject) - one needs to adopt open-source encoder to such API and you are ready to go (breaking the law, though). The problem with decoding is, that the API has not been publicly available and the only one I'm aware of is released under NDA. So first of all switching to ffmpeg for encoding is not an option because it will make hard to maintain commercial forks. Secondly, I could mainstream decoding support but first of all I have to be sure that the API has been publicly released by Qualcomm so I'm not breaking NDA (more or less). For apt-X HD there is also mentioned 24-bit issue. Some work has been already done by @joerg-krause, you might check his fork. However, I think that for dynamic bit-with support there is still a long way to go - mostly due to required architectural changes. |
Does that mean it's best to close this PR and maintain a "illegal" fork myself? |
I think that this PR might still be there, so if someone is looking for apt-X (HD), your fork could be easily found. Also, it will be a right place to notify subscribers about any progress with this feature :) |
@arkq I searched for the commit but i didn't find it. :( |
Hello! My https://github.com/pali/libopenaptx has some fixes related to both encoding and decoding process, specially related to algorithm delay. Also in decoder I implemented simple rescue and re-synchronization. So funcionality in my libopenaptx should be better then in proprietary qualcom implementation. Also affected patents for this code already expired, so there should not be any legal problems with either using or redistributing libopenaptx code. If you found some problems in libopenaptx, please report issue to my repository. |
@gpeter12 wrote:
I asked this question year ago on linux-bluetooth ML, see thread:
Nope, it should be turned off! Reliable sockets (like TCP) are unsuitable for real-time audio/video transports. If it is turned on then you would hear of of glitches, big and variable latency and have audio unsynchronized. In real-time streaming it is up to the codec to do error correction, not for transport layer. Transport layer should be low latency and should not try to retransmit packets on error. @joerg-krause wrote:
Now I released a new version of libopenaptx 0.2.0 which contains new functions in libopenaptx.so library for synchronization support, so caller just needs to call new function and do not need to do anything with parity check or syncing. Also code for synchronization handling in libopenaptx is improved. I did simulation, took aptx stream, removed some bytes from random places and play it. And there is no crackling noise anymore. So libopenaptx 0.2.0 implementation should be more suitable for bluetooth streaming (both encoder and decoder deals with algorithm delay and decoder supports synchronization) compared to ffmpeg implementation or proprietary qualcomm android implementation. If you think that there is something missing in libopenaptx or have suggestions for improvement, please let me know. |
Has someone already tried libopenaptx 0.2.0 with bluez-alsa or is working on that? |
@pali The crackling noise problem was because of my hardware choice. It turned out that the Raspberry Pi Zero W has a very low quality built in Bluetooth module. I bought a new USB Bluetooth stick and the problem was completely eliminated. Now the sound is perfect. I can’t hear any distortion or noise even after hours of usage. Currently I’m using @t123yh ’s code on the RPi, but I will try libopenaptx 0.2.0 code too because @t123yh ’s code has about 1.5 second latency. Sorry for the late reply. |
It's nice to see all of these:) Closing this for #356. |
This is powered by a simple library ffaptx that I extracted from ffmpeg source code. I tested both aptX and aptX HD from my OnePlus 6, and it seems to be working fine.
I believe encoding support with this library can be added with little effort (and thus eliminate the need for openaptx library), but as I don't have a aptX receiver I can't test it. Hope somebody can implement it.