[xiph-cvs] cvs commit: ogg/src framing.c

Monty xiphmont at xiph.org
Fri Nov 23 23:49:33 PST 2001



xiphmont    01/11/23 23:49:32

  Modified:    include/ogg ogg.h
               src      framing.c
  Log:
  Added suggested public API exposure for regenerating checksum.

Revision  Changes    Path
1.12      +3 -1      ogg/include/ogg/ogg.h

Index: ogg.h
===================================================================
RCS file: /usr/local/cvsroot/ogg/include/ogg/ogg.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ogg.h	2001/05/24 01:04:36	1.11
+++ ogg.h	2001/11/24 07:49:31	1.12
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: toplevel libogg include
- last mod: $Id: ogg.h,v 1.11 2001/05/24 01:04:36 xiphmont Exp $
+ last mod: $Id: ogg.h,v 1.12 2001/11/24 07:49:31 xiphmont Exp $
 
  ********************************************************************/
 #ifndef _OGG_H
@@ -154,6 +154,8 @@
 extern int      ogg_stream_reset(ogg_stream_state *os);
 extern int      ogg_stream_destroy(ogg_stream_state *os);
 extern int      ogg_stream_eos(ogg_stream_state *os);
+
+extern void     ogg_page_checksum_set(ogg_page *og);
 
 extern int      ogg_page_version(ogg_page *og);
 extern int      ogg_page_continued(ogg_page *og);

1.19      +24 -16    ogg/src/framing.c

Index: framing.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/framing.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- framing.c	2001/11/24 06:19:46	1.18
+++ framing.c	2001/11/24 07:49:32	1.19
@@ -12,7 +12,7 @@
 
  function: code raw [Vorbis] packets into framed OggSquish stream and
            decode Ogg streams back into raw packets
- last mod: $Id: framing.c,v 1.18 2001/11/24 06:19:46 xiphmont Exp $
+ last mod: $Id: framing.c,v 1.19 2001/11/24 07:49:32 xiphmont Exp $
 
  note: The CRC code is directly derived from public domain code by
  Ross Williams (ross at guest.adelaide.edu.au).  See docs/framing.html
@@ -244,19 +244,27 @@
 /* Direct table CRC; note that this will be faster in the future if we
    perform the checksum silmultaneously with other copies */
 
-static void _os_checksum(ogg_page *og){
-  ogg_uint32_t crc_reg=0;
-  int i;
-
-  for(i=0;i<og->header_len;i++)
-    crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];
-  for(i=0;i<og->body_len;i++)
-    crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]];
-  
-  og->header[22]=crc_reg&0xff;
-  og->header[23]=(crc_reg>>8)&0xff;
-  og->header[24]=(crc_reg>>16)&0xff;
-  og->header[25]=(crc_reg>>24)&0xff;
+void ogg_page_checksum_set(ogg_page *og){
+  if(og){
+    ogg_uint32_t crc_reg=0;
+    int i;
+
+    /* safety; needed for API behavior, but not framing code */
+    og->header[22]=0;
+    og->header[23]=0;
+    og->header[24]=0;
+    og->header[25]=0;
+    
+    for(i=0;i<og->header_len;i++)
+      crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];
+    for(i=0;i<og->body_len;i++)
+      crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]];
+    
+    og->header[22]=crc_reg&0xff;
+    og->header[23]=(crc_reg>>8)&0xff;
+    og->header[24]=(crc_reg>>16)&0xff;
+    og->header[25]=(crc_reg>>24)&0xff;
+  }
 }
 
 /* submit data to the internal buffer of the framing engine */
@@ -424,7 +432,7 @@
   
   /* calculate the checksum */
   
-  _os_checksum(og);
+  ogg_page_checksum_set(og);
 
   /* done */
   return(1);
@@ -573,7 +581,7 @@
     log.header_len=oy->headerbytes;
     log.body=page+oy->headerbytes;
     log.body_len=oy->bodybytes;
-    _os_checksum(&log);
+    ogg_page_checksum_set(&log);
     
     /* Compare */
     if(memcmp(chksum,page+22,4)){

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list