Index: include/theora/theora.h
===================================================================
--- include/theora/theora.h	(Revision 13808)
+++ include/theora/theora.h	(Arbeitskopie)
@@ -385,7 +385,7 @@
  *                    encoding mode.*/
 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
 /**Sets the speed level.
- * By default, the slowest speed (0) is used.
+ * By default a speed value of 1 is used.
  *
  * \param[in] buf int: The new encoding speed level.
  *                      0 is slowest, larger values use less CPU.
Index: tests/granulepos.c
===================================================================
--- tests/granulepos.c	(Revision 13808)
+++ tests/granulepos.c	(Arbeitskopie)
@@ -109,10 +109,10 @@
     last_granule = op.granulepos;
     keyframe = op.granulepos >> shift;
     keydist = op.granulepos - (keyframe << shift);
-    if ((keyframe + keydist) != frame)
-      FAIL ("encoder granulepos does not map to the correct frame index");
+    if ((keyframe + keydist) != frame + 1)
+      FAIL ("encoder granulepos does not map to the correct frame number");
     tframe = theora_granule_frame (&th, op.granulepos);
-    if (tframe != frame)
+    if (tframe != frame + 1)
       FAIL ("theora_granule_frame returned incorrect results");
 #if DEBUG
     printf("++ frame %d granulepos %lld %d:%d %d %.3lfs\n", 
Index: lib/internal.h
===================================================================
--- lib/internal.h	(Revision 13808)
+++ lib/internal.h	(Arbeitskopie)
@@ -41,12 +41,12 @@
 # endif
 
 /*This library's version.*/
-# define OC_VENDOR_STRING "Xiph.Org libTheora I 20060526 3 2 0"
+# define OC_VENDOR_STRING "Xiph.Org libTheora I 20070915 3 2 1"
 
 /*Theora bitstream version.*/
 # define TH_VERSION_MAJOR (3)
 # define TH_VERSION_MINOR (2)
-# define TH_VERSION_SUB   (0)
+# define TH_VERSION_SUB   (1)
 
 /*A keyframe.*/
 #define OC_INTRA_FRAME (0)
Index: lib/enc/encoder_toplevel.c
===================================================================
--- lib/enc/encoder_toplevel.c	(Revision 13808)
+++ lib/enc/encoder_toplevel.c	(Arbeitskopie)
@@ -1126,8 +1126,8 @@
   cpi->packetflag=1;
 
   t->granulepos=
-    ((cpi->CurrentFrame-cpi->LastKeyFrame-1)<<cpi->pb.keyframe_granule_shift)+
-    cpi->LastKeyFrame-1;
+    ((cpi->CurrentFrame - cpi->LastKeyFrame)<<cpi->pb.keyframe_granule_shift)+
+    cpi->LastKeyFrame - 1;
 
   return 0;
 }
@@ -1348,6 +1348,7 @@
   memset(th,0,sizeof(*th));
 }
 
+
 /* returns, in seconds, absolute time of current packet in given
    logical stream */
 static double theora_encode_granule_time(theora_state *th,
Index: lib/dec/state.c
===================================================================
--- lib/dec/state.c	(Revision 13808)
+++ lib/dec/state.c	(Arbeitskopie)
@@ -1182,7 +1182,16 @@
     ogg_int64_t pframe;
     iframe=_granpos>>state->info.keyframe_granule_shift;
     pframe=_granpos-(iframe<<state->info.keyframe_granule_shift);
-    return iframe+pframe;
+
+    /* 3.2.0 streams mark the frame index instead of the frame count
+     * this was changed with stream version 3.2.1 */ 
+    if(state->info.version_subminor == 0
+       && state->info.version_minor == 2
+       && state->info.version_major == 3) {
+      return iframe+pframe + 1;
+    } else {
+      return iframe+pframe;
+    }
   }
   return -1;
 }
@@ -1191,12 +1200,7 @@
   oc_theora_state *state;
   state=(oc_theora_state *)_encdec;
   if(_granpos>=0){
-    ogg_int64_t iframe;
-    ogg_int64_t pframe;
-    iframe=_granpos>>state->info.keyframe_granule_shift;
-    pframe=_granpos-(iframe<<state->info.keyframe_granule_shift);
-    return (iframe+pframe)*(
-     (double)state->info.fps_denominator/state->info.fps_numerator);
+      return th_granule_frame(_encdec, _granpos)*((double)state->info.fps_denominator/state->info.fps_numerator);
   }
   return -1;
 }

