[FFmpeg-cvslog] avformat/utils: fix timebase error in avformat_seek_file()

2016-09-28 Thread Xinzheng Zhang
ffmpeg | branch: release/3.0 | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Sep 
14 16:13:45 2016 +0800| [f2f7d49f41b1d4a1ac7d6054c12ce92b4708d4d5] | committer: 
Michael Niedermayer

avformat/utils: fix timebase error in avformat_seek_file()

When there is only one stream and stream_index has not specified,
The ts has been transferd by the timebase of stream0 without modifying the 
stream_index
In this condation it cause seek failure.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit ecc04b4f2f29ac676e6c1d1ebf20ec45f5385f1e)
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2f7d49f41b1d4a1ac7d6054c12ce92b4708d4d5
---

 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 42b617e..c9bc6f2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2284,6 +2284,7 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
 max_ts = av_rescale_rnd(max_ts, time_base.den,
 time_base.num * (int64_t)AV_TIME_BASE,
 AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
+stream_index = 0;
 }
 
 ret = s->iformat->read_seek2(s, stream_index, min_ts,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/utils: fix timebase error in avformat_seek_file()

2016-09-28 Thread Xinzheng Zhang
ffmpeg | branch: release/3.1 | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Sep 
14 16:13:45 2016 +0800| [c68ce48260cf374480439b8f0d658f02fe9932d4] | committer: 
Michael Niedermayer

avformat/utils: fix timebase error in avformat_seek_file()

When there is only one stream and stream_index has not specified,
The ts has been transferd by the timebase of stream0 without modifying the 
stream_index
In this condation it cause seek failure.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit ecc04b4f2f29ac676e6c1d1ebf20ec45f5385f1e)
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c68ce48260cf374480439b8f0d658f02fe9932d4
---

 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1711bef..5be1e86 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2414,6 +2414,7 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
 max_ts = av_rescale_rnd(max_ts, time_base.den,
 time_base.num * (int64_t)AV_TIME_BASE,
 AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
+stream_index = 0;
 }
 
 ret = s->iformat->read_seek2(s, stream_index, min_ts,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/utils: fix timebase error in avformat_seek_file()

2016-09-17 Thread Xinzheng Zhang
ffmpeg | branch: release/2.8 | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Sep 
14 16:13:45 2016 +0800| [0bdfdd6d2f57afef1ca1db1137c03809125a58b1] | committer: 
Michael Niedermayer

avformat/utils: fix timebase error in avformat_seek_file()

When there is only one stream and stream_index has not specified,
The ts has been transferd by the timebase of stream0 without modifying the 
stream_index
In this condation it cause seek failure.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit ecc04b4f2f29ac676e6c1d1ebf20ec45f5385f1e)
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0bdfdd6d2f57afef1ca1db1137c03809125a58b1
---

 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 930b235..17c4ff0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2245,6 +2245,7 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
 max_ts = av_rescale_rnd(max_ts, time_base.den,
 time_base.num * (int64_t)AV_TIME_BASE,
 AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
+stream_index = 0;
 }
 
 ret = s->iformat->read_seek2(s, stream_index, min_ts,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/utils: fix timebase error in avformat_seek_file()

2016-09-14 Thread Xinzheng Zhang
ffmpeg | branch: master | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Sep 14 
16:13:45 2016 +0800| [ecc04b4f2f29ac676e6c1d1ebf20ec45f5385f1e] | committer: 
Michael Niedermayer

avformat/utils: fix timebase error in avformat_seek_file()

When there is only one stream and stream_index has not specified,
The ts has been transferd by the timebase of stream0 without modifying the 
stream_index
In this condation it cause seek failure.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecc04b4f2f29ac676e6c1d1ebf20ec45f5385f1e
---

 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index cbaeef0..d605a96 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2418,6 +2418,7 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
 max_ts = av_rescale_rnd(max_ts, time_base.den,
 time_base.num * (int64_t)AV_TIME_BASE,
 AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
+stream_index = 0;
 }
 
 ret = s->iformat->read_seek2(s, stream_index, min_ts,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/flvdec: splitting add_keyframes_index() out from parse_keyframes_index()

2016-08-01 Thread Xinzheng Zhang
ffmpeg | branch: release/3.1 | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Jul 
27 12:21:24 2016 +0800| [88e3e6b94305839ca101e8bf2c4dd96700166c2f] | committer: 
Michael Niedermayer

avformat/flvdec: splitting add_keyframes_index() out from 
parse_keyframes_index()

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit cd141e71bd3441ac9b7b720b934b7d4d85a75355)

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88e3e6b94305839ca101e8bf2c4dd96700166c2f
---

 libavformat/flvdec.c | 76 +---
 1 file changed, 60 insertions(+), 16 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 2bf1e05..633cad0 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -61,6 +61,11 @@ typedef struct FLVContext {
 
 int broken_sizes;
 int sum_flv_tag_size;
+
+int last_keyframe_stream_index;
+int keyframe_count;
+int64_t *keyframe_times;
+int64_t *keyframe_filepositions;
 } FLVContext;
 
 static int probe(AVProbeData *p, int live)
@@ -92,6 +97,35 @@ static int live_flv_probe(AVProbeData *p)
 return probe(p, 1);
 }
 
