diff options
-rw-r--r-- | doc/APIchanges | 3 | ||||
-rw-r--r-- | libavcodec/audio_frame_queue.c | 2 | ||||
-rw-r--r-- | libavcodec/audio_frame_queue.h | 2 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 42 | ||||
-rw-r--r-- | libavcodec/avpacket.c | 12 | ||||
-rw-r--r-- | libavcodec/parser.c | 5 | ||||
-rw-r--r-- | libavcodec/version.h | 3 | ||||
-rw-r--r-- | libavformat/framecrcenc.c | 2 | ||||
-rw-r--r-- | libavformat/jacosubdec.c | 2 | ||||
-rw-r--r-- | libavformat/matroskadec.c | 26 | ||||
-rw-r--r-- | libavformat/matroskaenc.c | 9 | ||||
-rw-r--r-- | libavformat/md5enc.c | 2 | ||||
-rw-r--r-- | libavformat/movenc.c | 2 | ||||
-rw-r--r-- | libavformat/mux.c | 2 | ||||
-rw-r--r-- | libavformat/r3d.c | 4 | ||||
-rw-r--r-- | libavformat/srtenc.c | 4 | ||||
-rw-r--r-- | libavformat/utils.c | 12 |
17 files changed, 68 insertions, 66 deletions
diff --git a/doc/APIchanges b/doc/APIchanges index 5e69745ba3..03ffda8c37 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2015-09-29 - xxxxxxx - lavc 57.3.100 / lavc 57.2.0 - avcodec.h + Change type of AVPacket.duration from int to int64_t. + 2015-09-17 - xxxxxxx - lavc 57.3.100 / lavc 57.2.0 - d3d11va.h Add av_d3d11va_alloc_context(). This function must from now on be used for allocating AVD3D11VAContext. diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c index 4f6bccce36..f2ccd69281 100644 --- a/libavcodec/audio_frame_queue.c +++ b/libavcodec/audio_frame_queue.c @@ -73,7 +73,7 @@ int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f) } void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, - int *duration) + int64_t *duration) { int64_t out_pts = AV_NOPTS_VALUE; int removed_samples = 0; diff --git a/libavcodec/audio_frame_queue.h b/libavcodec/audio_frame_queue.h index 2e317bbf41..d8076eae54 100644 --- a/libavcodec/audio_frame_queue.h +++ b/libavcodec/audio_frame_queue.h @@ -78,6 +78,6 @@ int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f); * @param[out] duration output packet duration */ void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, - int *duration); + int64_t *duration); #endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */ diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 872a9a5ee4..138627d8d4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1411,28 +1411,19 @@ typedef struct AVPacket { * Duration of this packet in AVStream->time_base units, 0 if unknown. * Equals next_pts - this_pts in presentation order. */ - int duration; + int64_t duration; int64_t pos; ///< byte position in stream, -1 if unknown +#if FF_API_CONVERGENCE_DURATION /** - * Time difference in AVStream->time_base units from the pts of this - * packet to the point at which the output from the decoder has converged - * independent from the availability of previous frames. That is, the - * frames are virtually identical no matter if decoding started from - * the very first frame or from this keyframe. - * Is AV_NOPTS_VALUE if unknown. - * This field is not the display duration of the current packet. - * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY - * set. - * - * The purpose of this field is to allow seeking in streams that have no - * keyframes in the conventional sense. It corresponds to the - * recovery point SEI in H.264 and match_time_delta in NUT. It is also - * essential for some types of subtitle streams to ensure that all - * subtitles are correctly displayed after seeking. + * @deprecated Same as the duration field, but as int64_t. This was required + * for Matroska subtitles, whose duration values could overflow when the + * duration field was still an int. */ + attribute_deprecated int64_t convergence_duration; +#endif } AVPacket; #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted @@ -4325,24 +4316,13 @@ typedef struct AVCodecParserContext { */ int key_frame; +#if FF_API_CONVERGENCE_DURATION /** - * Time difference in stream time base units from the pts of this - * packet to the point at which the output from the decoder has converged - * independent from the availability of previous frames. That is, the - * frames are virtually identical no matter if decoding started from - * the very first frame or from this keyframe. - * Is AV_NOPTS_VALUE if unknown. - * This field is not the display duration of the current frame. - * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY - * set. - * - * The purpose of this field is to allow seeking in streams that have no - * keyframes in the conventional sense. It corresponds to the - * recovery point SEI in H.264 and match_time_delta in NUT. It is also - * essential for some types of subtitle streams to ensure that all - * subtitles are correctly displayed after seeking. + * @deprecated unused */ + attribute_deprecated int64_t convergence_duration; +#endif // Timestamp generation support: /** diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 32fa51f24f..0496254cf4 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -36,7 +36,11 @@ void av_init_packet(AVPacket *pkt) pkt->dts = AV_NOPTS_VALUE; pkt->pos = -1; pkt->duration = 0; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS pkt->convergence_duration = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->flags = 0; pkt->stream_index = 0; pkt->buf = NULL; @@ -468,7 +472,11 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) dst->dts = src->dts; dst->pos = src->pos; dst->duration = src->duration; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS dst->convergence_duration = src->convergence_duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif dst->flags = src->flags; dst->stream_index = src->stream_index; @@ -540,8 +548,12 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb); if (pkt->duration > 0) pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb); +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (pkt->convergence_duration > 0) pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb); +FF_ENABLE_DEPRECATION_WARNINGS +#endif } int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) diff --git a/libavcodec/parser.c b/libavcodec/parser.c index f5bfa249d9..2809158c35 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -25,6 +25,7 @@ #include "libavutil/avassert.h" #include "libavutil/atomic.h" +#include "libavutil/internal.h" #include "libavutil/mem.h" #include "internal.h" @@ -82,7 +83,11 @@ found: goto err_out; } s->key_frame = -1; +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS s->convergence_duration = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->dts_sync_point = INT_MIN; s->dts_ref_dts_delta = INT_MIN; s->pts_dts_delta = INT_MIN; diff --git a/libavcodec/version.h b/libavcodec/version.h index 676099ccee..9c0ed3492a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -185,5 +185,8 @@ #ifndef FF_API_VDPAU_PROFILE #define FF_API_VDPAU_PROFILE (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_CONVERGENCE_DURATION +#define FF_API_CONVERGENCE_DURATION (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c index 805b5428f9..eacbc457b1 100644 --- a/libavformat/framecrcenc.c +++ b/libavformat/framecrcenc.c @@ -47,7 +47,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, + snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08"PRIx32, pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc); if (pkt->flags != AV_PKT_FLAG_KEY) av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags); diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 5e543634fd..0436a9328d 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -101,7 +101,7 @@ static int jacosub_read_close(AVFormatContext *s) } static const char *read_ts(JACOsubContext *jacosub, const char *buf, - int64_t *start, int *duration) + int64_t *start, int64_t *duration) { int len; unsigned hs, ms, ss, fs; // hours, minutes, seconds, frame start diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 7a094a6fb8..9db2b59d4e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2777,29 +2777,15 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, else pkt->pts = timecode; pkt->pos = pos; + pkt->duration = lace_duration; + +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (st->codec->codec_id == AV_CODEC_ID_SUBRIP) { - /* - * For backward compatibility. - * Historically, we have put subtitle duration - * in convergence_duration, on the off chance - * that the time_scale is less than 1us, which - * could result in a 32bit overflow on the - * normal duration field. - */ pkt->convergence_duration = lace_duration; } - - if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE || - lace_duration <= INT_MAX) { - /* - * For non subtitle tracks, just store the duration - * as normal. - * - * If it's a subtitle track and duration value does - * not overflow a uint32, then also store it normally. - */ - pkt->duration = lace_duration; - } +FF_ENABLE_DEPRECATION_WARNINGS +#endif dynarray_add(&matroska->packets, &matroska->num_packets, pkt); matroska->prev_pkt = pkt; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2b2d034e00..c5822678c6 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1629,7 +1629,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, ebml_master block_group, block_additions, block_more; av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " - "pts %" PRId64 ", dts %" PRId64 ", duration %d, keyframe %d\n", + "pts %" PRId64 ", dts %" PRId64 ", duration %" PRId64 ", keyframe %d\n", avio_tell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, keyframe != 0); if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 && @@ -1734,7 +1734,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p size = id_size + 1 + settings_size + 1 + pkt->size; 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), size, pkt->pts, pkt->dts, pkt->duration, flags); blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size)); @@ -1847,10 +1847,15 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size)); + +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS /* For backward compatibility, prefer convergence_duration. */ if (pkt->convergence_duration > 0) { duration = pkt->convergence_duration; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* All subtitle blocks are considered to be keyframes. */ mkv_write_block(s, pb, MATROSKA_ID_BLOCK, pkt, 1); put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration); diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c index e1a53684b6..8433be440d 100644 --- a/libavformat/md5enc.c +++ b/libavformat/md5enc.c @@ -135,7 +135,7 @@ static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) av_hash_init(c->hash); av_hash_update(c->hash, 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/movenc.c b/libavformat/movenc.c index af03d1e4bb..5115585019 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4317,7 +4317,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) pkt->pts = AV_NOPTS_VALUE; } if (pkt->duration < 0) { - av_log(s, AV_LOG_ERROR, "Application provided duration: %d is invalid\n", pkt->duration); + av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration); return AVERROR(EINVAL); } } diff --git a/libavformat/mux.c b/libavformat/mux.c index 37b5976464..c9ef490bd2 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -496,7 +496,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt) av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index); if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) { - av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n", + av_log(s, AV_LOG_WARNING, "Packet with invalid duration %"PRId64" in stream %d\n", pkt->duration, pkt->stream_index); pkt->duration = 0; } diff --git a/libavformat/r3d.c b/libavformat/r3d.c index f220e3d9c0..40e2147ad3 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -266,7 +266,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; } @@ -316,7 +316,7 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) pkt->dts = dts; if (st->codec->sample_rate) 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/srtenc.c b/libavformat/srtenc.c index 9bb83d645d..0b2a16bc4f 100644 --- a/libavformat/srtenc.c +++ b/libavformat/srtenc.c @@ -73,9 +73,13 @@ static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt) y2 = AV_RL32(p + 12); } +#if FF_API_CONVERGENCE_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (d <= 0) /* For backward compatibility, fallback to convergence_duration. */ d = pkt->convergence_duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (s == AV_NOPTS_VALUE || d < 0) { av_log(avf, AV_LOG_WARNING, "Insufficient timestamps in event number %d.\n", srt->index); diff --git a/libavformat/utils.c b/libavformat/utils.c index 199e80be8b..dc83608b1f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -954,7 +954,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, } } if (pktl && pktl->pkt.dts != st->first_dts) { - av_log(s, AV_LOG_DEBUG, "first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n", + av_log(s, AV_LOG_DEBUG, "first_dts %s not matching first dts %s (pts %s, duration %"PRId64") in the queue\n", av_ts2str(st->first_dts), av_ts2str(pktl->pkt.dts), av_ts2str(pktl->pkt.pts), pktl->pkt.duration); return; } @@ -1094,7 +1094,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_TRACE, - "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d delay:%d onein_oneout:%d\n", + "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64" delay:%d onein_oneout:%d\n", presentation_delayed, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), pkt->stream_index, pc, pkt->duration, delay, onein_oneout); @@ -1167,8 +1167,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* update flags */ if (is_intra_only(st->codec)) 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) @@ -1348,7 +1352,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=%s, dts=%s, size=%d, duration=%d, flags=%d\n", + "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64", flags=%d\n", cur_pkt.stream_index, av_ts2str(cur_pkt.pts), av_ts2str(cur_pkt.dts), @@ -1460,7 +1464,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=%s, dts=%s, " - "size=%d, duration=%d, flags=%d\n", + "size=%d, duration=%"PRId64", flags=%d\n", pkt->stream_index, av_ts2str(pkt->pts), av_ts2str(pkt->dts), |