[xiph-commits] r17501 - trunk/ffmpeg2theora/src

oggk at svn.xiph.org oggk at svn.xiph.org
Sun Oct 10 07:55:10 PDT 2010


Author: oggk
Date: 2010-10-10 07:55:10 -0700 (Sun, 10 Oct 2010)
New Revision: 17501

Modified:
   trunk/ffmpeg2theora/src/theorautils.c
   trunk/ffmpeg2theora/src/theorautils.h
Log:
only generate a random serial number for one stream, and increment it for
 the subsequent streams, to avoid a possible (though unlikely) collision
OK'd by j.



Modified: trunk/ffmpeg2theora/src/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.c	2010-10-09 23:42:11 UTC (rev 17500)
+++ trunk/ffmpeg2theora/src/theorautils.c	2010-10-10 14:55:10 UTC (rev 17501)
@@ -106,6 +106,8 @@
 
     info->prev_vorbis_window = -1;
     info->content_offset = 0;
+
+    info->serialno = 0;
 }
 
 void oggmux_setup_kate_streams(oggmux_info *info, int n_kate_streams)
@@ -813,7 +815,8 @@
 
     /* yayness.  Set up Ogg output stream */
     srand (time (NULL));
-    ogg_stream_init (&info->vo, rand ());
+    info->serialno = rand();
+    ogg_stream_init (&info->vo, info->serialno++);
 
     if (info->passno!=1) {
         th_comment_add_tag(&info->tc, "ENCODER", PACKAGE_STRING);
@@ -825,7 +828,7 @@
     }
 
     if (!info->audio_only) {
-        ogg_stream_init (&info->to, rand ());    /* oops, add one ot the above */
+        ogg_stream_init (&info->to, info->serialno++);
         seek_index_init(&info->theora_index, info->index_interval);
     }
     /* init theora done */
@@ -860,7 +863,7 @@
         int ret, n;
         for (n=0; n<info->n_kate_streams; ++n) {
             oggmux_kate_stream *ks=info->kate_streams+n;
-            ogg_stream_init (&ks->ko, rand ());    /* oops, add one ot the above */
+            ogg_stream_init (&ks->ko, info->serialno++);
             ret = kate_encode_init (&ks->k, &ks->ki);
             if (ret<0) {
                 fprintf(stderr, "kate_encode_init: %d\n",ret);
@@ -897,7 +900,7 @@
            page with a Skeleton4.0 header page. */
         int skeleton_3 = info->skeleton_3;
         info->skeleton_3 = 1;
-        ogg_stream_init (&info->so, rand());
+        ogg_stream_init (&info->so, info->serialno++);
         add_fishead_packet (info, 3, 0);
         if (ogg_stream_pageout (&info->so, &og) != 1) {
             fprintf (stderr, "Internal Ogg library error.\n");
@@ -921,7 +924,7 @@
                 exit (1);
             }
             ogg_stream_clear (&info->so);
-            ogg_stream_init (&info->so, rand());
+            ogg_stream_init (&info->so, info->serialno++);
             add_fishead_packet (info, 4, 0);
             if (ogg_stream_pageout (&info->so, &og) != 1) {
                 fprintf (stderr, "Internal Ogg library error.\n");

Modified: trunk/ffmpeg2theora/src/theorautils.h
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.h	2010-10-09 23:42:11 UTC (rev 17500)
+++ trunk/ffmpeg2theora/src/theorautils.h	2010-10-10 14:55:10 UTC (rev 17501)
@@ -157,6 +157,8 @@
                                calculate duration of vorbis packets. */
     /* The offset of the first non header page in bytes. */
     ogg_int64_t content_offset;
+
+    ogg_int32_t serialno;
 }
 oggmux_info;
 



More information about the commits mailing list