[xiph-commits] r11416 - icecast/trunk/libshout/src

brendan at svn.xiph.org brendan at svn.xiph.org
Sun May 21 17:32:50 PDT 2006


Author: brendan
Date: 2006-05-21 17:32:49 -0700 (Sun, 21 May 2006)
New Revision: 11416

Modified:
   icecast/trunk/libshout/src/theora.c
Log:
(from Karl)

Another diff, this time it fixes a memory leak, the memory does get
freed up but only on close or when new headers come in.  So if using
something like ffmpeg2theora as the feed, the memory usage will
accumulate while running.
        
I've also changed an internal structure element name from the previous
patch as that was originally based on a time but really it's based on frame.


Modified: icecast/trunk/libshout/src/theora.c
===================================================================
--- icecast/trunk/libshout/src/theora.c	2006-05-20 23:10:07 UTC (rev 11415)
+++ icecast/trunk/libshout/src/theora.c	2006-05-22 00:32:49 UTC (rev 11416)
@@ -39,7 +39,8 @@
 	uint32_t granule_shift;
 	double per_frame;
     uint64_t start_frame;
-    int get_start_time;
+    int initial_frames;
+    int get_start_frame;
 } theora_data_t;
 
 /* -- local prototypes -- */
@@ -71,6 +72,7 @@
 	codec->read_page = read_theora_page;
 	codec->free_data = free_theora_data;
 	codec->headers = 1;
+    theora_data->initial_frames = 0;
 
 	return SHOUTERR_SUCCESS;
 }
@@ -94,25 +96,28 @@
         {
 			theora_data->granule_shift = theora_ilog(theora_data->ti.keyframe_frequency_force - 1);
             theora_data->per_frame = (double)theora_data->ti.fps_denominator / theora_data->ti.fps_numerator * 1000000;
-            theora_data->get_start_time = 1;
+            theora_data->get_start_frame = 1;
 		}
 
 		return SHOUTERR_SUCCESS;
 	}
 
+    while (ogg_stream_packetout(&codec->os, &packet) > 0)
+    {
+        if (theora_data->get_start_frame)
+            theora_data->initial_frames++;
+    }
 	if (granulepos > 0 && codec->headers >= 3)
     {
         iframe = granulepos >> theora_data->granule_shift;
         pframe = granulepos - (iframe << theora_data->granule_shift);
 
-        if (theora_data->get_start_time)
+        if (theora_data->get_start_frame)
         {
-            /* may need to improve mechanism for working out the start time, this
-             * doesn't include the first set of pages */
-
-            theora_data->start_frame = iframe + pframe;
+            /* work out the real start frame, which may not be 0 */
+            theora_data->start_frame = iframe + pframe - theora_data->initial_frames;
             codec->senttime = 0;
-            theora_data->get_start_time = 0;
+            theora_data->get_start_frame = 0;
         }
         else
         {



More information about the commits mailing list