[xiph-commits] r7296 - in branches/ogg2-arc: include/ogg2 src

arc at dactyl.lonelymoon.com arc
Fri Jul 23 16:07:35 PDT 2004


Author: arc
Date: Fri Jul 23 16:07:35 2004
New Revision: 7296

Modified:
branches/ogg2-arc/include/ogg2/ogg.h
branches/ogg2-arc/src/ogginternal.h
branches/ogg2-arc/src/sync.c
Log:
This solves bug 485 and re-adds ogg_page_checksum_set to ogginternal.h

Tt used to be in include/ogg2/ogg.h but was removed because there are
no external functions for modifying data, and thus, this is useless to
the outside.  I don't quite understand how my code has been compiling
without it all this time, but it's surely needed or others to compile.



Modified: branches/ogg2-arc/include/ogg2/ogg.h
===================================================================
--- branches/ogg2-arc/include/ogg2/ogg.h	2004-07-23 22:33:16 UTC (rev 7295)
+++ branches/ogg2-arc/include/ogg2/ogg.h	2004-07-23 23:07:26 UTC (rev 7296)
@@ -134,6 +134,13 @@
extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
extern int      ogg_page_packets(ogg_page *og);

+extern void     ogg_page_set_continued(ogg_page *og, int value);
+extern void     ogg_page_set_bos(ogg_page *og, int value);
+extern void     ogg_page_set_eos(ogg_page *og, int value);
+extern void     ogg_page_set_granulepos(ogg_page *og, ogg_int64_t value);
+extern void     ogg_page_set_serialno(ogg_page *og, ogg_uint32_t value);
+extern void     ogg_page_set_pageno(ogg_page *og, ogg_uint32_t value);
+
extern int      ogg_packet_release(ogg_packet *op);
extern int      ogg_page_release(ogg_page *og);


Modified: branches/ogg2-arc/src/ogginternal.h
===================================================================
--- branches/ogg2-arc/src/ogginternal.h	2004-07-23 22:33:16 UTC (rev 7295)
+++ branches/ogg2-arc/src/ogginternal.h	2004-07-23 23:07:26 UTC (rev 7296)
@@ -167,6 +167,7 @@
extern int               oggbyte_read2(oggbyte_buffer *b,int pos);
extern ogg_uint32_t      oggbyte_read4(oggbyte_buffer *b,int pos);
extern ogg_int64_t       oggbyte_read8(oggbyte_buffer *b,int pos);
+extern int               ogg_page_checksum_set(ogg_page *og);

#ifdef _V_SELFTEST
#define OGGPACK_CHUNKSIZE 3

Modified: branches/ogg2-arc/src/sync.c
===================================================================
--- branches/ogg2-arc/src/sync.c	2004-07-23 22:33:16 UTC (rev 7295)
+++ branches/ogg2-arc/src/sync.c	2004-07-23 23:07:26 UTC (rev 7296)
@@ -99,6 +99,66 @@
return(count);
}

+/*
+   These functions can be used to change some header values of an
+   Ogg Page without having to decode and recompile the stream.  This can
+   be very helpful for repairing broken streams, chaining streams which
+   have the same serialno, or intentionally creating broken streams
+   to test how your application will react to the erronious data.
+*/
+
+void ogg_page_set_continued(ogg_page *og, int value){
+  int b;
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  b=oggbyte_read1(&ob,5);
+  if(value)oggbyte_set1(&ob,b|0x01,5);
+  else oggbyte_set1(&ob,b&0xFE,5);
+  ogg_page_checksum_set(og);
+}
+
+void ogg_page_set_bos(ogg_page *og, int value){
+  int b;
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  b=oggbyte_read1(&ob,5);
+  if(value)oggbyte_set1(&ob,b|0x02,5);
+  else oggbyte_set1(&ob,b&0xFD,5);
+  ogg_page_checksum_set(og);
+}
+
+void ogg_page_set_eos(ogg_page *og, int value){
+  int b;
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  b=oggbyte_read1(&ob,5);
+  if(value)oggbyte_set1(&ob,b|0x04,5);
+  else oggbyte_set1(&ob,b&0xFB,5);
+  ogg_page_checksum_set(og);
+}
+
+void ogg_page_set_granulepos(ogg_page *og, ogg_int64_t value){
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  oggbyte_set8(&ob,value,6);
+  ogg_page_checksum_set(og);
+}
+
+void ogg_page_set_serialno(ogg_page *og, ogg_uint32_t value){
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  oggbyte_set4(&ob,value,14);
+  ogg_page_checksum_set(og);
+}
+
+void ogg_page_set_pageno(ogg_page *og, ogg_uint32_t value){
+  oggbyte_buffer ob;
+  oggbyte_init(&ob,og->header,0);
+  oggbyte_set4(&ob,value,18);
+  ogg_page_checksum_set(og);
+}
+
+
/* Static CRC calculation table.  See older code in SVN for dead
run-time initialization code. */




More information about the commits mailing list