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

conrad at svn.annodex.net conrad at svn.annodex.net
Wed Oct 29 04:06:38 PDT 2008


Author: conrad
Date: 2008-10-29 04:06:38 -0700 (Wed, 29 Oct 2008)
New Revision: 3753

Modified:
   libannodex/trunk/src/importers/anx_import_ogg.c
Log:
anx_import_ogg: update basegranules while handling pre-start keyframe region,
and fix timing in general (remove SUBSECONDS multiplier)


Modified: libannodex/trunk/src/importers/anx_import_ogg.c
===================================================================
--- libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-29 11:06:33 UTC (rev 3752)
+++ libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-29 11:06:38 UTC (rev 3753)
@@ -275,7 +275,8 @@
 
   granule = gp_to_granule (oggz, serialno, granulepos);
 
-  return (double)(granule * gr_d) / ((double)gr_n * SUBSECONDS);
+  //return (double)(granule * gr_d) / ((double)gr_n * SUBSECONDS);
+  return (double)(granule * gr_d) / ((double)gr_n);
 }
 
 static char *
@@ -505,8 +506,8 @@
   AnxOggData * aod = (AnxOggData *)user_data;
   AnxOggTrack * aot = NULL;
   AnxSourceTrack * track = NULL;
-  AnxOggPacket * aop;
-  int granuleshift, iframe;
+  AnxOggPacket * aop, * prev_iframe_aop;
+  int granuleshift, iframe, prev_iframe, prev_pframe;
   double start_time, at_time;
 
   aot = (AnxOggTrack *) oggz_table_lookup (aod->tracks, serialno);
@@ -519,7 +520,7 @@
   /* If we are past the start time, then queue this packet for delivery
    * and set state to STATE_DATA */
   start_time = aod->anx_source->start_time;
-  at_time = gp_to_time (aod->oggz, serialno, op->granulepos);
+  at_time = gp_to_time (aod->oggz, serialno, oggz_tell_granulepos(oggz));
   if (at_time >= start_time) {
     aop = anxogg_packet_new (op, track, at_time);
     aod->delivery_queue = anx_list_append (aod->delivery_queue, aop);
@@ -528,12 +529,23 @@
   }
 
   granuleshift = oggz_get_granuleshift(oggz, serialno);
-  /* No need to cache packets of tracks without granuleshift */
-  if (granuleshift == 0) return OGGZ_CONTINUE;
+  /* No need to cache packets of tracks without granuleshift, but record
+   * their basegranule */
+  if (granuleshift == 0) {
+    track->basegranule = oggz_tell_granulepos(oggz);
+    return OGGZ_CONTINUE;
+  }
 
   /* If this is a keyframe, clear the glue_packets queue for this track */
   iframe = op->granulepos >> granuleshift;
   if (op->granulepos != -1 && (iframe << granuleshift) == op->granulepos) {
+    /* First set the basegranule to that of the last packet in the previous
+     * GOP */
+    prev_iframe_aop = aot->glue_packets->data;
+    prev_iframe = prev_iframe_aop->granulepos >> granuleshift;
+    prev_pframe = iframe - prev_iframe - 1;
+    track->basegranule = (prev_iframe << granuleshift) | prev_pframe;
+
     anx_list_free_with (aot->glue_packets, anxogg_packet_free);
     aot->glue_packets = NULL;
   }
@@ -1105,6 +1117,7 @@
   AnxSource * m = aod->anx_source;
   AnxSourceTrack * track = NULL;
   anx_int64_t gp = oggz_tell_granulepos(oggz);
+  double at_time;
   
   op->granulepos = gp;
 
@@ -1126,7 +1139,6 @@
 
   if (!op->b_o_s) {
     if (aod->cmml_serialno != -1 && serialno == aod->cmml_serialno) {
-      double at_time;
 
 #ifdef DEBUG
       fprintf (aod->df, "aod->cmml_serialno %010ld, op->granulepos %lld\n",
@@ -1136,7 +1148,7 @@
       if (gp == -1) {
 	      return OGGZ_STOP_ERR;
       }
-      at_time = gp_to_time (aod->oggz, serialno, gp);
+      at_time = gp_to_time (aod->oggz, serialno, oggz_tell_granulepos(oggz));
       
 #ifdef DEBUG
       {
@@ -1201,8 +1213,8 @@
     fprintf (aod->df, "anxogg::read_packet_data: no, copy out\n");
 #endif
 
-    aop = anxogg_packet_new (op, track,
-                             ((double)oggz_tell_units(oggz)) / SUBSECONDS);
+    at_time = gp_to_time (aod->oggz, serialno, oggz_tell_granulepos(oggz));
+    aop = anxogg_packet_new (op, track, at_time);
     aod->delivery_queue = anx_list_append (aod->delivery_queue, aop);
     
 #if 0



More information about the commits mailing list