Ignore:
Timestamp:
Apr 6, 2009 1:52:01 PM (15 years ago)
Author:
nanang
Message:

Ticket #778: Fixed IPP G722.1 codec to aware about endianness in packing/decoding G722.1 RTP payload.

File:
1 edited

Legend:

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

    r2516 r2573  
    201201                              pj_size_t *pkt_size, pj_size_t max_pkt_size); 
    202202 
     203static    void predecode_g7221( ipp_private_t *codec_data, 
     204                                const pjmedia_frame *rtp_frame, 
     205                                USC_Bitstream *usc_frame); 
     206static  pj_status_t pack_g7221( ipp_private_t *codec_data, void *pkt,  
     207                                pj_size_t *pkt_size, pj_size_t max_pkt_size); 
    203208 
    204209/* IPP codec implementation descriptions. */ 
     
    294299    {0, "G7221",    PJMEDIA_RTP_PT_G722_1_16, &USC_G722_Fxns,   16000, 1, 320,  
    295300                    16000, 16000, 1, 0, 1, 
    296                     NULL, NULL, NULL, 
     301                    predecode_g7221, NULL, pack_g7221, 
    297302                    {1, {{{"bitrate", 7}, {"16000", 5}}} } 
    298303    }, 
    299304    {1, "G7221",    PJMEDIA_RTP_PT_G722_1_24, &USC_G722_Fxns,   16000, 1, 320,  
    300305                    24000, 24000, 1, 0, 1, 
    301                     NULL, NULL, NULL, 
     306                    predecode_g7221, NULL, pack_g7221, 
    302307                    {1, {{{"bitrate", 7}, {"24000", 5}}} } 
    303308    }, 
    304309    {1, "G7221",    PJMEDIA_RTP_PT_G722_1_32, &USC_G722_Fxns,   16000, 1, 320,  
    305310                    32000, 32000, 1, 0, 1, 
    306                     NULL, NULL, NULL, 
     311                    predecode_g7221, NULL, pack_g7221, 
    307312                    {1, {{{"bitrate", 7}, {"32000", 5}}} } 
    308313    }, 
     
    564569#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_AMR */ 
    565570 
     571 
     572#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 
     573 
     574static void predecode_g7221( ipp_private_t *codec_data, 
     575                             const pjmedia_frame *rtp_frame, 
     576                             USC_Bitstream *usc_frame) 
     577{ 
     578    usc_frame->pBuffer = (char*)rtp_frame->buf; 
     579    usc_frame->nbytes = rtp_frame->size; 
     580    usc_frame->frametype = 0; 
     581    usc_frame->bitrate = codec_data->info->params.modes.bitrate; 
     582 
     583#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
     584    { 
     585        pj_uint16_t *p, *p_end; 
     586 
     587        p = (pj_uint16_t*)rtp_frame->buf; 
     588        p_end = p + rtp_frame->size/2; 
     589        while (p < p_end) { 
     590            *p = pj_ntohs(*p); 
     591            ++p; 
     592        } 
     593    } 
     594#endif 
     595} 
     596 
     597static pj_status_t pack_g7221( ipp_private_t *codec_data, void *pkt,  
     598                               pj_size_t *pkt_size, pj_size_t max_pkt_size) 
     599{ 
     600    PJ_UNUSED_ARG(codec_data); 
     601    PJ_UNUSED_ARG(max_pkt_size); 
     602 
     603#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 
     604    { 
     605        pj_uint16_t *p, *p_end; 
     606 
     607        p = (pj_uint16_t*)pkt; 
     608        p_end = p + *pkt_size/2; 
     609        while (p < p_end) { 
     610            *p = pj_htons(*p); 
     611            ++p; 
     612        } 
     613    } 
     614#else 
     615    PJ_UNUSED_ARG(pkt); 
     616    PJ_UNUSED_ARG(pkt_size); 
     617#endif 
     618 
     619    return PJ_SUCCESS; 
     620} 
     621 
     622#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 */ 
    566623 
    567624/* 
Note: See TracChangeset for help on using the changeset viewer.