On Fri, Sep 11, 2015 at 12:17 AM, wm4 <[email protected]> wrote:
> 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.
> ---
> libavcodec/audio_frame_queue.c | 2 +-
> libavcodec/audio_frame_queue.h | 2 +-
> libavcodec/avcodec.h | 44
> +++++++++++-------------------------------
> libavcodec/avpacket.c | 6 ++++++
> libavcodec/parser.c | 2 ++
> libavcodec/version.h | 3 +++
> libavformat/framecrcenc.c | 2 +-
> libavformat/matroskadec.c | 6 ++++--
> libavformat/matroskaenc.c | 8 ++++++--
> libavformat/md5enc.c | 2 +-
> libavformat/mov.c | 2 +-
> libavformat/r3d.c | 4 ++--
> libavformat/utils.c | 6 ++++--
> 13 files changed, 43 insertions(+), 46 deletions(-)
>
> diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c
> index 15ffa82..c4ca02b 100644
> --- a/libavcodec/audio_frame_queue.c
> +++ b/libavcodec/audio_frame_queue.c
> @@ -111,7 +111,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 4a29770..1250ec2 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 9b38655..251ad13 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1197,28 +1197,18 @@ 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.
> */
> - int64_t convergence_duration;
> + 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
> @@ -3837,24 +3827,12 @@ 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
> */
> - int64_t convergence_duration;
> + attribute_deprecated int64_t convergence_duration;
> +#endif
>
> // Timestamp generation support:
> /**
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index dfaf045..d4d7631 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -34,7 +34,9 @@ void av_init_packet(AVPacket *pkt)
> pkt->dts = AV_NOPTS_VALUE;
> pkt->pos = -1;
> pkt->duration = 0;
> +#if FF_API_CONVERGENCE_DURATION
> pkt->convergence_duration = 0;
> +#endif
> pkt->flags = 0;
> pkt->stream_index = 0;
> pkt->buf = NULL;
> @@ -269,7 +271,9 @@ 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
> dst->convergence_duration = src->convergence_duration;
> +#endif
> dst->flags = src->flags;
> dst->stream_index = src->stream_index;
>
> @@ -341,6 +345,8 @@ 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
> if (pkt->convergence_duration > 0)
> pkt->convergence_duration = av_rescale_q(pkt->convergence_duration,
> src_tb, dst_tb);
> +#endif
> }
> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> index 4671c13..5224a53 100644
> --- a/libavcodec/parser.c
> +++ b/libavcodec/parser.c
> @@ -86,7 +86,9 @@ found:
> s->fetch_timestamp = 1;
> s->pict_type = AV_PICTURE_TYPE_I;
> s->key_frame = -1;
> +#if FF_API_CONVERGENCE_DURATION
> s->convergence_duration = 0;
> +#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 eefc3a9..a92ca6c 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -162,5 +162,8 @@
> #ifndef FF_API_WITHOUT_PREFIX
> #define FF_API_WITHOUT_PREFIX (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 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..3c9147a 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -2335,10 +2335,12 @@ 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
> if (st->codec->codec_id == AV_CODEC_ID_TEXT)
> pkt->convergence_duration = duration;
> - else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)
> - pkt->duration = duration;
> +#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..8a746fe 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,11 @@ 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
> + if (pkt->convergence_duration)
> + duration = pkt->convergence_duration;
> +#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..2834dd6 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -735,8 +735,10 @@ 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
> if (pc)
> pkt->convergence_duration = pc->convergence_duration;
> +#endif
> }
>
> static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList
> **pkt_buf_end)
> @@ -906,7 +908,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 +957,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);
the patch is very nice, but every time the deprecated variable is used
you should add FF_{DISABLE,ENABLE}_DEPRECATION_WARNINGS or you'll get
several deprecation warning messages.
--
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel