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
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
G.729B: Explicitly use 80:10 ratio in expressions, instead of 8:1
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.
  • Loading branch information
fbriere committed Feb 13, 2022
commit bc7c4dd703a8cf8964c85f4dca49d35832295851
4 changes: 2 additions & 2 deletions src/audio/audio_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,14 @@ t_g729a_audio_decoder::~t_g729a_audio_decoder()

uint16 t_g729a_audio_decoder::get_ptime(uint16 payload_size) const
{
return (payload_size * 8) / (audio_sample_rate(_codec) / 1000);
return ((payload_size / 10) * 80) / (audio_sample_rate(_codec) / 1000);
}

uint16 t_g729a_audio_decoder::decode(uint8 *payload, uint16 payload_size,
int16 *pcm_buf, uint16 pcm_buf_size)
{
assert((payload_size % 10) == 0);
assert(pcm_buf_size >= payload_size*8);
assert(pcm_buf_size >= ((payload_size / 10) * 80));

uint8 frame_size = 10;
uint16 result_size = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/audio_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ uint16 t_g729a_audio_encoder::encode(int16 *sample_buf, uint16 nsamples,
uint8 *payload, uint16 payload_size, bool &silence)
{
assert ((nsamples % 80) == 0);
assert (payload_size >= (nsamples/8));
assert (payload_size >= ((nsamples / 80) * 10));

silence = false;

Expand Down