Commit 01fa4fb6 authored by Paul B Mahol's avatar Paul B Mahol

avcodec/h264_parser: set missing pts for top/bottom field frames

Adopted from 4eb49fdd revert.
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 93e04102
......@@ -60,6 +60,7 @@ typedef struct H264ParseContext {
uint8_t parse_history[6];
int parse_history_count;
int parse_last_mb;
int64_t reference_dts;
} H264ParseContext;
......@@ -598,6 +599,26 @@ static int h264_parse(AVCodecParserContext *s,
s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
}
if (s->dts_sync_point >= 0) {
int64_t den = avctx->time_base.den * avctx->pkt_timebase.num;
if (den > 0) {
int64_t num = avctx->time_base.num * avctx->pkt_timebase.den;
if (s->dts != AV_NOPTS_VALUE) {
// got DTS from the stream, update reference timestamp
p->reference_dts = s->dts - av_rescale(s->dts_ref_dts_delta, num, den);
} else if (p->reference_dts != AV_NOPTS_VALUE) {
// compute DTS based on reference timestamp
s->dts = p->reference_dts + av_rescale(s->dts_ref_dts_delta, num, den);
}
if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE)
s->pts = s->dts + av_rescale(s->pts_dts_delta, num, den);
if (s->dts_sync_point > 0)
p->reference_dts = s->dts; // new reference
}
}
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
......@@ -655,6 +676,7 @@ static av_cold int init(AVCodecParserContext *s)
{
H264ParseContext *p = s->priv_data;
p->reference_dts = AV_NOPTS_VALUE;
ff_h264dsp_init(&p->h264dsp, 8, 1);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment