[FFmpeg-devel] [PATCH] lavf/oggdec: check for begin-of-stream flag in case of chained streams.

Clément Bœsch ubitux at gmail.com
Mon Sep 17 22:52:15 CEST 2012


On Sun, Sep 16, 2012 at 10:28:06PM +0200, Clément Bœsch wrote:
> Fix Ticket #1617, revealing a regression I introduced in 8f3eebd.
> ---
>  libavformat/oggdec.c | 15 ++++++++++++++-
>  libavformat/oggdec.h |  1 +
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 

New version resetting the state of the stream. Doesn't seem to affect the
behaviour with my tests case.

-- 
Clément B.
-------------- next part --------------
From 9ce5be3a86a3eb3359707148659ac8a4e3e96d78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Sun, 16 Sep 2012 22:24:11 +0200
Subject: [PATCH] lavf/oggdec: check for begin-of-stream flag in case of
 chained streams.

Fix Ticket #1617, revealing a regression I introduced in 8f3eebd.
---
 libavformat/oggdec.c | 16 +++++++++++++++-
 libavformat/oggdec.h |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 02d64d4..c37fc58 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -139,6 +139,7 @@ static int ogg_reset(AVFormatContext *s)
         os->nsegs = 0;
         os->segp = 0;
         os->incomplete = 0;
+        os->got_data = 0;
         if (start_pos <= s->data_offset) {
             os->lastpts = 0;
         }
@@ -248,6 +249,16 @@ static int ogg_new_buf(struct ogg *ogg, int idx)
     return 0;
 }
 
+static int data_packets_seen(const struct ogg *ogg)
+{
+    int i;
+
+    for (i = 0; i < ogg->nstreams; i++)
+        if (ogg->streams[i].got_data)
+            return 1;
+    return 0;
+}
+
 static int ogg_read_page(AVFormatContext *s, int *sid)
 {
     AVIOContext *bc = s->pb;
@@ -297,7 +308,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 
     idx = ogg_find_stream (ogg, serial);
     if (idx < 0){
-        if (ogg->headers)
+        if (data_packets_seen(ogg))
             idx = ogg_replace_stream(s, serial);
         else
             idx = ogg_new_stream(s, serial);
@@ -325,6 +336,9 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
     for (i = 0; i < nsegs; i++)
         size += os->segments[i];
 
+    if (!(flags & OGG_FLAG_BOS))
+        os->got_data = 1;
+
     if (flags & OGG_FLAG_CONT || os->incomplete){
         if (!os->psize){
             // If this is the very first segment we started
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index aa94db5..b68c40d 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -76,6 +76,7 @@ struct ogg_stream {
     int page_end;   ///< current packet is the last one completed in the page
     int keyframe_seek;
     int got_start;
+    int got_data;   ///< 1 if the stream expected some data (non-initial packets), 0 otherwise
     void *private;
 };
 
-- 
1.7.12

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120917/c0d4ba09/attachment.asc>


More information about the ffmpeg-devel mailing list