On 4/12/11 12:59 PM, Martin Storsjö wrote:
On Tue, 12 Apr 2011, Anton Khirnov wrote:
On Tue, Apr 12, 2011 at 12:43:23PM +0300, Martin Storsjö wrote:
From: Michael Niedermayer<[email protected]>
Reading the index currently requires seeking.
---
libavformat/flvdec.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 62d25c8..1a827fd 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -212,7 +212,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream
*astream, AVStream *vst
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
- if (key&& !strcmp(KEYFRAMES_TAG, key)&& depth == 1)
+ if (ioc->seekable&& key&& !strcmp(KEYFRAMES_TAG, key)&& depth
== 1)
if (parse_keyframes_index(s, ioc, vstream, max_pos)< 0)
return -1;
--
1.7.3.1
Ok
Queued.
Dequeue, there is a simpler solution for that.
Right now what we should decide is if we want to error out if we don't
have enough memory for the index or keep going.
I'd just error out if I cannot parse an element as before.
Here an untested tentative patch, point me to a sample file and I'll
make sure it works as should.
lu
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 62d25c8..155a47f 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -136,7 +136,6 @@ static int parse_keyframes_index(AVFormatContext *s,
AVIOContext *ioc, AVStream
int64_t *times = NULL;
int64_t *filepositions = NULL;
int ret = 0;
- int64_t initial_pos = avio_tell(ioc);
while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val,
sizeof(str_val)) > 0) {
int64_t* current_array;
@@ -181,10 +180,11 @@ static int parse_keyframes_index(AVFormatContext *s,
AVIOContext *ioc, AVStream
else
av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
+ ret = -1;
finish:
av_freep(×);
av_freep(&filepositions);
- avio_seek(ioc, initial_pos, SEEK_SET);
return ret;
}
@@ -212,9 +212,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream
*astream, AVStream *vst
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
- if (key && !strcmp(KEYFRAMES_TAG, key) && depth == 1)
+ if (key && !strcmp(KEYFRAMES_TAG, key) && depth == 1) {
if (parse_keyframes_index(s, ioc, vstream, max_pos) < 0)
return -1;
+ else
+ break;
+ }
while(avio_tell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {
avio_skip(ioc, keylen); //skip key string
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel