Ignore:
Timestamp:
Apr 18, 2009 2:29:28 PM (15 years ago)
Author:
bennylp
Message:

More ticket #774: optimization for siren7/siren14 codecs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/g7221.c

    r2603 r2616  
    223223} 
    224224 
     225#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
     226PJ_INLINE(void) swap_bytes(pj_uint16_t *buf, unsigned count) 
     227{ 
     228    pj_uint16_t *end = buf + count; 
     229    while (buf != end) { 
     230        *buf = (pj_uint16_t)((*buf << 8) | (*buf >> 8)); 
     231        ++buf; 
     232    } 
     233} 
     234#else 
     235#define swap_bytes(buf, count) 
     236#endif 
     237 
    225238/* 
    226239 * Initialize and register G722.1 codec factory to pjmedia endpoint. 
     
    775788            output->buf); 
    776789 
    777 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
    778     { 
    779         pj_uint16_t *p, *p_end; 
    780  
    781         p = (pj_uint16_t*)output->buf; 
    782         p_end = p + codec_data->frame_size/2; 
    783         while (p < p_end) { 
    784             *p = pj_htons(*p); 
    785             ++p; 
    786         } 
    787     } 
    788 #endif 
     790    /* Encoder output are in native host byte order, while ITU says 
     791     * it must be in network byte order (MSB first). 
     792     */ 
     793    swap_bytes((pj_uint16_t*)output->buf, codec_data->frame_size/2); 
    789794 
    790795    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
     
    819824                         PJMEDIA_CODEC_EFRMINLEN); 
    820825 
    821         /* Decoder requires input of 16-bits array, so we need to take care 
    822          * about endianness. 
     826        /* Decoder requires input of 16-bits array in native host byte 
     827         * order, while the frame received from the network are in 
     828         * network byte order (MSB first). 
    823829         */ 
    824 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
    825         { 
    826             pj_uint16_t *p, *p_end; 
    827  
    828             p = (pj_uint16_t*)input->buf; 
    829             p_end = p + codec_data->frame_size/2; 
    830             while (p < p_end) { 
    831                 *p = pj_ntohs(*p); 
    832                 ++p; 
    833             } 
    834         } 
    835 #endif 
     830        swap_bytes((pj_uint16_t*)input->buf, codec_data->frame_size/2); 
    836831 
    837832        bitobj.code_word_ptr = (Word16*)input->buf; 
Note: See TracChangeset for help on using the changeset viewer.