From 8a84da8102cb9c436627a61cd3b674a8ad3e9708 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Dec 2013 20:12:14 +0100 Subject: 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. --- sub/sd_lavc_conv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sub/sd_lavc_conv.c') diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c index 6f72671650..24ea2c10c6 100644 --- a/sub/sd_lavc_conv.c +++ b/sub/sd_lavc_conv.c @@ -234,15 +234,12 @@ static void decode(struct sd *sd, struct demux_packet *packet) { struct sd_lavc_priv *priv = sd->priv; AVCodecContext *avctx = priv->avctx; - double ts = av_q2d(av_inv_q(avctx->time_base)); AVSubtitle sub = {0}; AVPacket pkt; AVPacket parsed_pkt = {0}; int ret, got_sub; - mp_set_av_packet(&pkt, packet); - pkt.pts = packet->pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : packet->pts * ts; - pkt.duration = packet->duration * ts; + mp_set_av_packet(&pkt, packet, &avctx->time_base); if (sd->codec && strcmp(sd->codec, "webvtt-webm") == 0) { if (parse_webvtt(&pkt, &parsed_pkt) < 0) { -- cgit v1.2.3