Changeset 1846


Ignore:
Timestamp:
Mar 4, 2008 4:23:42 PM (11 years ago)
Author:
bennylp
Message:

Ticket #502: New packet lost concealment (PLC) implementation and enable PLC on G711 and GSM codec

Location:
pjproject/trunk/pjmedia/src
Files:
3 edited

Legend:

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

    r1267 r1846  
    3535#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC != 0 
    3636 
    37 /* We removed PLC in 0.6 */ 
    38 #define PLC_DISABLED    1 
     37/* We removed PLC in 0.6 (and re-enabled it again in 0.9!) */ 
     38#define PLC_DISABLED    0 
    3939 
    4040 
  • pjproject/trunk/pjmedia/src/pjmedia/g711.c

    r1417 r1846  
    3333#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0 
    3434 
    35 /* We removed PLC in 0.6 */ 
    36 #define PLC_DISABLED    1 
     35/* We removed PLC in 0.6 (and re-enabled it again in 0.9!) */ 
     36#define PLC_DISABLED    0 
    3737 
    3838 
  • pjproject/trunk/pjmedia/src/pjmedia/plc_common.c

    r1266 r1846  
    1919#include <pjmedia/plc.h> 
    2020#include <pjmedia/errno.h> 
     21#include <pjmedia/wsola.h> 
    2122#include <pj/assert.h> 
    2223#include <pj/pool.h> 
     
    2425 
    2526 
    26 static void* plc_replay_create(pj_pool_t*, unsigned c, unsigned f); 
    27 static void  plc_replay_save(void*, pj_int16_t*); 
    28 static void  plc_replay_generate(void*, pj_int16_t*); 
    29  
    30 extern void* pjmedia_plc_steveu_create(pj_pool_t*, unsigned c, unsigned f); 
    31 extern void  pjmedia_plc_steveu_save(void*, pj_int16_t*); 
    32 extern void  pjmedia_plc_steveu_generate(void*, pj_int16_t*); 
    33  
     27static void* plc_wsola_create(pj_pool_t*, unsigned c, unsigned f); 
     28static void  plc_wsola_save(void*, pj_int16_t*); 
     29static void  plc_wsola_generate(void*, pj_int16_t*); 
    3430 
    3531/** 
     
    4440 
    4541 
    46 #if defined(PJMEDIA_HAS_STEVEU_PLC) && PJMEDIA_HAS_STEVEU_PLC!=0 
    47 static struct plc_alg plc_steveu = 
     42static struct plc_alg plc_wsola = 
    4843{ 
    49     &pjmedia_plc_steveu_create, 
    50     &pjmedia_plc_steveu_save, 
    51     &pjmedia_plc_steveu_generate 
    52 }; 
    53 #endif 
    54  
    55  
    56 static struct plc_alg plc_replay = 
    57 { 
    58     &plc_replay_create, 
    59     &plc_replay_save, 
    60     &plc_replay_generate 
     44    &plc_wsola_create, 
     45    &plc_wsola_save, 
     46    &plc_wsola_generate 
    6147}; 
    6248 
     
    8975    plc = PJ_POOL_ZALLOC_T(pool, pjmedia_plc); 
    9076 
    91     if (0) 
    92         ; 
    93 #if defined(PJMEDIA_HAS_STEVEU_PLC) && PJMEDIA_HAS_STEVEU_PLC!=0 
    94     else if (clock_rate == 8000) 
    95         plc->op = &plc_steveu; 
    96 #endif 
    97     else 
    98         plc->op = &plc_replay; 
    99  
     77    plc->op = &plc_wsola; 
    10078    plc->obj = plc->op->plc_create(pool, clock_rate, samples_per_frame); 
    10179 
     
    134112////////////////////////////////////////////////////////////////////////////// 
    135113/* 
    136  * Simple replay based plc 
     114 * Packet loss concealment based on WSOLA 
    137115 */ 
    138 struct replay_plc 
     116struct wsola_plc 
    139117{ 
    140     unsigned    size; 
    141     unsigned    replay_cnt; 
    142     pj_int16_t *frame; 
     118    pjmedia_wsola   *wsola; 
     119    pj_bool_t        prev_lost; 
    143120}; 
    144121 
    145122 
    146 static void* plc_replay_create(pj_pool_t *pool, unsigned clock_rate,  
    147                                unsigned samples_per_frame) 
     123static void* plc_wsola_create(pj_pool_t *pool, unsigned clock_rate,  
     124                              unsigned samples_per_frame) 
    148125{ 
    149     struct replay_plc *o; 
     126    struct wsola_plc *o; 
     127    pj_status_t status; 
    150128 
    151129    PJ_UNUSED_ARG(clock_rate); 
    152130 
    153     o = PJ_POOL_ALLOC_T(pool, struct replay_plc); 
    154     o->size = samples_per_frame * 2; 
    155     o->replay_cnt = 0; 
    156     o->frame = (pj_int16_t*) pj_pool_zalloc(pool, o->size); 
     131    o = PJ_POOL_ALLOC_T(pool, struct wsola_plc); 
     132 
     133    status = pjmedia_wsola_create(pool, clock_rate, samples_per_frame, 1, 
     134                                  PJMEDIA_WSOLA_NO_DISCARD, &o->wsola); 
     135    if (status != PJ_SUCCESS) 
     136        return NULL; 
    157137 
    158138    return o; 
    159139} 
    160140 
    161 static void plc_replay_save(void *plc, pj_int16_t *frame) 
     141static void plc_wsola_save(void *plc, pj_int16_t *frame) 
    162142{ 
    163     struct replay_plc *o = (struct replay_plc*) plc; 
     143    struct wsola_plc *o = (struct wsola_plc*) plc; 
    164144 
    165     pj_memcpy(o->frame, frame, o->size); 
    166     o->replay_cnt = 0; 
     145    pjmedia_wsola_save(o->wsola, frame, o->prev_lost); 
     146    o->prev_lost = PJ_FALSE; 
    167147} 
    168148 
    169 static void plc_replay_generate(void *plc, pj_int16_t *frame) 
     149static void plc_wsola_generate(void *plc, pj_int16_t *frame) 
    170150{ 
    171     struct replay_plc *o = (struct replay_plc*) plc; 
    172     unsigned i, count; 
    173     pj_int16_t *samp; 
    174  
    175     ++o->replay_cnt; 
    176  
    177     if (o->replay_cnt < 16) { 
    178         pj_memcpy(frame, o->frame, o->size); 
     151    struct wsola_plc *o = (struct wsola_plc*) plc; 
    179152     
    180  
    181         count = o->size / 2; 
    182         samp = o->frame; 
    183         for (i=0; i<count; ++i) 
    184             samp[i] = (pj_int16_t)(samp[i] >> 1); 
    185     } else { 
    186         pj_bzero(frame, o->size); 
    187     } 
     153    pjmedia_wsola_generate(o->wsola, frame); 
     154    o->prev_lost = PJ_TRUE; 
    188155} 
    189156 
    190157 
    191  
Note: See TracChangeset for help on using the changeset viewer.