pkt->pts = st->cur_dts; pkt->dts = st->cur_dts;
if (pkt->dts == AV_NOPTS_VALUE) { pkt->pts = st->cur_dts; pkt->dts = st->cur_dts; } else { st->cur_dts = pkt->dts; pkt->pts = pkt->dts; }
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,                                AVCodecParserContext *pc, AVPacket *pkt){    int num, den, presentation_delayed;    if (pkt->duration == 0) {        compute_frame_duration(&num, &den, s, st, pc, pkt);        if (den && num) {            pkt->duration = (num * (int64_t)AV_TIME_BASE) / den;        }    }    /* do we have a video B frame ? */    presentation_delayed = 0;    if (st->codec.codec_type == CODEC_TYPE_VIDEO) {        /* XXX: need has_b_frame, but cannot get it if the codec is           not initialized */        if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||             st->codec.codec_id == CODEC_ID_MPEG2VIDEO ||             st->codec.codec_id == CODEC_ID_MPEG4 ||             st->codec.codec_id == CODEC_ID_H264) &&             pc && pc->pict_type != FF_B_TYPE)            presentation_delayed = 1;    }    /* interpolate PTS and DTS if they are not present */    if (presentation_delayed) {        /* DTS = decompression time stamp */        /* PTS = presentation time stamp */        if (pkt->dts == AV_NOPTS_VALUE) {            pkt->dts = st->cur_dts;        } else {            st->cur_dts = pkt->dts;        }        /* this is tricky: the dts must be incremented by the duration           of the frame we are displaying, i.e. the last I or P frame */        if (st->last_IP_duration == 0)            st->cur_dts += pkt->duration;        else            st->cur_dts += st->last_IP_duration;        st->last_IP_duration  = pkt->duration;        /* cannot compute PTS if not present (we can compute it only           by knowing the futur */    } else {        /* presentation is not delayed : PTS and DTS are the same */        if (pkt->pts == AV_NOPTS_VALUE) {            pkt->pts = st->cur_dts;            pkt->dts = st->cur_dts;        } else {            st->cur_dts = pkt->pts;            pkt->dts = pkt->pts;        }        st->cur_dts += pkt->duration;    }        /* update flags */    if (pc) {        pkt->flags = 0;        /* key frame computation */        switch(st->codec.codec_type) {        case CODEC_TYPE_VIDEO:            if (pc->pict_type == FF_I_TYPE)                pkt->flags |= PKT_FLAG_KEY;            break;        case CODEC_TYPE_AUDIO:            pkt->flags |= PKT_FLAG_KEY;            break;        default:            break;        }    }}