[FFmpeg-cvslog] avformat/oggenc: Check segments_count for headers too

Michael Niedermayer git at videolan.org
Sat Oct 10 00:38:43 CEST 2015


ffmpeg | branch: release/2.2 | Michael Niedermayer <michael at niedermayer.cc> | Thu Aug 27 04:08:42 2015 +0200| [57e284dac6491bff2b0127db3cf68a5beee4a24e] | committer: Carl Eugen Hoyos

avformat/oggenc: Check segments_count for headers too

Fixes infinite loop and segfault in ogg_buffer_data()
Fixes Ticket4806

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 81a8701eb52d2b6469ae16ef442ce425388141b7)

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

 libavformat/oggenc.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 9c64755..b2680ec 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -249,7 +249,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
         if (i == total_segments)
             page->granule = granule;
 
-        if (!header) {
+        {
             AVStream *st = s->streams[page->stream_index];
 
             int64_t start = av_rescale_q(page->start_granule, st->time_base,
@@ -257,10 +257,13 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
             int64_t next  = av_rescale_q(page->granule, st->time_base,
                                          AV_TIME_BASE_Q);
 
-            if (page->segments_count == 255 ||
-                (ogg->pref_size     > 0 && page->size   >= ogg->pref_size) ||
-                (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
+            if (page->segments_count == 255) {
                 ogg_buffer_page(s, oggstream);
+            } else if (!header) {
+                if ((ogg->pref_size     > 0 && page->size   >= ogg->pref_size) ||
+                    (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
+                    ogg_buffer_page(s, oggstream);
+                }
             }
         }
     }



More information about the ffmpeg-cvslog mailing list