Changeset 5728 for pjproject


Ignore:
Timestamp:
Jan 18, 2018 4:02:00 AM (6 years ago)
Author:
ming
Message:

Fixed #2084: Opus decode/recovery issue when FEC or PLC is enabled

File:
1 edited

Legend:

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

    r5659 r5728  
    933933    pjmedia_frame *inframe; 
    934934    int fec = 0; 
     935    int frm_size; 
    935936 
    936937    PJ_UNUSED_ARG(output_buf_len); 
     
    969970        pj_memcpy(inframe->buf, input->buf, input->size); 
    970971        fec = 1; 
    971      } 
    972  
    973      decoded_samples = opus_decode(opus_data->dec, 
     972    } 
     973 
     974    /* From Opus doc: In the case of PLC (data==NULL) or FEC(decode_fec=1), 
     975     * then frame_size needs to be exactly the duration of audio that 
     976     * is missing. 
     977     */ 
     978    if (inframe->type != PJMEDIA_FRAME_TYPE_AUDIO || fec) { 
     979        frm_size = opus_data->cfg.sample_rate * opus_data->ptime / 1000; 
     980    } else { 
     981        frm_size = output->size / (sizeof(opus_int16) * 
     982                   opus_data->cfg.channel_cnt); 
     983    } 
     984    decoded_samples = opus_decode( opus_data->dec, 
    974985                                   inframe->type==PJMEDIA_FRAME_TYPE_AUDIO ? 
    975986                                   inframe->buf : NULL, 
     
    977988                                   inframe->size : 0, 
    978989                                   (opus_int16*)output->buf, 
    979                                    output->size / (sizeof(opus_int16) * 
    980                                    opus_data->cfg.channel_cnt), 
     990                                   frm_size, 
    981991                                   fec); 
    982      output->timestamp = inframe->timestamp; 
     992    output->timestamp = inframe->timestamp; 
    983993      
    984      if (inframe->type == PJMEDIA_FRAME_TYPE_AUDIO) { 
     994    if (inframe->type == PJMEDIA_FRAME_TYPE_AUDIO) { 
    985995        /* Mark current indexed frame as invalid */ 
    986996        inframe->type = PJMEDIA_FRAME_TYPE_NONE; 
     
    10221032    int decoded_samples; 
    10231033    pjmedia_frame *inframe; 
     1034    int frm_size; 
    10241035 
    10251036    PJ_UNUSED_ARG(output_buf_len); 
     
    10401051 
    10411052    inframe = &opus_data->dec_frame[opus_data->dec_frame_index]; 
     1053    if (inframe->type != PJMEDIA_FRAME_TYPE_AUDIO) { 
     1054        frm_size = opus_data->cfg.sample_rate * opus_data->ptime/1000; 
     1055    } else { 
     1056        frm_size = output->size / (sizeof(opus_int16) * 
     1057                   opus_data->cfg.channel_cnt); 
     1058    } 
    10421059    decoded_samples = opus_decode(opus_data->dec, 
    10431060                                  inframe->type==PJMEDIA_FRAME_TYPE_AUDIO ? 
     
    10461063                                  inframe->size : 0, 
    10471064                                  (opus_int16*)output->buf, 
    1048                                   output->size / (sizeof(opus_int16) * 
    1049                                   opus_data->cfg.channel_cnt), 
     1065                                  frm_size, 
    10501066                                  0); 
    10511067 
Note: See TracChangeset for help on using the changeset viewer.