diff options
author | wm4 <wm4@nowhere> | 2013-12-04 20:12:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-04 23:12:51 +0100 |
commit | 8a84da8102cb9c436627a61cd3b674a8ad3e9708 (patch) | |
tree | 9329d8af1d4239b50a5605788286ef43f5ef3871 /video | |
parent | e2dfdc0c7ed5542b0211bb405ad3564bb72e3dee (diff) | |
download | mpv-8a84da8102cb9c436627a61cd3b674a8ad3e9708.tar.bz2 mpv-8a84da8102cb9c436627a61cd3b674a8ad3e9708.tar.xz |
av_common: add timebase parameter to mp_set_av_packet()
If the timebase is set, it's used for converting the packet timestamps.
Otherwise, the previous method of reinterpret-casting the mpv style
double timestamps to libavcodec style int64_t timestamps is used.
Also replace the kind of awkward mp_get_av_frame_pkt_ts() function by
mp_pts_from_av(), which simply converts timestamps in a way the old
function did. (Plus it takes a timebase parameter, similar to the
addition to mp_set_av_packet().)
Note that this should not change anything yet. The code in ad_lavc.c and
vd_lavc.c passes NULL for the timebase parameters. We could set
AVCodecContext.pkt_timebase and use that if we want to give libavcodec
"proper" timestamps.
This could be important for ad_lavc.c: some codecs (opus, probably mp3
and aac too) have weird requirements about doing decoding preroll on the
container level, and thus require adjusting the audio start timestamps
in some cases. libavcodec doesn't tell us how much was skipped, so we
either get shifted timestamps (by the length of the skipped data), or we
give it proper timestamps. (Note: libavcodec interprets or changes
timestamps only if pkt_timebase is set, which by default it is not.)
This would require selecting a timebase though, so I feel uncomfortable
with the idea. At least this change paves the way, and will allow some
testing.
Diffstat (limited to 'video')
-rw-r--r-- | video/decode/vd_lavc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 868f148d8b..fadd76de0e 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -744,7 +744,7 @@ static int decode(struct dec_video *vd, struct demux_packet *packet, else avctx->skip_frame = ctx->skip_frame; - mp_set_av_packet(&pkt, packet); + mp_set_av_packet(&pkt, packet, NULL); ret = avcodec_decode_video2(avctx, ctx->pic, &got_picture, &pkt); if (ret < 0) { @@ -757,7 +757,8 @@ static int decode(struct dec_video *vd, struct demux_packet *packet, return 0; update_image_params(vd, ctx->pic); - mp_get_av_frame_pkt_ts(ctx->pic, &vd->codec_pts, &vd->codec_dts); + vd->codec_pts = mp_pts_from_av(ctx->pic->pkt_pts, NULL); + vd->codec_dts = mp_pts_from_av(ctx->pic->pkt_dts, NULL); // Note: potentially resets ctx->pic as it is transferred to mpi struct mp_image *mpi = image_from_decoder(vd); |