[xiph-commits] r12448 - experimental/giles/rogg

giles at svn.xiph.org giles at svn.xiph.org
Fri Feb 9 13:24:35 PST 2007


Author: giles
Date: 2007-02-09 13:24:33 -0800 (Fri, 09 Feb 2007)
New Revision: 12448

Modified:
   experimental/giles/rogg/rogg.c
   experimental/giles/rogg/rogg.h
   experimental/giles/rogg/rogg_eosfix.c
   experimental/giles/rogg/rogg_pagedump.c
Log:
Misc updates: fix a typo, api change to make way for packet reader.


Modified: experimental/giles/rogg/rogg.c
===================================================================
--- experimental/giles/rogg/rogg.c	2007-02-09 17:14:39 UTC (rev 12447)
+++ experimental/giles/rogg/rogg.c	2007-02-09 21:24:33 UTC (rev 12448)
@@ -92,7 +92,7 @@
 }
 
 /* calculate the length of the page starting at p */
-void rogg_get_length(unsigned char *p, int *length)
+void rogg_page_get_length(unsigned char *p, int *length)
 {
   int i;
   int segments;
@@ -125,7 +125,7 @@
 }
 
 /* parse out the header fields of the page starting at p */
-void rogg_parse_header(unsigned char *p, rogg_page_header *header)
+void rogg_page_parse(unsigned char *p, rogg_page_header *header)
 {
   header->capture = p;
   header->version = p[ROGG_OFFSET_VERSION];
@@ -142,7 +142,7 @@
   header->bos = (header->flags & 0x02) ? 1 : 0;
   header->eos = (header->flags & 0x04) ? 1 : 0;
 
-  rogg_get_length(p, &header->length);
+  rogg_page_get_length(p, &header->length);
 }
 
 /* helper lookup table for the crc */
@@ -213,13 +213,13 @@
   0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
 
 /* recompute and store a new crc on the page starting at p */
