AMR-WB, error getting size of bitrates array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Antonio,

Thanks for the report. I just fixed this in r4348.

Regards,
Ming

On Wed, Feb 13, 2013 at 6:13 PM, Antonio Mart?nez <tonio.mg at gmail.com> wrote:
> Hello,
>
> I found this problem working with opencore_amr.c using AMR-WB:
>
> The array containing the bitrates of both AMR (NB and WB) is declared like
> this in opencore_amr.c (line 194):
>
> static const pj_uint16_t* amr_bitrates[2] = {pjmedia_codec_amrnb_bitrates,
> pjmedia_codec_amrwb_bitrates};
>
> And both arrays are declared in amr_helper.h (line 587):
>
> /**
>
>  * Constant of AMR-WB frame lengths in bits.
>
>  */
>
> const pj_uint16_t pjmedia_codec_amrwb_framelenbits[10] =
>
>     {132, 177, 253, 285, 317, 365, 397, 461, 477, 40};
>
> /**
>
>  * Constant of AMR-WB bitrates.
>
>  */
>
> const pj_uint16_t pjmedia_codec_amrwb_bitrates[9] =
>
>     {6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850};
>
>
> Accesing the arrays during runtime works:
>
> amr_bitrates[0][3] -> Works
>
>
> The problem comes when trying to get the size of the individual arrays (in
> several places in opencore_amr.c):
>
> PJ_ARRAY_SIZE(amr_bitrates[idx]) -> Same as
> sizeof(amr_bitrates[idx])/sizeof(amr_bitrates[idx][0])
>
> The array size is 2, because it stores pointers, so it crashes in several
> places in the code where the array size is expected to be 8 or 9, depending
> on WB or NB.
>
> My solution would be declaring the sizes of the array in a const, and using
> it, something like:
>
> const pj_uint16_t sizeWBArray = 9;
>
> What do you think?
>
> Regards,
>
> Antonio MG.
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux