Changeset 2572


Ignore:
Timestamp:
Apr 6, 2009 11:45:25 AM (15 years ago)
Author:
nanang
Message:

Ticket #774: Fixed G722.1 codec to aware about endianness in packing/unpacking RTP payload (the underlying implementation, ITU impl ref, works with 16-bits coded data).

File:
1 edited

Legend:

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

    r2565 r2572  
    764764                                      codec_data->samples_per_frame); 
    765765 
    766     /* Encode the mlt coefs */ 
     766    /* Encode the mlt coefs. Note that encoder output stream is 16 bit array, 
     767     * so we need to take care about endianness. 
     768     */ 
    767769    encoder(codec_data->frame_size_bits, 
    768770            codec_data->number_of_regions, 
     
    771773            output->buf); 
    772774 
     775#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
     776    { 
     777        pj_uint16_t *p, *p_end; 
     778 
     779        p = (pj_uint16_t*)output->buf; 
     780        p_end = p + codec_data->frame_size/2; 
     781        while (p < p_end) { 
     782            *p = pj_htons(*p); 
     783            ++p; 
     784        } 
     785    } 
     786#endif 
     787 
    773788    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    774789    output->size = codec_data->frame_size; 
     
    801816        PJ_ASSERT_RETURN((pj_uint16_t)input->size == codec_data->frame_size, 
    802817                         PJMEDIA_CODEC_EFRMINLEN); 
     818 
     819        /* Decoder requires input of 16-bits array, so we need to take care 
     820         * about endianness. 
     821         */ 
     822#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
     823        { 
     824            pj_uint16_t *p, *p_end; 
     825 
     826            p = (pj_uint16_t*)input->buf; 
     827            p_end = p + codec_data->frame_size/2; 
     828            while (p < p_end) { 
     829                *p = pj_ntohs(*p); 
     830                ++p; 
     831            } 
     832        } 
     833#endif 
     834 
    803835        bitobj.code_word_ptr = (Word16*)input->buf; 
    804836        bitobj.current_word =  *bitobj.code_word_ptr; 
Note: See TracChangeset for help on using the changeset viewer.