[FFmpeg-devel] [PATCH] avformat/fivdec: cached keyframes before video or audio stream was created

Michael Niedermayer michael at niedermayer.cc
Mon Jul 25 23:33:36 EEST 2016


On Mon, Jul 25, 2016 at 05:34:58PM +0800, XinZheng Zhang wrote:
> On Mon, Jul 25, 2016 at 4:41 PM, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
> > On Thu, Jul 21, 2016 at 10:36:20AM +0800, Xinzheng Zhang wrote:
> >> ---
> >>  libavformat/flvdec.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
> >>  1 file changed, 44 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> >> index 2bf1e05..b4fb4e2 100644
> >> --- a/libavformat/flvdec.c
> >> +++ b/libavformat/flvdec.c
> >> @@ -30,6 +30,7 @@
> >>  #include "libavutil/opt.h"
> >>  #include "libavutil/intfloat.h"
> >>  #include "libavutil/mathematics.h"
> >> +#include "libavutil/mem.h"
> >>  #include "libavcodec/bytestream.h"
> >>  #include "libavcodec/mpeg4audio.h"
> >>  #include "avformat.h"
> >> @@ -41,6 +42,11 @@
> >>
> >>  #define RESYNC_BUFFER_SIZE (1<<20)
> >>
> >> +typedef struct FLVKeyFrame {
> >> +    int64_t pos;
> >> +    int64_t timestamp;
> >> +} FLVKeyFrame;
> >
> > instead of adding a 3rd array the local arrays from parse_keyframes_index()
> > could be moved into the context. That would reduce the memory needed
> >
> 
> ok
> 

> > It also may be needed to keep 2 sets that is one per stream
> > and the arrays should be freed after their use
> >
> >
> 
> Is that mean we need to call av_add_index_entry() for both stream?

no, but i am not sure if its guranteed that we never read both

when it first looks like theres just an audio stream the audio
index is loaded but when then a video index is found that is loaded
i think

maybe you could free the previous one in that case if you prefer
to have only single set of arrays


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160725/c81a0c82/attachment.sig>


More information about the ffmpeg-devel mailing list