[Freeswitch-dev] Codes I don't understand
seven du
seven at idapted.com
Mon Apr 6 08:44:06 PDT 2009
Well, Thank you Anthony. 3 questions In summary,
1) in
> if (x < rlen) {
> z += (int32_t) *(fp + x);
Any difference if change the "+=" to "=" since z is 0? It just
confused me.
2) If n1 = 32768, n2 = 32766, after use MACRO
switch_normalize_to_16bit(n1)
switch_normalize_to_16bit(n2)
the result will be:
n1 = 32767/2 = 16383
n2 = 32766
is that the expected result?
3) Is there any chance rlen and wlen both > 0?
On Apr 6, 2009, at 11:16 PM, Anthony Minessale wrote:
> 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
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org
> iax:guest at conference.freeswitch.org/888
> googletalk:conf+888 at conference.freeswitch.org
> pstn:213-799-1400
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20090406/50c9b665/attachment-0001.html
More information about the Freeswitch-dev
mailing list