Changeset 5925


Ignore:
Timestamp:
Dec 17, 2018 3:46:35 AM (6 years ago)
Author:
nanang
Message:

Close #2171:

  • Apply returned frame quality filter in OpenH264 decoder (drop the frame if decoder returns dsRefLost dsNoParamSets, dsDepLayerLost).
  • Only publish keyframe missing event when decoder returns non-dsErrorFree (was always publishing the event when no frame is returned, while decoder may return dsErrorFree and no frame returned, e.g: when decoding parameter sets).
  • Added a bit more logs for debugging.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/openh264.cpp

    r5440 r5925  
    964964    unsigned i, frm_cnt; 
    965965    pj_status_t status = PJ_SUCCESS; 
     966    DECODING_STATE ret; 
    966967 
    967968    PJ_ASSERT_RETURN(codec && count && packets && out_size && output, 
     
    10461047        oh264_data->dec->DecodeFrame2( start, frm_size, pData, &sDstBufInfo); 
    10471048 
    1048         if (sDstBufInfo.iBufferStatus == 1) { 
     1049        if (0 && sDstBufInfo.iBufferStatus == 1) { 
     1050            // Better to just get the frame later after all NALs are consumed 
     1051            // by the decoder, it should have the best quality and save some 
     1052            // CPU load. 
    10491053            /* May overwrite existing frame but that's ok. */ 
    10501054            status = oh264_got_decoded_frame(codec, oh264_data, pData, 
     
    10691073    pj_bzero(pData, sizeof(pData)); 
    10701074    pj_bzero(&sDstBufInfo, sizeof (SBufferInfo)); 
    1071     oh264_data->dec->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo); 
    1072  
    1073     if (sDstBufInfo.iBufferStatus == 1) { 
     1075    ret = oh264_data->dec->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo); 
     1076 
     1077    if (sDstBufInfo.iBufferStatus == 1 && 
     1078        !(ret & dsRefLost) && !(ret & dsNoParamSets) && 
     1079        !(ret & dsDepLayerLost)) 
     1080    { 
    10741081        /* Overwrite existing output frame and that's ok, because we assume 
    10751082         * newer frame have better quality because it has more NALs 
     
    10811088    } 
    10821089 
    1083     if (!has_frame) { 
     1090    if (ret != dsErrorFree) { 
    10841091        pjmedia_event event; 
    10851092 
     
    10901097                              PJMEDIA_EVENT_PUBLISH_DEFAULT); 
    10911098 
    1092         PJ_LOG(5,(THIS_FILE, "Decode couldn't produce picture, " 
    1093                   "input nframes=%d, concatenated size=%d bytes", 
    1094                   count, whole_len)); 
    1095  
     1099        if (has_frame) { 
     1100            PJ_LOG(5,(oh264_data->pool->obj_name, 
     1101                      "Decoder returned non error free frame, ret=%d", ret)); 
     1102        } 
     1103    } 
     1104         
     1105    if (!has_frame) { 
    10961106        output->type = PJMEDIA_FRAME_TYPE_NONE; 
    10971107        output->size = 0; 
    10981108        output->timestamp = packets[0].timestamp; 
     1109 
     1110        PJ_LOG(5,(THIS_FILE, "Decode couldn't produce picture, " 
     1111                  "input nframes=%d, concatenated size=%d bytes, ret=%d", 
     1112                  count, whole_len, ret)); 
    10991113    } 
    11001114 
Note: See TracChangeset for help on using the changeset viewer.