+static void add_keyframes_index(AVFormatContext *s)
+{
+FLVContext *flv   = s->priv_data;
+AVStream *stream  = NULL;
+unsigned int i= 0;
+
+if (flv->last_keyframe_stream_index < 0) {
+av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
+return;
+}
+
+av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
+stream = s->streams[flv->last_keyframe_stream_index];
+
+if (stream->nb_index_entries == 0) {
+for (i = 0; i < flv->keyframe_count; i++) {
+av_add_index_entry(stream, flv->keyframe_filepositions[i],
+flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME);
+}
+} else
+av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+
+if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+av_freep(>keyframe_times);
+av_freep(>keyframe_filepositions);
+flv->keyframe_count = 0;
+}
+}
+
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
 AVStream *st = avformat_new_stream(s, NULL);
@@ -305,8 +339,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, 
int buffsize)
 return length;
 }
 
-static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
- AVStream *vstream, int64_t max_pos)
+static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t 
max_pos)
 {
 FLVContext *flv   = s->priv_data;
 unsigned int timeslen = 0, fileposlen = 0, i;
@@ -316,10 +349,12 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 int ret= AVERROR(ENOSYS);
 int64_t initial_pos= avio_tell(ioc);
 
-if (vstream->nb_index_entries>0) {
-av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+if (flv->keyframe_count > 0) {
+av_log(s, AV_LOG_DEBUG, "keyframes have been paresed\n");
 return 0;
 }
+av_assert0(!flv->keyframe_times);
+av_assert0(!flv->keyframe_filepositions);
 
 if (s->flags & AVFMT_FLAG_IGNIDX)
 return 0;
@@ -368,15 +403,17 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 }
 
 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) 
{
-for (i = 0; i < fileposlen; i++) {
-av_add_index_entry(vstream, filepositions[i], times[i] * 1000,
-   0, 0, AVINDEX_KEYFRAME);
-if (i < 2) {
-flv->validate_index[i].pos = filepositions[i];
-flv->validate_index[i].dts = times[i] * 1000;
-flv->validate_count= i + 1;
-}
+for (i = 0; i < FFMIN(2,fileposlen); i++) {
+flv->validate_index[i].pos = filepositions[i];
+flv->validate_index[i].dts = times[i] * 1000;
+flv->validate_count= i + 1;
 }
+flv->keyframe_times = times;
+flv->keyframe_filepositions = filepositions;
+flv->keyframe_count = timeslen;
+times = NULL;
+filepositions = NULL;
+add_keyframes_index(s);
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -421,10 +458,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 if ((vstream || astream) && key &&
 ioc->seekable &&
 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
-if (parse_keyframes_index(s, ioc, vstrea

[FFmpeg-cvslog] avformat/flvdec: splitting add_keyframes_index() out from parse_keyframes_index()

2016-07-27 Thread Xinzheng Zhang
ffmpeg | branch: master | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Jul 27 
12:21:24 2016 +0800| [cd141e71bd3441ac9b7b720b934b7d4d85a75355] | committer: 
Michael Niedermayer

avformat/flvdec: splitting add_keyframes_index() out from 
parse_keyframes_index()

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cd141e71bd3441ac9b7b720b934b7d4d85a75355
---

 libavformat/flvdec.c | 76 +---
 1 file changed, 60 insertions(+), 16 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 2bf1e05..633cad0 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -61,6 +61,11 @@ typedef struct FLVContext {
 
 int broken_sizes;
 int sum_flv_tag_size;
+
+int last_keyframe_stream_index;
+int keyframe_count;
+int64_t *keyframe_times;
+int64_t *keyframe_filepositions;
 } FLVContext;
 
 static int probe(AVProbeData *p, int live)
@@ -92,6 +97,35 @@ static int live_flv_probe(AVProbeData *p)
 return probe(p, 1);
 }
 
+static void add_keyframes_index(AVFormatContext *s)
+{
+FLVContext *flv   = s->priv_data;
+AVStream *stream  = NULL;
+unsigned int i= 0;
+
+if (flv->last_keyframe_stream_index < 0) {
+av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
+return;
+}
+
+av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
+stream = s->streams[flv->last_keyframe_stream_index];
+
+if (stream->nb_index_entries == 0) {
+for (i = 0; i < flv->keyframe_count; i++) {
+av_add_index_entry(stream, flv->keyframe_filepositions[i],
+flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME);
+}
+} else
+av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+
+if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+av_freep(>keyframe_times);
+av_freep(>keyframe_filepositions);
+flv->keyframe_count = 0;
+}
+}
+
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
 AVStream *st = avformat_new_stream(s, NULL);
@@ -305,8 +339,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, 
int buffsize)
 return length;
 }
 
-static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
- AVStream *vstream, int64_t max_pos)
+static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t 
max_pos)
 {
 FLVContext *flv   = s->priv_data;
 unsigned int timeslen = 0, fileposlen = 0, i;
@@ -316,10 +349,12 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 int ret= AVERROR(ENOSYS);
 int64_t initial_pos= avio_tell(ioc);
 
-if (vstream->nb_index_entries>0) {
-av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+if (flv->keyframe_count > 0) {
+av_log(s, AV_LOG_DEBUG, "keyframes have been paresed\n");
 return 0;
 }
+av_assert0(!flv->keyframe_times);
+av_assert0(!flv->keyframe_filepositions);
 
 if (s->flags & AVFMT_FLAG_IGNIDX)
 return 0;
@@ -368,15 +403,17 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 }
 
 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) 
{
-for (i = 0; i < fileposlen; i++) {
-av_add_index_entry(vstream, filepositions[i], times[i] * 1000,
-   0, 0, AVINDEX_KEYFRAME);
-if (i < 2) {
-flv->validate_index[i].pos = filepositions[i];
-flv->validate_index[i].dts = times[i] * 1000;
-flv->validate_count= i + 1;
-}
+for (i = 0; i < FFMIN(2,fileposlen); i++) {
+flv->validate_index[i].pos = filepositions[i];
+flv->validate_index[i].dts = times[i] * 1000;
+flv->validate_count= i + 1;
 }
+flv->keyframe_times = times;
+flv->keyframe_filepositions = filepositions;
+flv->keyframe_count = timeslen;
+times = NULL;
+filepositions = NULL;
+add_keyframes_index(s);
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -421,10 +458,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 if ((vstream || astream) && key &&
 ioc->seekable &&
 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
-if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
+if (parse_keyframes_index(s, ioc,
   max_pos) < 0)
 av_log(s, AV_LOG_ERROR,

[FFmpeg-cvslog] avformat/flvdec: parse keyframe before a\v stream was created add_keyframes_index() when stream created or keyframe parsed

2016-07-27 Thread Xinzheng Zhang
ffmpeg | branch: master | Xinzheng Zhang <zhangxzh...@gmail.com> | Wed Jul 27 
12:21:25 2016 +0800| [ad14aab3b4f88cdb6c2a3f8877c578e5a8042f1d] | committer: 
Michael Niedermayer

avformat/flvdec: parse keyframe before a\v stream was created 
add_keyframes_index() when stream created or keyframe parsed

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad14aab3b4f88cdb6c2a3f8877c578e5a8042f1d
---

 libavformat/flvdec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 633cad0..0afeba5 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -128,6 +128,7 @@ static void add_keyframes_index(AVFormatContext *s)
 
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
+FLVContext *flv   = s->priv_data;
 AVStream *st = avformat_new_stream(s, NULL);
 if (!st)
 return NULL;
@@ -138,6 +139,8 @@ static AVStream *create_stream(AVFormatContext *s, int 
codec_type)
 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
 
 avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
+flv->last_keyframe_stream_index = s->nb_streams - 1;
+add_keyframes_index(s);
 return st;
 }
 
@@ -413,7 +416,6 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc, int64_t m
 flv->keyframe_count = timeslen;
 times = NULL;
 filepositions = NULL;
-add_keyframes_index(s);
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -455,12 +457,14 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 }
 break;
 case AMF_DATA_TYPE_OBJECT:
-if ((vstream || astream) && key &&
+if (key &&
 ioc->seekable &&
 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
 if (parse_keyframes_index(s, ioc,
   max_pos) < 0)
 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
+else
+add_keyframes_index(s);
 while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
 if (amf_parse_object(s, astream, vstream, str_val, max_pos,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog