Ignore:
Timestamp:
Aug 1, 2006 11:09:35 PM (17 years ago)
Author:
bennylp
Message:

Added simple WinCE application:

  • added pjsua_wince in pjsip-apps, which is a simple SIP UA application just to broadly test pjsip/pjmedia on WinCE.
  • Fix name conflicts in xpidf.c (e.g. ATOM variable conflicts with ATOM type in WinCE SDK).
  • Fix speex compilation errors on Wince (e.g. inline keyword is not recognized, replaced with PJ_INLINE).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/resample.c

    r513 r641  
    9999#endif 
    100100 
    101 typedef char           BOOL; 
    102 typedef short          HWORD; 
    103 typedef unsigned short UHWORD; 
    104 typedef int            WORD; 
    105 typedef unsigned int   UWORD; 
     101typedef char           RES_BOOL; 
     102typedef short          RES_HWORD; 
     103typedef int            RES_WORD; 
     104typedef unsigned short RES_UHWORD; 
     105typedef unsigned int   RES_UWORD; 
    106106 
    107107#define MAX_HWORD (32767) 
     
    222222 
    223223 
    224 static INLINE HWORD WordToHword(WORD v, int scl) 
    225 { 
    226     HWORD out; 
    227     WORD llsb = (1<<(scl-1)); 
     224static INLINE RES_HWORD WordToHword(RES_WORD v, int scl) 
     225{ 
     226    RES_HWORD out; 
     227    RES_WORD llsb = (1<<(scl-1)); 
    228228    v += llsb;          /* round */ 
    229229    v >>= scl; 
     
    233233        v = MIN_HWORD; 
    234234    }    
    235     out = (HWORD) v; 
     235    out = (RES_HWORD) v; 
    236236    return out; 
    237237} 
     
    240240 */ 
    241241static int  
    242   SrcLinear(const HWORD X[], HWORD Y[], double pFactor, UHWORD nx) 
    243 { 
    244     HWORD iconst; 
    245     UWORD time = 0; 
    246     const HWORD *xp; 
    247     HWORD *Ystart, *Yend; 
    248     WORD v,x1,x2; 
     242  SrcLinear(const RES_HWORD X[], RES_HWORD Y[], double pFactor, RES_UHWORD nx) 
     243{ 
     244    RES_HWORD iconst; 
     245    RES_UWORD time = 0; 
     246    const RES_HWORD *xp; 
     247    RES_HWORD *Ystart, *Yend; 
     248    RES_WORD v,x1,x2; 
    249249     
    250250    double dt;                  /* Step through input signal */  
    251     UWORD dtb;                  /* Fixed-point version of Dt */ 
    252     UWORD endTime;              /* When time reaches EndTime, return to user */ 
     251    RES_UWORD dtb;                  /* Fixed-point version of Dt */ 
     252    RES_UWORD endTime;              /* When time reaches EndTime, return to user */ 
    253253     
    254254    dt = 1.0/pFactor;            /* Output sampling period */ 
     
    257257    Ystart = Y; 
    258258    Yend = Ystart + (unsigned)(nx * pFactor); 
    259     endTime = time + (1<<Np)*(WORD)nx; 
     259    endTime = time + (1<<Np)*(RES_WORD)nx; 
    260260    while (time < endTime) 
    261261    { 
     
    273273} 
    274274 
    275 static WORD FilterUp(const HWORD Imp[], const HWORD ImpD[],  
    276                      UHWORD Nwing, BOOL Interp, 
    277                      const HWORD *Xp, HWORD Ph, HWORD Inc) 
    278 { 
    279     const HWORD *Hp; 
    280     const HWORD *Hdp = NULL; 
    281     const HWORD *End; 
    282     HWORD a = 0; 
    283     WORD v, t; 
     275static RES_WORD FilterUp(const RES_HWORD Imp[], const RES_HWORD ImpD[],  
     276                     RES_UHWORD Nwing, RES_BOOL Interp, 
     277                     const RES_HWORD *Xp, RES_HWORD Ph, RES_HWORD Inc) 
     278{ 
     279    const RES_HWORD *Hp; 
     280    const RES_HWORD *Hdp = NULL; 
     281    const RES_HWORD *End; 
     282    RES_HWORD a = 0; 
     283    RES_WORD v, t; 
    284284     
    285285    v=0; 
     
    302302      while (Hp < End) { 
    303303          t = *Hp;              /* Get filter coeff */ 
    304           t += (((WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ 
     304          t += (((RES_WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ 
    305305          Hdp += Npc;           /* Filter coeff differences step */ 
    306306          t *= *Xp;             /* Mult coeff by input sample */ 
     
    328328 
    329329 
    330 static WORD FilterUD(const HWORD Imp[], const HWORD ImpD[], 
    331                      UHWORD Nwing, BOOL Interp, 
    332                      const HWORD *Xp, HWORD Ph, HWORD Inc, UHWORD dhb) 
    333 { 
    334     HWORD a; 
    335     const HWORD *Hp, *Hdp, *End; 
    336     WORD v, t; 
    337     UWORD Ho; 
     330static RES_WORD FilterUD(const RES_HWORD Imp[], const RES_HWORD ImpD[], 
     331                     RES_UHWORD Nwing, RES_BOOL Interp, 
     332                     const RES_HWORD *Xp, RES_HWORD Ph, RES_HWORD Inc, RES_UHWORD dhb) 
     333{ 
     334    RES_HWORD a; 
     335    const RES_HWORD *Hp, *Hdp, *End; 
     336    RES_WORD v, t; 
     337    RES_UWORD Ho; 
    338338     
    339339    v=0; 
    340     Ho = (Ph*(UWORD)dhb)>>Np; 
     340    Ho = (Ph*(RES_UWORD)dhb)>>Np; 
    341341    End = &Imp[Nwing]; 
    342342    if (Inc == 1)               /* If doing right wing...              */ 
     
    352352          Hdp = &ImpD[Ho>>Na];  /* get interp (lower Na) bits from diff table*/ 
    353353          a = Ho & Amask;       /* a is logically between 0 and 1 */ 
    354           t += (((WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ 
     354          t += (((RES_WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ 
    355355          t *= *Xp;             /* Mult coeff by input sample */ 
    356356          if (t & 1<<(Nhxn-1))  /* Round, if needed */ 
     
    378378 * Slightly faster than down-conversion; 
    379379 */ 
    380 static int SrcUp(const HWORD X[], HWORD Y[], double pFactor,  
    381                  UHWORD nx, UHWORD pNwing, UHWORD pLpScl, 
    382                  const HWORD pImp[], const HWORD pImpD[], BOOL Interp) 
    383 { 
    384     const HWORD *xp; 
    385     HWORD *Ystart, *Yend; 
    386     WORD v; 
     380static int SrcUp(const RES_HWORD X[], RES_HWORD Y[], double pFactor,  
     381                 RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl, 
     382                 const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp) 
     383{ 
     384    const RES_HWORD *xp; 
     385    RES_HWORD *Ystart, *Yend; 
     386    RES_WORD v; 
    387387     
    388388    double dt;                  /* Step through input signal */  
    389     UWORD dtb;                  /* Fixed-point version of Dt */ 
    390     UWORD time = 0; 
    391     UWORD endTime;              /* When time reaches EndTime, return to user */ 
     389    RES_UWORD dtb;                  /* Fixed-point version of Dt */ 
     390    RES_UWORD time = 0; 
     391    RES_UWORD endTime;              /* When time reaches EndTime, return to user */ 
    392392     
    393393    dt = 1.0/pFactor;            /* Output sampling period */ 
     
    396396    Ystart = Y; 
    397397    Yend = Ystart + (unsigned)(nx * pFactor); 
    398     endTime = time + (1<<Np)*(WORD)nx; 
     398    endTime = time + (1<<Np)*(RES_WORD)nx; 
    399399    while (time < endTime) 
    400400    { 
     
    402402        /* Perform left-wing inner product */ 
    403403        v = 0; 
    404         v = FilterUp(pImp, pImpD, pNwing, Interp, xp, (HWORD)(time&Pmask),-1); 
     404        v = FilterUp(pImp, pImpD, pNwing, Interp, xp, (RES_HWORD)(time&Pmask),-1); 
    405405 
    406406        /* Perform right-wing inner product */ 
    407         v += FilterUp(pImp, pImpD, pNwing, Interp, xp+1,  (HWORD)((-time)&Pmask),1); 
     407        v += FilterUp(pImp, pImpD, pNwing, Interp, xp+1,  (RES_HWORD)((-time)&Pmask),1); 
    408408 
    409409        v >>= Nhg;              /* Make guard bits */ 
     
    418418/* Sampling rate conversion subroutine */ 
    419419 
    420 static int SrcUD(const HWORD X[], HWORD Y[], double pFactor,  
    421                  UHWORD nx, UHWORD pNwing, UHWORD pLpScl, 
    422                  const HWORD pImp[], const HWORD pImpD[], BOOL Interp) 
    423 { 
    424     const HWORD *xp; 
    425     HWORD *Ystart, *Yend; 
    426     WORD v; 
     420static int SrcUD(const RES_HWORD X[], RES_HWORD Y[], double pFactor,  
     421                 RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl, 
     422                 const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp) 
     423{ 
     424    const RES_HWORD *xp; 
     425    RES_HWORD *Ystart, *Yend; 
     426    RES_WORD v; 
    427427     
    428428    double dh;                  /* Step through filter impulse response */ 
    429429    double dt;                  /* Step through input signal */ 
    430     UWORD time = 0; 
    431     UWORD endTime;              /* When time reaches EndTime, return to user */ 
    432     UWORD dhb, dtb;             /* Fixed-point versions of Dh,Dt */ 
     430    RES_UWORD time = 0; 
     431    RES_UWORD endTime;          /* When time reaches EndTime, return to user */ 
     432    RES_UWORD dhb, dtb;         /* Fixed-point versions of Dh,Dt */ 
    433433     
    434434    dt = 1.0/pFactor;            /* Output sampling period */ 
     
    440440    Ystart = Y; 
    441441    Yend = Ystart + (unsigned)(nx * pFactor); 
    442     endTime = time + (1<<Np)*(WORD)nx; 
     442    endTime = time + (1<<Np)*(RES_WORD)nx; 
    443443    while (time < endTime) 
    444444    { 
    445445        xp = &X[time>>Np];      /* Ptr to current input sample */ 
    446         v = FilterUD(pImp, pImpD, pNwing, Interp, xp, (HWORD)(time&Pmask), 
     446        v = FilterUD(pImp, pImpD, pNwing, Interp, xp, (RES_HWORD)(time&Pmask), 
    447447                     -1, dhb);  /* Perform left-wing inner product */ 
    448         v += FilterUD(pImp, pImpD, pNwing, Interp, xp+1, (HWORD)((-time)&Pmask), 
     448        v += FilterUD(pImp, pImpD, pNwing, Interp, xp+1, (RES_HWORD)((-time)&Pmask), 
    449449                      1, dhb);  /* Perform right-wing inner product */ 
    450450        v >>= Nhg;              /* Make guard bits */ 
Note: See TracChangeset for help on using the changeset viewer.