From 20be72c8909cf22811926a6c182a58bc210e47dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= <mans@mansr.com>
Date: Mon, 15 Jan 2007 22:05:22 +0000
Subject: [PATCH] save/restore number of streams

Originally committed as revision 7535 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavformat/ogg2.c | 6 ++++--
 libavformat/ogg2.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/ogg2.c b/libavformat/ogg2.c
index 1e5d3862051..d630d4a3da9 100644
--- a/libavformat/ogg2.c
+++ b/libavformat/ogg2.c
@@ -90,6 +90,7 @@ ogg_save (AVFormatContext * s)
     ost->pos = url_ftell (&s->pb);;
     ost->curidx = ogg->curidx;
     ost->next = ogg->state;
+    ost->nstreams = ogg->nstreams;
     memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
 
     for (i = 0; i < ogg->nstreams; i++){
@@ -123,8 +124,9 @@ ogg_restore (AVFormatContext * s, int discard)
 
         url_fseek (bc, ost->pos, SEEK_SET);
         ogg->curidx = ost->curidx;
-        memcpy (ogg->streams, ost->streams,
-        ogg->nstreams * sizeof (*ogg->streams));
+        ogg->nstreams = ost->nstreams;
+        memcpy(ogg->streams, ost->streams,
+               ost->nstreams * sizeof(*ogg->streams));
     }
 
     av_free (ost);
diff --git a/libavformat/ogg2.h b/libavformat/ogg2.h
index dd6f24aab6e..6b7c6b22ec7 100644
--- a/libavformat/ogg2.h
+++ b/libavformat/ogg2.h
@@ -57,6 +57,7 @@ typedef struct ogg_state {
     uint64_t pos;
     int curidx;
     struct ogg_state *next;
+    int nstreams;
     ogg_stream_t streams[1];
 } ogg_state_t;
 
-- 
GitLab