From 948f3c19a8bd069768ca411212aaf8c1ed96b10d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 26 Sep 2015 18:13:55 +0200 Subject: lavc: Make AVPacket.duration int64, and deprecate convergence_duration Note that convergence_duration had another meaning, one which was in practice never used. The only real use for it was a 64 bit replacement for the duration field. It's better just to make duration 64 bits, and to get rid of it. Signed-off-by: Vittorio Giovara --- libavformat/framecrcenc.c | 2 +- libavformat/matroskadec.c | 8 ++++++-- libavformat/matroskaenc.c | 10 ++++++++-- libavformat/md5enc.c | 2 +- libavformat/mov.c | 2 +- libavformat/r3d.c | 4 ++-- libavformat/utils.c | 8 ++++++-- 7 files changed, 25 insertions(+), 11 deletions(-) (limited to 'libavformat') diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c index 4d5483a..470442e 100644 --- a/libavformat/framecrcenc.c +++ b/libavformat/framecrcenc.c @@ -30,7 +30,7 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); char buf[256]; - snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32"\n", + snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08"PRIx32"\n", pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc); avio_write(s->pb, buf, strlen(buf)); return 0; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 3556b14..caf127f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2335,10 +2335,14 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, else pkt->pts = timecode; pkt->pos = pos; + if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE || st->codec->codec_id == AV_CODEC_ID_TEXT) + pkt->duration = duration; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (st->codec->codec_id == AV_CODEC_ID_TEXT) pkt->convergence_duration = duration; - else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) - pkt->duration = duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (st->codec->codec_id == AV_CODEC_ID_SSA) matroska_fix_ass_packet(matroska, pkt, duration); diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 498f479..db86e88 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1394,7 +1394,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " - "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n", + "pts %" PRId64 ", dts %" PRId64 ", duration %" PRId64 ", flags %d\n", avio_tell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags); if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 && (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1)) @@ -1527,7 +1527,13 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size)); - duration = pkt->convergence_duration; + duration = pkt->duration; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS + if (pkt->convergence_duration) + duration = pkt->convergence_duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif mkv_write_block(s, pb, MATROSKA_ID_BLOCK, pkt, 0); put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration); end_ebml_master(pb, blockgroup); diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c index 9249704..bd10df7 100644 --- a/libavformat/md5enc.c +++ b/libavformat/md5enc.c @@ -104,7 +104,7 @@ static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) av_md5_init(c->md5); av_md5_update(c->md5, pkt->data, pkt->size); - snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ", + snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, ", pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size); md5_finish(s, buf); return 0; diff --git a/libavformat/mov.c b/libavformat/mov.c index bb99f75..95dc1ee 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3535,7 +3535,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) goto retry; pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; - av_log(s, AV_LOG_TRACE, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", + av_log(s, AV_LOG_TRACE, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %"PRId64"\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); return 0; } diff --git a/libavformat/r3d.c b/libavformat/r3d.c index a99f265..c56bdc6 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -264,7 +264,7 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom) if (st->avg_frame_rate.num) pkt->duration = (uint64_t)st->time_base.den* st->avg_frame_rate.den/st->avg_frame_rate.num; - av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration); + av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64"\n", pkt->dts, pkt->duration); return 0; } @@ -313,7 +313,7 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) pkt->stream_index = 1; pkt->dts = dts; pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); - av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n", + av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64" samples %d sample rate %d\n", pkt->dts, pkt->duration, samples, st->codec->sample_rate); return 0; diff --git a/libavformat/utils.c b/libavformat/utils.c index 5d4ec62..f8926bd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -735,8 +735,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* update flags */ if (is_intra_only(st->codec->codec_id)) pkt->flags |= AV_PKT_FLAG_KEY; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (pc) pkt->convergence_duration = pc->convergence_duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end) @@ -906,7 +910,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", " - "size=%d, duration=%d, flags=%d\n", + "size=%d, duration=%"PRId64", flags=%d\n", cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, cur_pkt.size, cur_pkt.duration, cur_pkt.flags); @@ -955,7 +959,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", " - "size=%d, duration=%d, flags=%d\n", + "size=%d, duration=%"PRId64", flags=%d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration, pkt->flags); -- cgit v1.1