[xiph-commits] r3743 - libannodex/trunk/src/importers

conrad at svn.annodex.net conrad at svn.annodex.net
Mon Oct 27 01:45:09 PDT 2008


Author: conrad
Date: 2008-10-27 01:45:09 -0700 (Mon, 27 Oct 2008)
New Revision: 3743

Modified:
   libannodex/trunk/src/importers/anx_import_ogg.c
Log:
anx_import_ogg: cleanup: create anx_ogg_packet_new() util function, use
in reader, and pull anx_ogg_packet_free() to top of file


Modified: libannodex/trunk/src/importers/anx_import_ogg.c
===================================================================
--- libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-27 08:45:04 UTC (rev 3742)
+++ libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-27 08:45:09 UTC (rev 3743)
@@ -277,6 +277,31 @@
   return strcpy (ret, s);
 }
 
+static AnxOggPacket *
+anxogg_packet_new (ogg_packet * op, AnxSourceTrack * source_track,
+                   double current_time)
+{
+  AnxOggPacket * aop;
+
+  aop = anx_malloc (sizeof (AnxOggPacket));
+  aop->length = op->bytes;
+  aop->data = anx_malloc (op->bytes);
+  aop->granulepos = op->granulepos;
+  aop->current_time = current_time;
+  aop->source_track = source_track;
+  aop->eos = op->e_o_s;
+
+  return aop;
+}
+
+static AnxOggPacket *
+anxogg_packet_free (AnxOggPacket * aop)
+{
+  anx_free (aop->data);
+  anx_free (aop);
+  return NULL;
+}
+
 /***********************************************************
  * Setup
  */
@@ -1083,20 +1108,9 @@
 #ifdef DEBUG
     fprintf (aod->df, "anxogg::read_packet_data: no, copy out\n");
 #endif
-    aop = anx_malloc (sizeof (AnxOggPacket));
-    aop->length = op->bytes;
-    aop->data = anx_malloc (op->bytes);
-    aop->granulepos = op->granulepos;
-    aop->current_time = ((double)oggz_tell_units (oggz)) / SUBSECONDS;
-    aop->source_track = track;
-    aop->eos = op->e_o_s;
 
-#if 0
-    if (aod->nr_headers_remaining == 0 && aop->granulepos != -1) {
-      aop->granulepos -= track->start_granule;
-    }
-#endif
-
+    aop = anxogg_packet_new (op, track,
+                             ((double)oggz_tell_units(oggz)) / SUBSECONDS);
     memcpy (aop->data, op->packet, op->bytes);
     
     aod->media_packets = anx_list_append (aod->media_packets, aop);
@@ -1134,14 +1148,6 @@
   return OGGZ_STOP_OK;
 }
 
-static AnxOggPacket *
-anxogg_packet_free (AnxOggPacket * aop)
-{
-  anx_free (aop->data);
-  anx_free (aop);
-  return NULL;
-}
-
 static long
 anxogg_read (AnxSource * media, char * buf, long n, long bound)
 {



More information about the commits mailing list