[Freeswitch-dev] Codes I don't understand
seven du
seven at idapted.com
Mon Apr 6 09:40:37 PDT 2009
Thank you for the quick and detailed explain, It had confused me for a
while. :)
On Apr 7, 2009, at 12:21 AM, Anthony Minessale wrote:
> 1) no the += or = makes no difference to me.
>
> 2) the macro is designed to fight clipping:
> When a sample exceeds the max size of the datatype we set it to
> the max value then cut the volume in half of that sample so it does
> not make too much noise. if we divide everything by 2 then all the
> volume would be reduced even on samples that fell inside the proper
> range.
>
> 3) rlen and wlen are often both > 0. the point is we only manupulate
> the data that is real rlen is how many bytes on the read channel and
> wlen the write, we normalize it so if one of the other is a
> difference size we only change samples that are in the range where
> actual audio occured.
>
>
>
>
> On Mon, Apr 6, 2009 at 10:44 AM, seven du <seven at idapted.com> wrote:
> 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
>
>
> _______________________________________________
> 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/20090407/2f7339ae/attachment-0001.html
More information about the Freeswitch-dev
mailing list