-void rogg_update_crc(unsigned char *p)
+void rogg_page_update_crc(unsigned char *p)
 {
   uint32_t crc = 0;
   unsigned char *q = p;
   int i, length;
 
-  rogg_get_length(p, &length);
+  rogg_page_get_length(p, &length);
   
   /* calculate the CRC with the CRC header element zeroed */
   p[ROGG_OFFSET_CRC + 0] = 0;

Modified: experimental/giles/rogg/rogg.h
===================================================================
--- experimental/giles/rogg/rogg.h	2007-02-09 17:14:39 UTC (rev 12447)
+++ experimental/giles/rogg/rogg.h	2007-02-09 21:24:33 UTC (rev 12448)
@@ -63,6 +63,16 @@
 #define ROGG_OFFSET_SEGMENTS 26
 #define ROGG_OFFSET_LACING 27
 
+/* parsed packet struct */
+typedef struct _rogg_packet rogg_packet;
+struct _rogg_packet {
+  unsigned char **data;	/* array of pointers to body data sections */
+  /* framing data derived from the page header(s) */
+  unsigned int *lengths;	/* array of data section lengths */
+  uint64_t granulepos;		/* timestamp, -1 if unknown */
+  int bos, eos;			/* beginning and end flags */
+};
+
 /* little endian i/o */
 void rogg_write_uint64(unsigned char *p, uint64_t v);
 void rogg_write_uint32(unsigned char *p, uint32_t v);
@@ -75,12 +85,12 @@
 unsigned char *rogg_scan(unsigned char *p, int len);
 
 /* calculate the length of the page starting at p */
-void rogg_get_length(unsigned char *p, int *length);
+void rogg_page_get_length(unsigned char *p, int *length);
 
 /* parse out the header fields of the page starting at p */
-void rogg_parse_header(unsigned char *p, rogg_page_header *header);
+void rogg_page_parse(unsigned char *p, rogg_page_header *header);
 
 /* recompute and store a new crc on the page starting at p */
-void rogg_update_crc(unsigned char *p);
+void rogg_page_update_crc(unsigned char *p);
 
 #endif /* _ROGG_H */

Modified: experimental/giles/rogg/rogg_eosfix.c
===================================================================
--- experimental/giles/rogg/rogg_eosfix.c	2007-02-09 17:14:39 UTC (rev 12447)
+++ experimental/giles/rogg/rogg_eosfix.c	2007-02-09 21:24:33 UTC (rev 12448)
@@ -55,7 +55,7 @@
   fprintf(out, " Ogg page serial %08x seq %d (%5d bytes)",
 	header->serialno, header->sequenceno, header->length);
   fprintf(out, (header->continued) ? " c" : "  ");
-  fprintf(out, " %lld", header->granulepos);
+  fprintf(out, " %lld", (long long int)header->granulepos);
   fprintf(out, (header->bos) ? " bos" : "");
   fprintf(out, (header->eos) ? " eos" : "");
   fprintf(out, "\n");
@@ -123,12 +123,12 @@
   rogg_page_header header;
 
   while (ref != NULL) {
-    rogg_parse_header(ref->last, &header);
+    rogg_page_parse(ref->last, &header);
     if (!header.eos) {
 	fprintf(stderr, "setting missing eos on stream %08x\n",
 	  header.serialno);
 	ref->last[ROGG_OFFSET_FLAGS] |= 0x04;
-	rogg_update_crc(ref->last);
+	rogg_page_update_crc(ref->last);
     }
     ref = ref->next;
   }
@@ -156,7 +156,7 @@
     p = mmap(0, s.st_size, PROT_READ|PROT_WRITE,
 	MAP_SHARED, f, 0);
     if (p == NULL) {
-	fprintf(stderr, "could mmap '%s'\n", argv[i]);
+	fprintf(stderr, "couldn't mmap '%s'\n", argv[i]);
 	close(f);
 	continue;
     }
@@ -168,18 +168,18 @@
 	fprintf(stdout, "couldn't find ogg data!\n");
     } else {
       if (q > p) {
-	fprintf(stdout, "Skipped %d garbage bytes at the start\n", q-p);
+	fprintf(stdout, "Skipped %d garbage bytes at the start\n", (int)(q-p));
       } 
       while (q < e) {
 	o = rogg_scan(q, e-q); /* find the next Ogg page */
 	if (o > q) {
-	  fprintf(stdout, "Hole in data! skipped %d bytes\n", o - q);
+	  fprintf(stdout, "Hole in data! skipped %d bytes\n", (int)(o-q));
 	   q = o;
 	} else if (o == NULL) {
-	  fprintf(stdout, "Skipped %d garbage bytes as the end\n", e-q);
+	  fprintf(stdout, "Skipped %d garbage bytes as the end\n", (int)(e-q));
 	  break;
 	}
-	rogg_parse_header(q, &header);
+	rogg_page_parse(q, &header);
 #ifdef VERBOSE
 	print_header_info(stdout, &header);
 #endif
@@ -187,7 +187,7 @@
 	if (header.eos) {
 	  /* unset any eos flags */
 	  q[ROGG_OFFSET_FLAGS] &= ~0x04;
-	  rogg_update_crc(q);
+	  rogg_page_update_crc(q);
 	  fprintf(stderr, "Removed eos flag on stream %08x\n", 
 		header.serialno);
         }

Modified: experimental/giles/rogg/rogg_pagedump.c
===================================================================
--- experimental/giles/rogg/rogg_pagedump.c	2007-02-09 17:14:39 UTC (rev 12447)
+++ experimental/giles/rogg/rogg_pagedump.c	2007-02-09 21:24:33 UTC (rev 12448)
@@ -76,7 +76,7 @@
     p = mmap(0, s.st_size, PROT_READ|PROT_WRITE,
 	MAP_SHARED, f, 0);
     if (p == NULL) {
-	fprintf(stderr, "could mmap '%s'\n", argv[i]);
+	fprintf(stderr, "couldn't mmap '%s'\n", argv[i]);
 	close(f);
 	continue;
     }
@@ -98,7 +98,7 @@
 	  fprintf(stdout, "Skipped %d garbage bytes as the end\n", e-q);
 	  break;
 	}
-	rogg_parse_header(q, &header);
+	rogg_page_parse(q, &header);
 	print_header_info(stdout, &header);
 	q += header.length;
       }



More information about the commits mailing list