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).
This commit is contained in:
wm4 2016-02-03 21:29:56 +01:00
parent 35bdb63952
commit 1b6a191ea3
2 changed files with 9 additions and 3 deletions

View File

@ -17,6 +17,7 @@ typedef struct lavc_ctx {
AVCodecContext *avctx;
AVFrame *pic;
struct vd_lavc_hwdec *hwdec;
AVRational codec_timebase;
enum AVPixelFormat pix_fmt;
int best_csp;
enum AVDiscard skip_frame;

View File

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