From 271cabe6a5bd8342b56ab855d033abba63dfead6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Jan 2016 20:47:13 +0100 Subject: video: cleanup pts/dts passing between decoder components Instead of using semi-public codec_pts/codec_dts fields in struct dec_video, pass them via mp_image fields. --- video/decode/dec_video.c | 6 ++++-- video/decode/dec_video.h | 4 ++-- video/decode/vd_lavc.c | 17 ++++++++++------- video/mp_image.h | 2 ++ 4 files changed, 18 insertions(+), 11 deletions(-) (limited to 'video') diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index f28871c6bb..1d2806f17a 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -310,18 +310,20 @@ static struct mp_image *decode_packet(struct dec_video *d_video, } // Note: the PTS is reordered, but the DTS is not. Both should be monotonic. - double pts = d_video->codec_pts; - double dts = d_video->codec_dts; + double pts = mpi->pts; + double dts = mpi->dts; if (pts == MP_NOPTS_VALUE) { d_video->codec_pts = prev_codec_pts; } else if (pts < prev_codec_pts) { + d_video->codec_pts = mpi->pts; d_video->num_codec_pts_problems++; } if (dts == MP_NOPTS_VALUE) { d_video->codec_dts = prev_codec_dts; } else if (dts <= prev_codec_dts) { + d_video->codec_dts = mpi->dts; d_video->num_codec_dts_problems++; } diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h index 012f42c510..9e9f2d54c2 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -45,6 +45,8 @@ struct dec_video { void *priv; // for free use by vd_driver + // Strictly internal (dec_video.c). + // Last PTS from decoder (set with each vd_driver->decode() call) double codec_pts; int num_codec_pts_problems; @@ -57,8 +59,6 @@ struct dec_video { double buffered_pts[128]; int num_buffered_pts; - // Strictly internal (dec_video.c). - // PTS or DTS of packet first read double first_packet_pdts; diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 9677e4c079..f480d185b6 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -676,11 +676,6 @@ static void decode(struct dec_video *vd, struct demux_packet *packet, ctx->hwdec_fail_count = 0; - struct mp_image_params params; - update_image_params(vd, ctx->pic, ¶ms); - vd->codec_pts = mp_pts_from_av(ctx->pic->pkt_pts, NULL); - vd->codec_dts = mp_pts_from_av(ctx->pic->pkt_dts, NULL); - AVFrameSideData *sd = NULL; sd = av_frame_get_side_data(ctx->pic, AV_FRAME_DATA_A53_CC); if (sd) { @@ -692,12 +687,20 @@ static void decode(struct dec_video *vd, struct demux_packet *packet, } struct mp_image *mpi = mp_image_from_av_frame(ctx->pic); - av_frame_unref(ctx->pic); - if (!mpi) + if (!mpi) { + av_frame_unref(ctx->pic); return; + } assert(mpi->planes[0] || mpi->planes[3]); + mpi->pts = mp_pts_from_av(ctx->pic->pkt_pts, NULL); + mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, NULL); + + struct mp_image_params params; + update_image_params(vd, ctx->pic, ¶ms); mp_image_set_params(mpi, ¶ms); + av_frame_unref(ctx->pic); + if (ctx->hwdec && ctx->hwdec->process_image) mpi = ctx->hwdec->process_image(ctx, mpi); diff --git a/video/mp_image.h b/video/mp_image.h index c2841490f4..af602721f3 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -86,6 +86,8 @@ typedef struct mp_image { /* only inside filter chain */ double pts; + /* only after decoder */ + double dts; /* for private use */ void* priv; -- cgit v1.2.3