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

conrad at svn.annodex.net conrad at svn.annodex.net
Mon Oct 27 01:04:41 PDT 2008


Author: conrad
Date: 2008-10-27 01:04:40 -0700 (Mon, 27 Oct 2008)
New Revision: 3739

Modified:
   libannodex/trunk/src/importers/anx_import_ogg.c
Log:
anx_ogg_importer: for tracks with granuleshift, estimate the start granule as
1 granule before the time of the keyframe. Should be correct for Theora
(ie. 1 frame) and usually 1ms for CMML.


Modified: libannodex/trunk/src/importers/anx_import_ogg.c
===================================================================
--- libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-26 10:43:45 UTC (rev 3738)
+++ libannodex/trunk/src/importers/anx_import_ogg.c	2008-10-27 08:04:40 UTC (rev 3739)
@@ -841,7 +841,8 @@
  * are found, granuleinfo_update_state will set the state to FILTER and the
  * loop will end.
  *
- * NOTE THAT this starts scanning from the specified startpos for the media.
+ * Note that in anxogg_setup() below, this packet reading callback is
+ * used after seeking to the specified startpos for the media.
  */
 static int
 read_page_granuleinfo (OGGZ * oggz, const ogg_page * og, long serialno,
@@ -861,6 +862,7 @@
 #endif
 
   granulepos = ogg_page_granulepos ((ogg_page *)og);
+  if (granulepos == -1) return OGGZ_STOP_OK;
 
 #ifdef DEBUG
   fprintf(aod->df, " granulepos %llx cmml_serialno %d", granulepos, 
@@ -905,10 +907,13 @@
     track = &(aot->source_track);
     
     /* Slurp in granuleinfo */
-    if (aot->need_keygranule && granulepos != -1) {
+    if (aot->need_keygranule) {
       iframe = granulepos >> track->granuleshift;
       pframe = granulepos - (iframe << track->granuleshift);
 
+      if (iframe > 0 && track->basegranule == 0.0)
+        track->basegranule = (iframe-1) << track->granuleshift;
+
 #if 1
       /* XXX: vaguely similar reasoning to CMML above */
       start_time = aod->anx_source->start_time;
@@ -927,7 +932,7 @@
       granulepos = (iframe + pframe);
       aot->keygranule = iframe << track->granuleshift;
       aot->need_keygranule = 0;
-      
+
       offset = gp_to_time (aod->oggz, serialno, aot->keygranule);
       aot->keygranule_time = offset;
       if (aod->min_granule_seek == 0.0 || offset < aod->min_granule_seek) {



More information about the commits mailing list