Ignore:
Timestamp:
Feb 14, 2013 2:00:13 AM (12 years ago)
Author:
ming
Message:

Re #1608: Fixed array size calculation of amr bitrates array.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/opencore_amr.c

    r4335 r4348  
    143143    &amr_alloc_codec, 
    144144    &amr_dealloc_codec, 
    145     &pjmedia_codec_opencore_amrnb_deinit 
     145    &pjmedia_codec_opencore_amr_deinit 
    146146}; 
    147147 
     
    195195    {pjmedia_codec_amrnb_bitrates, pjmedia_codec_amrwb_bitrates}; 
    196196 
     197static const unsigned amr_bitrates_size[2] = 
     198{ 
     199    PJ_ARRAY_SIZE(pjmedia_codec_amrnb_bitrates), 
     200    PJ_ARRAY_SIZE(pjmedia_codec_amrwb_bitrates) 
     201}; 
     202 
    197203 
    198204/* 
     
    327333 
    328334    /* Normalize bitrate. */ 
    329     nbitrates = PJ_ARRAY_SIZE(amr_bitrates[idx]); 
     335    nbitrates = amr_bitrates_size[idx]; 
    330336    if (def_config[idx].bitrate < amr_bitrates[idx][0]) { 
    331337        def_config[idx].bitrate = amr_bitrates[idx][0]; 
     
    410416    attr->info.channel_cnt = 1; 
    411417    attr->info.avg_bps = def_config[idx].bitrate; 
    412     attr->info.max_bps = amr_bitrates[idx][PJ_ARRAY_SIZE(amr_bitrates[idx])-1]; 
     418    attr->info.max_bps = amr_bitrates[idx][amr_bitrates_size[idx]-1]; 
    413419    attr->info.pcm_bits_per_sample = 16; 
    414420    attr->info.frm_ptime = 20; 
     
    563569    idx = (attr->info.clock_rate <= 8000? IDX_AMR_NB: IDX_AMR_WB); 
    564570    enc_mode = pjmedia_codec_amr_get_mode(attr->info.avg_bps); 
    565     pj_assert(enc_mode >= 0 && 
    566               enc_mode < PJ_ARRAY_SIZE(amr_bitrates[idx])); 
     571    pj_assert(enc_mode >= 0 && enc_mode < amr_bitrates_size[idx]); 
    567572 
    568573    /* Check octet-align */ 
     
    598603            l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 
    599604            while (l--) { 
    600                 if (*p>='0' && 
    601                     *p<=('0'+PJ_ARRAY_SIZE(amr_bitrates[idx])-1)) 
    602                 { 
     605                if (*p>='0' && *p<=('0'+amr_bitrates_size[idx]-1)) { 
    603606                    pj_int8_t tmp = *p - '0' - enc_mode; 
    604607 
     
    776779 
    777780    /* Check for Change Mode Request. */ 
    778     if (cmr < PJ_ARRAY_SIZE(amr_bitrates[idx]) && amr_data->enc_mode != cmr) { 
     781    if (cmr < amr_bitrates_size[idx] && amr_data->enc_mode != cmr) { 
    779782        amr_data->enc_mode = cmr; 
    780783        TRACE_((THIS_FILE, "AMR encoder switched mode to %d (%dbps)", 
Note: See TracChangeset for help on using the changeset viewer.