summaryrefslogtreecommitdiffstats
path: root/video/decode/vd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-03 21:29:56 +0100
committerwm4 <wm4@nowhere>2016-02-03 21:29:56 +0100
commit1b6a191ea3ba4af3c89db98419b5eae899fedcb9 (patch)
tree9ece13b63a7b82b57d9acec2b0858d58acf30e51 /video/decode/vd_lavc.c
parent35bdb63952b50b634121ee49446294861766e72d (diff)
downloadmpv-1b6a191ea3ba4af3c89db98419b5eae899fedcb9.tar.bz2
mpv-1b6a191ea3ba4af3c89db98419b5eae899fedcb9.tar.xz
vd_lavc: force microsecond timestamps on RPI
Avoids "problems". In particular, it makes MMAL output a NOPTS timestamp if the input timestamp was NOPTS. Don't do it for other decoders. Ideally, we will at some point in the future switch to integer fractions for timestamps at least up until the filter layer. But this would be a larger change, and for now I'd prefer keeping the not-rounded demuxer timestamps (if we have them).
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r--video/decode/vd_lavc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 1e7324457e..64c71afd02 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -375,6 +375,10 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
ctx->hwdec_info = vd->hwdec_info;
+ ctx->codec_timebase = (AVRational){0};
+ if (strstr(decoder, "_mmal"))
+ ctx->codec_timebase = (AVRational){1, 1000000};
+
ctx->pix_fmt = AV_PIX_FMT_NONE;
ctx->hwdec = hwdec;
ctx->hwdec_fmt = 0;
@@ -665,6 +669,7 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
struct vd_lavc_params *opts = ctx->opts->vd_lavc_params;
+ AVRational *tb = ctx->codec_timebase.num ? &ctx->codec_timebase : NULL;
AVPacket pkt;
if (!avctx)
@@ -678,7 +683,7 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
avctx->skip_frame = ctx->skip_frame;
}
- mp_set_av_packet(&pkt, packet, NULL);
+ mp_set_av_packet(&pkt, packet, tb);
ctx->flushing |= !pkt.data;
// Reset decoder if hw state got reset, or new data comes during flushing.
@@ -734,8 +739,8 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
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);
+ mpi->pts = mp_pts_from_av(ctx->pic->pkt_pts, tb);
+ mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, tb);
struct mp_image_params params;
update_image_params(vd, ctx->pic, &params);