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

(Almost) Add support for G.729 Annex B #153

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fbriere
Copy link
Collaborator

@fbriere fbriere commented Jul 7, 2019

As bcg729 now supports G.729 Annex B (since 1.0.2), it should be possible (once #104 has been merged) for Twinkle to do the same, at least in theory.

This PR lays most of the groundwork necessary to handle SID frames and DTX properly. (VAD is obviously none of our concern, and CNG is done automatically through the same process as frame erasure concealment.)

To quote the state of affairs from the last commit:

  • Everything should be ready on the decoder side: SID frames (notwithstanding RFC 3389) will be decoded as expected, and untransmitted frames will be treated as erased frames, where conceal() will end up generating the comfort noise (this is all done transparently by bcg729).
  • On the encoder side, as indicated by the code comments, two issues remain: one regarding SID frames (if they do not happen to be at the end of the payload), and one with an empty payload of only untransmitted frames (if it ends up being transmitted nonetheless as a NAT keepalive).

I think I could tackle the second issue by myself, but the first one is beyond my abilities. (Can we afford to mercilessly drop the other samples after a SID frame?)

Some additional points:

  • Despite what it may look like, I actually have no experience or expertise in any of this stuff. (I'm merely a fast learner, that's all.) Therefore, it's quite possible that I got a few (or many) things wrong. Please let me know of any mistake I may have made.

  • It goes without saying that none of this has ever been tested, aside from confirming that "yup, it does compile just fine". 😄 Although the Annex B aspect isn't functional yet, it would be nice to confirm that I did not wreck the common G.729 code by mistake. If someone could check and make sure, this would be most welcome!

  • The first two commits are merely a copy of Add support for the new bcg729 API, introduced in version 1.0.2 #152, on which this PR depends.

  • The other commits prior to the last one may appear needlessly trivial; their role is merely to lessen the size and complexity of the last commit. I tried to make the job of whoever is going to review this PR as easy and painless as I could manage.


(Filing this as a draft PR, until #104 is merged.)

@fbriere fbriere changed the title (Almost) add support for G.729 Annex B (Almost) Add support for G.729 Annex B Jul 8, 2019
@fbriere fbriere mentioned this pull request Jul 8, 2019
@fbriere fbriere added untested This pull resquest has not (completely) been tested and removed help wanted labels Jul 15, 2019
@fbriere
Copy link
Collaborator Author

fbriere commented Sep 8, 2019

As I stated in #104, I've now had a chance to actually test G.729, and this code seems to work fine, in that it does not have any impact when using plain G.729A. (Any confirmation would always be welcome, of course.)

Once G.729B support is added, the number of audio samples decoded on
output will no longer be linearly correlated to the number of bytes fed
on input (or vice-versa for encoding).  We will therefore need to tally
up that number in a variable, which will act as a return value, as well
as an index for the destination buffer.
Once G.729B support is added, the size of a frame will no longer be
fixed to 10 bytes.  Let's get a head start by moving those hard-coded
values into a variable.

(Note that the assertion can be removed, since we no longer rely on it.)
Once G.729B support is added, these expressions are about to get a bit
more complicated, to account for the different size of SID frames.  By
switching to a 80:10 ratio right away, we can get a head start and
reduce the complexity of the last patch.  (Not to mention that this
makes things a bit more explicit as a bonus.)

For the record, there is a reason behind performing the division before
the multiplication, which will become apparent in the final patch.  Note
that the quotient is guaranteed to be integral, due to the assertions.
Once G.729B support is added, the value of the encoder's `silence`
variable will only be known after the encoding has been completed.  As
per the previous commits, we move it ahead of time to simplify the final
patch.
Although we don't yet emit or receive SID frames, this will make it
possible to deal with them when the time comes.

At this point, everything should be ready on the decoder side; SID
frames (those within a G.729 stream, not those sent via RFC 3389) will
be decoded as expected, and untransmitted frames will be treated as
erased frames, where `conceal()` will end up generating the comfort
noise.

On the encoder side, as indicated by the comments, two issues remain:
one regarding SID frames (if they do not happen to be at the end of the
payload), and one with an empty payload of only untransmitted frames (if
it ends up being transmitted nonetheless as a NAT keepalive).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codec enhancement untested This pull resquest has not (completely) been tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant