[FFmpeg-cvslog] avformat/nutenc: limit index table size if no index is going to be written

Michael Niedermayer git at videolan.org
Thu May 29 04:12:29 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 29 03:48:02 2014 +0200| [6d1aba6a29b477ae69ca527812f10db5c025cf91] | committer: Michael Niedermayer

avformat/nutenc: limit index table size if no index is going to be written

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/nutenc.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 0bed15a..9920a39 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -1002,8 +1002,15 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
                 AV_ROUND_DOWN);
             int index = av_index_search_timestamp(st, dts_tb,
                                                   AVSEEK_FLAG_BACKWARD);
-            if (index >= 0)
+            if (index >= 0) {
                 sp_pos = FFMIN(sp_pos, st->index_entries[index].pos);
+                if (!nut->write_index && 2*index > st->nb_index_entries) {
+                    memmove(st->index_entries,
+                            st->index_entries + index,
+                            sizeof(*st->index_entries) * (st->nb_index_entries - index));
+                    st->nb_index_entries -=  index;
+                }
+            }
         }
 
         nut->last_syncpoint_pos = avio_tell(bc);



More information about the ffmpeg-cvslog mailing list