Message ID | 1505018719-15091-1-git-send-email-tiejun.peng@foxmail.com |
---|---|
State | New |
Headers | show |
On Sun, Sep 10, 2017 at 12:45:19PM +0800, tiejun.peng wrote: > 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@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; > > + /* subtitle stream no need the next process, because subtitle's pkt->dts is always 0 */ The english grammer is not good > - if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1) { > + if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1 && st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) { this already checks that there are multiple index entries Do these all have the same timestamp ? it seems a bit counter intuitiv to have 2 with dts=0. Please elaborate also please provide a testcase to reproduce the issue [...]
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 /
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@foxmail.com> --- libavformat/avidec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)