[xiph-commits] r9444 - trunk/vorbis-tools/ogginfo

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Mon Jun 13 06:54:26 PDT 2005


Author: giles
Date: 2005-06-13 06:54:22 -0700 (Mon, 13 Jun 2005)
New Revision: 9444

Modified:
   trunk/vorbis-tools/ogginfo/ogginfo2.c
   trunk/vorbis-tools/ogginfo/theora.c
   trunk/vorbis-tools/ogginfo/theora.h
Log:
Fix theora length calculation (can't use granpos directly, need to do 
keyframe shifting trickery).

Fix comment parser, which was broken, then became more broken, and now 
works without crashing.


Modified: trunk/vorbis-tools/ogginfo/ogginfo2.c
===================================================================
--- trunk/vorbis-tools/ogginfo/ogginfo2.c	2005-06-12 18:43:11 UTC (rev 9443)
+++ trunk/vorbis-tools/ogginfo/ogginfo2.c	2005-06-13 13:54:22 UTC (rev 9444)
@@ -156,7 +156,8 @@
     va_end(ap);
 }
 
-static void check_xiph_comment(stream_processor *stream, int i, char *comment)
+static void check_xiph_comment(stream_processor *stream, int i, char *comment,
+    int comment_length)
 {
     char *sep = strchr(comment, '=');
     char *decoded;
@@ -188,10 +189,10 @@
 
     val = comment;
 
-    j = sep-comment[i]+1;
-    while(j < comment[i])
+    j = sep-comment+1;
+    while(j < comment_length)
     {
-        remaining = comment[i] - j;
+        remaining = comment_length - j;
         if((val[j] & 0x80) == 0)
             bytes = 1;
         else if((val[j] & 0x40) == 0x40) {
@@ -306,7 +307,6 @@
     ogg_packet packet;
     misc_theora_info *inf = stream->data;
     int i, header=0;
-    int k;
 
     ogg_stream_pagein(&stream->os, page);
     if(inf->doneheaders < 3)
@@ -386,7 +386,8 @@
 
                 for(i=0; i < inf->tc.comments; i++) {
                     char *comment = inf->tc.user_comments[i];
-		    check_xiph_comment(stream, i, comment);
+		    check_xiph_comment(stream, i, comment, 
+		            inf->tc.comment_lengths[i]);
 		}
 	    }
 	}
@@ -418,7 +419,9 @@
     double bitrate, time;
 
     /* This should be lastgranulepos - startgranulepos, or something like that*/
-    time = (double)inf->lastgranulepos / 
+    ogg_int64_t iframe=inf->lastgranulepos>>inf->ti.granule_shift;
+    ogg_int64_t pframe=inf->lastgranulepos-(iframe<<inf->ti.granule_shift);
+    time = (double)(iframe+pframe) /
 	((float)inf->ti.fps_numerator/(float)inf->ti.fps_denominator);
     minutes = (long)time / 60;
     seconds = (long)time - minutes*60;
@@ -512,7 +515,8 @@
 
                 for(i=0; i < inf->vc.comments; i++) {
                     char *comment = inf->vc.user_comments[i];
-		    check_xiph_comment(stream, i, comment);
+		    check_xiph_comment(stream, i, comment, 
+		            inf->vc.comment_lengths[i]);
 		}
             }
         }

Modified: trunk/vorbis-tools/ogginfo/theora.c
===================================================================
--- trunk/vorbis-tools/ogginfo/theora.c	2005-06-12 18:43:11 UTC (rev 9443)
+++ trunk/vorbis-tools/ogginfo/theora.c	2005-06-13 13:54:22 UTC (rev 9444)
@@ -96,7 +96,7 @@
   ci->quality=ret;
 
   theora_read(opb,5,&ret);
-  ci->keyframe_frequency_force=1<<ret;
+  ci->granule_shift = ret;
 
   theora_read(opb,2,&ret);
   ci->pixelformat=ret;

Modified: trunk/vorbis-tools/ogginfo/theora.h
===================================================================
--- trunk/vorbis-tools/ogginfo/theora.h	2005-06-12 18:43:11 UTC (rev 9443)
+++ trunk/vorbis-tools/ogginfo/theora.h	2005-06-13 13:54:22 UTC (rev 9444)
@@ -82,14 +82,14 @@
   unsigned char version_minor;
   unsigned char version_subminor;
 
+  int granule_shift;
+
   void *codec_setup;
 
   /* encode only */
   int           dropframes_p;
   int           keyframe_auto_p;
   ogg_uint32_t  keyframe_frequency;
-  ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
-                                              get granpos shift correct */
   ogg_uint32_t  keyframe_data_target_bitrate;
   ogg_int32_t   keyframe_auto_threshold;
   ogg_uint32_t  keyframe_mindistance;
@@ -181,3 +181,5 @@
 extern int theora_decode_header(theora_info *ci, theora_comment *cc,
                                 ogg_packet *op);
 
+void theora_info_clear(theora_info *c);
+void theora_comment_clear(theora_comment *tc);



More information about the commits mailing list