[xiph-commits] r2883 - liboggz/trunk/src/tools

conrad at svn.annodex.net conrad at svn.annodex.net
Sun Jun 10 02:39:06 PDT 2007


Author: conrad
Date: 2007-06-10 02:38:09 -0700 (Sun, 10 Jun 2007)
New Revision: 2883

Modified:
   liboggz/trunk/src/tools/oggz_tools.c
   liboggz/trunk/src/tools/oggz_tools.h
   liboggz/trunk/src/tools/oggzdump.c
   liboggz/trunk/src/tools/oggzinfo.c
Log:
generalize granulepos printing in oggz tools, use in oggzdump and oggzinfo


Modified: liboggz/trunk/src/tools/oggz_tools.c
===================================================================
--- liboggz/trunk/src/tools/oggz_tools.c	2007-06-08 08:34:00 UTC (rev 2882)
+++ liboggz/trunk/src/tools/oggz_tools.c	2007-06-10 09:38:09 UTC (rev 2883)
@@ -43,6 +43,12 @@
 #define snprintf _snprintf
 #endif  
 
+#ifdef HAVE_INTTYPES_H
+#  include <inttypes.h>
+#else
+#  define PRId64 "I64d"
+#endif
+
 static  ogg_uint32_t
 _le_32 (ogg_uint32_t i)
 {
@@ -346,6 +352,25 @@
   return fprintf (stream, "%s%02d:%02d:%06.3f", sign, hrs, min, sec);
 }
 
+int
+ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
+                      ogg_int64_t granulepos)
+{
+  int ret, granuleshift = oggz_get_granuleshift (oggz, serialno);
+
+  if (granuleshift < 1) {
+    ret = fprintf (stream, "%" PRId64, granulepos);
+  } else {
+    ogg_int64_t iframe, pframe;
+    iframe = granulepos >> granuleshift;
+    pframe = granulepos - (iframe << granuleshift);
+
+    ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
+  }
+
+  return ret;
+}
+
 void
 ot_init (void)
 {

Modified: liboggz/trunk/src/tools/oggz_tools.h
===================================================================
--- liboggz/trunk/src/tools/oggz_tools.h	2007-06-08 08:34:00 UTC (rev 2882)
+++ liboggz/trunk/src/tools/oggz_tools.h	2007-06-10 09:38:09 UTC (rev 2883)
@@ -52,6 +52,9 @@
 
 int ot_fprint_time (FILE * stream, double seconds);
 
+int ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
+                          ogg_int64_t granulepos);
+
 /*
  * Tool initialization function. Sets stdin, stdio to binary on windows etc.
  * Call this at the beginning of main().

Modified: liboggz/trunk/src/tools/oggzdump.c
===================================================================
--- liboggz/trunk/src/tools/oggzdump.c	2007-06-08 08:34:00 UTC (rev 2882)
+++ liboggz/trunk/src/tools/oggzdump.c	2007-06-10 09:38:09 UTC (rev 2883)
@@ -244,7 +244,6 @@
   ODData * oddata = (ODData *) user_data;
   ogg_int64_t units;
   double time_offset;
-  int granuleshift;
 
   if (oddata->hide_offset) {
     fprintf (outfile, "oOo");
@@ -261,23 +260,14 @@
   fprintf (outfile, ": serialno %010ld, ",
 	   oddata->hide_serialno ? -1 : serialno);
 
+  fprintf (outfile, "granulepos ");
   if (oddata->hide_granulepos) {
-    fprintf (outfile, "granulepos gGg,");
+    fprintf (outfile, "gGg");
   } else {
-    granuleshift = oggz_get_granuleshift (oggz, serialno);
-    if (granuleshift < 1) {
-      fprintf (outfile, "granulepos %" PRId64 ",", op->granulepos);
-    } else {
-      ogg_int64_t iframe, pframe;
-      iframe = op->granulepos >> granuleshift;
-      pframe = op->granulepos - (iframe << granuleshift);
-
-      fprintf (outfile, "granulepos %" PRId64 "|%" PRId64 ",",
-	       iframe, pframe);
-    }
+    ot_fprint_granulepos (outfile, oggz, serialno, op->granulepos);
   }
 
-  fprintf (outfile, " packetno %" PRId64,
+  fprintf (outfile, ", packetno %" PRId64,
 	   oddata->hide_packetno ? -1 : op->packetno);
 
   if (op->b_o_s) {

Modified: liboggz/trunk/src/tools/oggzinfo.c
===================================================================
--- liboggz/trunk/src/tools/oggzinfo.c	2007-06-08 08:34:00 UTC (rev 2882)
+++ liboggz/trunk/src/tools/oggzinfo.c	2007-06-10 09:38:09 UTC (rev 2883)
@@ -93,6 +93,7 @@
 typedef void (*OI_TrackFunc) (OI_Info * info, OI_TrackInfo * oit, long serialno);
 
 struct _OI_Info {
+  OGGZ * oggz;
   OggzTable * tracks;
   ogg_int64_t duration;
   long length_total;
@@ -217,16 +218,18 @@
 }
 
 static void
-ot_fisbone_print(OI_TrackInfo *oit) {
+ot_fisbone_print(OI_Info * info, OI_TrackInfo *oit) {
 
   char *messages, *token;
   
   if (oit->has_fisbone) {
-    printf("\n\tExtra information from Ogg Skeleton\n");
-    printf("\tserialno: %010d\n", oit->fbInfo.serial_no);
+    printf("\n\tExtra information from Ogg Skeleton track:\n");
+    /*printf("\tserialno: %010d\n", oit->fbInfo.serial_no);*/
     printf("\tNumber of header packets: %d\n", oit->fbInfo.nr_header_packet);
     printf("\tGranule rate: %.2f\n", (double)oit->fbInfo.granule_rate_n/oit->fbInfo.granule_rate_d);
-    printf("\tStart granule: %" PRId64 "\n", oit->fbInfo.start_granule);
+    printf("\tStart granule: ");
+    ot_fprint_granulepos(stdout, info->oggz, oit->fbInfo.serial_no, oit->fbInfo.start_granule);
+    printf ("\n");
     printf("\tPreroll: %d\n", oit->fbInfo.preroll);
     messages = token = _ogg_calloc(oit->fbInfo.current_header_size+1, sizeof(char));
     strcpy(messages, oit->fbInfo.message_header_fields);
@@ -282,7 +285,7 @@
     ot_fishead_print(oit);
   }
   if (show_extra_skeleton_info && oit->has_fisbone) {
-    ot_fisbone_print(oit);
+    ot_fisbone_print(info, oit);
   }
 
  }
@@ -572,6 +575,7 @@
       return (1);
     }
 
+    info.oggz = oggz;
     info.tracks = oggz_table_new ();
     info.length_total = 0;
     
@@ -581,8 +585,6 @@
     
     oi_pass2 (oggz, &info);
     
-    oggz_close (oggz);
-    
     /* Print summary information */
     if (many_files)
       printf ("Filename: %s\n", infilename);
@@ -607,6 +609,8 @@
     oggzinfo_apply (oit_delete, &info);
     oggz_table_delete (info.tracks);
 
+    oggz_close (oggz);
+    
     if (optind < argc) puts (SEP);
   }
 



More information about the commits mailing list