# [Freeswitch-dev] Codes I don't understand

seven du seven at idapted.com
Mon Apr 6 07:35:13 PDT 2009

```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.

```