-
Notifications
You must be signed in to change notification settings - Fork 61
Issue/104 bcg729 api #139
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
Issue/104 bcg729 api #139
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -542,15 +542,30 @@ uint16 t_g729a_audio_decoder::get_ptime(uint16 payload_size) const | |
| uint16 t_g729a_audio_decoder::decode(uint8 *payload, uint16 payload_size, | ||
| int16 *pcm_buf, uint16 pcm_buf_size) | ||
| { | ||
| #ifdef HAVE_BCG729_API_1_0_2 | ||
| int frame_size; | ||
| uint8 *encoded_data_ptr = payload; | ||
| int16 *decoded_data_ptr = pcm_buf; | ||
| uint32 new_len = 0; | ||
| for (uint16 done = 0; done < payload_size && new_len < pcm_buf_size; done += frame_size) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second half of this condition will interrupt the loop if we're about to write past the end of The previous version avoided this problem with the use of assertions, to ensure that |
||
| { | ||
| uint8 is_sid = (payload_size - done < 8) ? 1 : 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, why 8? Not that it won't work (any expression returning true on 2 and false on 10+ will do the job), but I was wondering if it had a special significance that I was unaware of. |
||
| frame_size = (is_sid == 1) ? 2 : 10; | ||
| bcg729Decoder(_context, encoded_data_ptr, payload_size, false, is_sid, false, decoded_data_ptr); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already made mention of the use of |
||
| encoded_data_ptr += frame_size; | ||
| decoded_data_ptr += 80; | ||
| new_len += 80; | ||
| } | ||
| return new_len; | ||
| #else | ||
| assert((payload_size % 10) == 0); | ||
| assert(pcm_buf_size >= payload_size*8); | ||
|
|
||
| for (uint16 done = 0; done < payload_size; done += 10) | ||
| { | ||
| bcg729Decoder(_context, &payload[done], false, &pcm_buf[done * 8]); | ||
| } | ||
|
|
||
| return payload_size * 8; | ||
| #endif | ||
| } | ||
|
|
||
| bool t_g729a_audio_decoder::valid_payload_size(uint16 payload_size, uint16 sample_buf_size) const | ||
|
|
@@ -562,7 +577,11 @@ uint16 t_g729a_audio_decoder::conceal(int16 *pcm_buf, uint16 pcm_buf_size) | |
| { | ||
| assert(pcm_buf_size >= 80); | ||
|
|
||
| #ifdef HAVE_BCG729_API_1_0_2 | ||
| bcg729Decoder(_context, nullptr, false, true, false, false, pcm_buf); | ||
| #else | ||
| bcg729Decoder(_context, nullptr, true, pcm_buf); | ||
| #endif | ||
| return 80; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -433,7 +433,11 @@ uint16 t_g726_audio_encoder::encode(int16 *sample_buf, uint16 nsamples, | |
| t_g729a_audio_encoder::t_g729a_audio_encoder(uint16 payload_id, uint16 ptime, t_user *user_config) | ||
| : t_audio_encoder(payload_id, ptime, user_config) | ||
| { | ||
| #ifdef HAVE_BCG729_API_1_0_2 | ||
| _context = initBcg729EncoderChannel(false); | ||
| #else | ||
| _context = initBcg729EncoderChannel(); | ||
| #endif | ||
| } | ||
|
|
||
| t_g729a_audio_encoder::~t_g729a_audio_encoder() | ||
|
|
@@ -448,13 +452,27 @@ uint16 t_g729a_audio_encoder::encode(int16 *sample_buf, uint16 nsamples, | |
| assert (payload_size >= (nsamples/8)); | ||
|
|
||
| silence = false; | ||
|
|
||
| #ifdef HAVE_BCG729_API_1_0_2 | ||
| uint16 new_len = 0; | ||
| int16 *decoded_data_ptr = sample_buf; | ||
| uint8 *encoded_data_ptr = payload; | ||
| uint8 frame_size; | ||
| int loops = (int)nsamples / 80; | ||
| for (uint16 done = 0; done < loops; done ++) | ||
| { | ||
| bcg729Encoder(_context, decoded_data_ptr, encoded_data_ptr, &frame_size); | ||
| encoded_data_ptr += frame_size; | ||
| decoded_data_ptr += frame_size * 8; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a mistake, as |
||
| new_len += frame_size; | ||
| } | ||
| return new_len; | ||
| #else | ||
| for (uint16 done = 0; done < nsamples; done += 80) | ||
| { | ||
| bcg729Encoder(_context, &sample_buf[done], &payload[done / 8]); | ||
| } | ||
|
|
||
| return nsamples / 8; | ||
| #endif | ||
| } | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of
new_len(uint32) does not match the return type of this function (uint16).