[mod_amrwb] Fix scan-build 14
This commit is contained in:
parent
d5ad504723
commit
84ab90895a
|
@ -95,23 +95,23 @@ extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n)
|
|||
|
||||
extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
|
||||
{
|
||||
int framesz, index, ft;
|
||||
int framesz, index;
|
||||
uint8_t shift_tocs[2] = {0x00, 0x00};
|
||||
uint8_t *shift_buf;
|
||||
|
||||
memcpy(shift_tocs, encoded_buf, 2);
|
||||
/* shift for BE */
|
||||
switch_amr_array_lshift(4, shift_tocs, 2);
|
||||
ft = shift_tocs[0] >> 3;
|
||||
ft &= ~(1 << 5); /* Frame Type*/
|
||||
shift_buf = encoded_buf + 1; /* skip CMR */
|
||||
/* shift for BE */
|
||||
switch_amr_array_lshift(2, shift_buf, encoded_len - 1);
|
||||
/* get frame size */
|
||||
index = ((shift_tocs[0] >> 3) & 0x0f);
|
||||
if (index > 10 && index != 0xe && index != 0xf) {
|
||||
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
framesz = switch_amrwb_frame_sizes[index];
|
||||
tmp[0] = shift_tocs[0]; /* save TOC */
|
||||
memcpy(&tmp[1], shift_buf, framesz);
|
||||
|
|
|
@ -191,6 +191,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
|
|||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#else
|
||||
struct amrwb_context *context = NULL;
|
||||
|
@ -204,6 +205,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
|
|||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct amrwb_context))))) {
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
|
||||
|
@ -296,6 +298,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
|
|||
|
||||
/* re-create mode-set */
|
||||
fmtptmp_pos = switch_snprintf(fmtptmp, sizeof(fmtptmp), "mode-set=");
|
||||
|
||||
for (i = 0; SWITCH_AMRWB_MODES-1 > i; ++i) {
|
||||
if (context->enc_modes & (1 << i)) {
|
||||
fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, fmtptmp_pos > strlen("mode-set=") ? ",%d" : "%d", i);
|
||||
|
@ -312,12 +315,13 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
|
|||
}
|
||||
|
||||
if (!globals.volte) {
|
||||
fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d",
|
||||
switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d",
|
||||
switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
|
||||
} else {
|
||||
fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d;max-red=0;mode-change-capability=2",
|
||||
switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d;max-red=0;mode-change-capability=2",
|
||||
switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
|
||||
}
|
||||
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
|
||||
|
||||
context->encoder_state = NULL;
|
||||
|
|
Loading…
Reference in New Issue