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.
This commit is contained in:
wm4 2016-01-25 20:47:13 +01:00
parent 7f300b4204
commit 271cabe6a5
4 changed files with 18 additions and 11 deletions

View File

@ -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++;
}

View File

@ -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;

View File

@ -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, &params);
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, &params);
mp_image_set_params(mpi, &params);
av_frame_unref(ctx->pic);
if (ctx->hwdec && ctx->hwdec->process_image)
mpi = ctx->hwdec->process_image(ctx, mpi);

View File

@ -86,6 +86,8 @@ typedef struct mp_image {
/* only inside filter chain */
double pts;
/* only after decoder */
double dts;
/* for private use */
void* priv;