diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2014-03-03 09:20:53 +0100 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2014-03-03 09:20:53 +0100 |
commit | 16c7667d7ebe7fbdb49af0c5d0be9eb86fdc5d39 (patch) | |
tree | 45e62f0718c5d20d61164b1b35c637fb4ecade69 /lib | |
parent | 9fd89d4eb366e094c3824853267766ebd205b05c (diff) |
ffmpeg: backport detect MPEG streams with faulty DTS and discard
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffmpeg/patches/0059-backport-detect-MPEG-streams-faulty-dts.patch | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/lib/ffmpeg/patches/0059-backport-detect-MPEG-streams-faulty-dts.patch b/lib/ffmpeg/patches/0059-backport-detect-MPEG-streams-faulty-dts.patch new file mode 100644 index 0000000000..1ea599187c --- /dev/null +++ b/lib/ffmpeg/patches/0059-backport-detect-MPEG-streams-faulty-dts.patch @@ -0,0 +1,92 @@ +From 2dcaa1b9d142ae113b28bffdbf7f8f8900b5e770 Mon Sep 17 00:00:00 2001 +From: Michael Niedermayer <michaelni@gmx.at> +Date: Mon, 3 Mar 2014 01:55:18 +0100 +Subject: [PATCH] avformat/utils: detect MPEG streams with faulty DTS and + discard affected DTS + +Fixes issue2.ts + +Signed-off-by: Michael Niedermayer <michaelni@gmx.at> +--- + libavformat/avformat.h | 7 +++++++ + libavformat/utils.c | 25 +++++++++++++++++++++++++ + 2 files changed, 32 insertions(+) + +diff --git a/libavformat/avformat.h b/libavformat/avformat.h +index 52eeb61..e0ec3da 100644 +--- a/libavformat/avformat.h ++++ b/libavformat/avformat.h +@@ -988,6 +988,13 @@ enum AVStreamParseType { + int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; + uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; + ++ /** ++ * Internal data to analyze DTS and detect faulty mpeg streams ++ */ ++ int64_t last_dts_for_order_check; ++ uint8_t dts_ordered; ++ uint8_t dts_misordered; ++ + } AVStream; + + AVRational av_stream_get_r_frame_rate(const AVStream *s); +diff --git a/libavformat/utils.c b/libavformat/utils.c +index 584edd3..4e262b1 100644 +--- a/libavformat/utils.c ++++ b/libavformat/utils.c +@@ -1120,6 +1120,28 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, + if (s->flags & AVFMT_FLAG_NOFILLIN) + return; + ++ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE) { ++ if (pkt->dts == pkt->pts && st->last_dts_for_order_check != AV_NOPTS_VALUE) { ++ if (st->last_dts_for_order_check <= pkt->dts) { ++ st->dts_ordered++; ++ } else { ++ av_log(s, st->dts_misordered ? AV_LOG_DEBUG : AV_LOG_WARNING, ++ "DTS %"PRIi64" < %"PRIi64" out of order\n", ++ pkt->dts, ++ st->last_dts_for_order_check); ++ st->dts_misordered++; ++ } ++ if (st->dts_ordered + st->dts_misordered > 250) { ++ st->dts_ordered >>= 1; ++ st->dts_misordered >>= 1; ++ } ++ } ++ ++ st->last_dts_for_order_check = pkt->dts; ++ if (st->dts_ordered < 8*st->dts_misordered && pkt->dts == pkt->pts) ++ pkt->dts = AV_NOPTS_VALUE; ++ } ++ + if ((s->flags & AVFMT_FLAG_IGNDTS) && pkt->pts != AV_NOPTS_VALUE) + pkt->dts = AV_NOPTS_VALUE; + +@@ -1664,6 +1686,7 @@ void ff_read_frame_flush(AVFormatContext *s) + st->parser = NULL; + } + st->last_IP_pts = AV_NOPTS_VALUE; ++ st->last_dts_for_order_check = AV_NOPTS_VALUE; + if (st->first_dts == AV_NOPTS_VALUE) + st->cur_dts = RELATIVE_TS_BASE; + else +@@ -2488,6 +2511,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) + st = ic->streams[i]; + st->cur_dts = st->first_dts; + st->last_IP_pts = AV_NOPTS_VALUE; ++ st->last_dts_for_order_check = AV_NOPTS_VALUE; + for (j = 0; j < MAX_REORDER_DELAY + 1; j++) + st->pts_buffer[j] = AV_NOPTS_VALUE; + } +@@ -3623,6 +3647,7 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) + /* default pts setting is MPEG-like */ + avpriv_set_pts_info(st, 33, 1, 90000); + st->last_IP_pts = AV_NOPTS_VALUE; ++ st->last_dts_for_order_check = AV_NOPTS_VALUE; + for (i = 0; i < MAX_REORDER_DELAY + 1; i++) + st->pts_buffer[i] = AV_NOPTS_VALUE; + +-- +1.8.5.5 + |