[Freeswitch-dev] Codes I don't understand

Anthony Minessale anthony.minessale at gmail.com
Mon Apr 6 08:16:33 PDT 2009


what ?

I don't know what your question is.



On Mon, Apr 6, 2009 at 9:35 AM, seven du <seven at idapted.com> wrote:

> Hi, can someone explain this  to me?
>
> In switch_core_media_bug.c, around line 173:
>
>
>
>                for (x = 0; x < blen; x++) {
>                        int32_t z = 0;
>
>                        if (x < rlen) {
>                                z += (int32_t) *(fp + x);     //what's
> difference here with z =
> (int32_t) *(fp + x) ?
>                        }
>                        if (x < wlen) {
>                                z += (int32_t) *(dp + x);
>                        }
>                        switch_normalize_to_16bit(z);
>                        *(fp + x) = (int16_t) z / 2;
>                }
>
> And for switch_normalize_to_16bit, according to switch_utils.h,
>
> #define SWITCH_SMAX 32767
> #define SWITCH_SMIN -32768
> #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n =
> SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
>
> Then
> switch_normalize_to_16bit( 32768 ), z = 32767/2, and (int16_t) z / 2 =
> 32767/4
> switch_normalize_to_16bit( 32766) , z = 32766, and (int16_t) z / 2 =
> 32766/2
>
> Does that make sense? I guess it should be like this:
>
> #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n =
> SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2; else n
> = n / 2;
>
>                        switch_normalize_to_16bit(z);
>                        *(fp + x) = (int16_t) z;
>
>
> Thank you.
>
> _______________________________________________
> Freeswitch-dev mailing list
> Freeswitch-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>



-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
pstn:213-799-1400
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20090406/cdc8bb85/attachment.html 


More information about the Freeswitch-dev mailing list