[FFmpeg-devel] [PATCH] libavformat/avidec: subtitle stream disable some non-interleaved process
tiejun.peng
tiejun.peng at foxmail.com
Sun Sep 10 07:45:19 EEST 2017
non-interleaved process call avio_seek frequently, it will cause some performance issues especially in network play scene, such as http/ftp protocol.
Signed-off-by: tiejun.peng <tiejun.peng at foxmail.com>
---
libavformat/avidec.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index b8a31dc..0220ea1 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1520,7 +1520,8 @@ resync:
}
ast->seek_pos= 0;
- if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1) {
+ /* subtitle stream no need the next process, because subtitle's pkt->dts is always 0 */
+ if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1 && st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
int64_t dts= av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q);
if (avi->dts_max - dts > 2*AV_TIME_BASE) {
@@ -1646,6 +1647,10 @@ static int check_stream_max_drift(AVFormatContext *s)
AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data;
int n = st->nb_index_entries;
+ /* when stream is subtitle, don't change min_dts, because subtitle stream's dts is always 0 */
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ continue;
+
while (idx[i] < n && st->index_entries[idx[i]].pos < pos)
idx[i]++;
if (idx[i] < n) {
@@ -1661,6 +1666,10 @@ static int check_stream_max_drift(AVFormatContext *s)
AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data;
+ /* when stream is subtitle, don't change max_dts, because subtitle stream's dts is always 0 */
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ continue;
+
if (idx[i] && min_dts != INT64_MAX / 2) {
int64_t dts;
dts = av_rescale_q(st->index_entries[idx[i] - 1].timestamp /
--
2.7.4
More information about the ffmpeg-devel
mailing list