[FFmpeg-devel] [PATCH] avformat/utils: ignore outlier durations on subtitle/data streams as well
Michael Niedermayer
michael at niedermayer.cc
Fri Apr 20 02:43:18 EEST 2018
On Thu, Apr 19, 2018 at 01:35:20PM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman at tmm1.net>
>
> Similar to 4c9c4fe8b21, but for durations. This fixes #7151, where
> the report duration and bitrate on a mpegts stream is wildly off
> due to the dvb_teletext stream's timings.
> ---
> libavformat/utils.c | 33 +++++++++++++++++++++------------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index f2f2cc4239..c685d260f7 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2618,9 +2618,8 @@ static int has_duration(AVFormatContext *ic)
> static void update_stream_timings(AVFormatContext *ic)
> {
> int64_t start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
> - int64_t duration, duration1, filesize;
> + int64_t duration, duration1, duration_text, filesize;
> int i;
> - AVStream *st;
> AVProgram *p;
>
> start_time = INT64_MAX;
> @@ -2628,22 +2627,25 @@ static void update_stream_timings(AVFormatContext *ic)
> end_time = INT64_MIN;
> end_time_text = INT64_MIN;
> duration = INT64_MIN;
> + duration_text = INT64_MIN;
> +
> for (i = 0; i < ic->nb_streams; i++) {
> - st = ic->streams[i];
> + AVStream *st = ic->streams[i];
> + int is_text = st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ||
> + st->codecpar->codec_type == AVMEDIA_TYPE_DATA;
> if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) {
> start_time1 = av_rescale_q(st->start_time, st->time_base,
> AV_TIME_BASE_Q);
> - if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
> - if (start_time1 < start_time_text)
> - start_time_text = start_time1;
> - } else
> + if (is_text)
> + start_time_text = FFMIN(start_time_text, start_time1);
> + else
> start_time = FFMIN(start_time, start_time1);
> end_time1 = av_rescale_q_rnd(st->duration, st->time_base,
> AV_TIME_BASE_Q,
> AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
> if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
> end_time1 += start_time1;
> - if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
> + if (is_text)
please split the code factorization into a seperate patch
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180420/2557c238/attachment.sig>
More information about the ffmpeg-devel
mailing list