[xiph-commits] r9005 - in branches/ogg2-arc: doc/ogg2 include/ogg2
src
arc at motherfish-iii.xiph.org
arc at motherfish-iii.xiph.org
Wed Mar 2 03:40:52 PST 2005
Author: arc
Date: 2005-03-02 03:40:48 -0800 (Wed, 02 Mar 2005)
New Revision: 9005
Modified:
branches/ogg2-arc/doc/ogg2/bitpacking.html
branches/ogg2-arc/doc/ogg2/datastructures.html
branches/ogg2-arc/include/ogg2/ogg.h
branches/ogg2-arc/src/bitwise.c
branches/ogg2-arc/src/buffer.c
branches/ogg2-arc/src/bytewise.c
branches/ogg2-arc/src/mutex.h
branches/ogg2-arc/src/ogginternal.h
branches/ogg2-arc/src/stream.c
branches/ogg2-arc/src/sync.c
Log:
I hope this is complete.. should resolve namespace conflicts for libogg1
Modified: branches/ogg2-arc/doc/ogg2/bitpacking.html
===================================================================
--- branches/ogg2-arc/doc/ogg2/bitpacking.html 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/doc/ogg2/bitpacking.html 2005-03-02 11:40:48 UTC (rev 9005)
@@ -16,7 +16,7 @@
<h1>Bitpacking Functions</h1>
<p>Libogg contains a basic bitpacking library that is useful for manipulating data within a buffer.
<p>
-All the <b>libogg</b> specific functions are declared in "ogg/ogg.h".
+All the <b>libogg</b> specific functions are declared in "ogg2/ogg.h".
<p>
<table border=1 color=black width=50% cellspacing=0 cellpadding=7>
@@ -25,7 +25,7 @@
<td><b>purpose</b></td>
</tr>
<tr valign=top>
-<td><a href="oggpack_writeinit.html">oggpack_writeinit</a></td>
+<td><a href="oggpack_writeinit.html">oggpack_writeinit</a> and <a href="oggpackB_writeinit.html"></td>
<td>Initializes a buffer for writing using this bitpacking library.</td>
</tr>
<tr valign=top>
Modified: branches/ogg2-arc/doc/ogg2/datastructures.html
===================================================================
--- branches/ogg2-arc/doc/ogg2/datastructures.html 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/doc/ogg2/datastructures.html 2005-03-02 11:40:48 UTC (rev 9005)
@@ -16,7 +16,7 @@
<h1>Base Data Structures</h1>
<p>Libogg uses several data structures to hold data and state information.
<p>
-All the <b>libogg</b> specific data structures are declared in "ogg/ogg.h".
+All the <b>libogg</b> specific data structures are declared in "ogg2/ogg.h".
<p>
<table border=1 color=black width=50% cellspacing=0 cellpadding=7>
@@ -26,20 +26,12 @@
</tr>
<tr valign=top>
<td><a href="ogg_page.html">ogg_page</a></td>
- <td>This structure encapsulates data into one ogg bitstream page.</td>
+ <td>This structure references the data of an Ogg bitstream page.</td>
</tr>
<tr valign=top>
-<td><a href="ogg_stream_state.html">ogg_stream_state</a></td>
- <td>This structure contains current encode/decode data for a logical bitstream.</td>
-</tr>
-<tr valign=top>
<td><a href="ogg_packet.html">ogg_packet</a></td>
- <td>This structure encapsulates the data and metadata for a single raw Ogg Vorbis packet.</td>
+ <td>This structure references the data and metadata for an Ogg packet.</td>
</tr>
-<tr valign=top>
-<td><a href="ogg_sync_state.html">ogg_sync_state</a></td>
- <td>Contains bitstream synchronization information.</td>
-</tr>
</table>
<br><br>
Modified: branches/ogg2-arc/include/ogg2/ogg.h
===================================================================
--- branches/ogg2-arc/include/ogg2/ogg.h 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/include/ogg2/ogg.h 2005-03-02 11:40:48 UTC (rev 9005)
@@ -14,8 +14,8 @@
last mod: $Id$
********************************************************************/
-#ifndef _OGG_H
-#define _OGG_H
+#ifndef _OGG2_H
+#define _OGG2_H
#ifdef __cplusplus
extern "C" {
@@ -23,151 +23,142 @@
#include <ogg2/os_types.h>
-struct ogg_buffer;
-struct ogg_reference;
-struct ogg_buffer_state;
-struct ogg_sync_state;
-struct ogg_stream_state;
-struct oggpack_buffer;
+struct ogg2_buffer;
+struct ogg2_reference;
+struct ogg2_buffer_state;
+struct ogg2_sync_state;
+struct ogg2_stream_state;
+struct ogg2pack_buffer;
-typedef struct ogg_buffer ogg_buffer;
-typedef struct ogg_reference ogg_reference;
-typedef struct ogg_buffer_state ogg_buffer_state;
-typedef struct ogg_sync_state ogg_sync_state;
-typedef struct ogg_stream_state ogg_stream_state;
-typedef struct oggpack_buffer oggpack_buffer;
+typedef struct ogg2_buffer ogg2_buffer;
+typedef struct ogg2_reference ogg2_reference;
+typedef struct ogg2_buffer_state ogg2_buffer_state;
+typedef struct ogg2_sync_state ogg2_sync_state;
+typedef struct ogg2_stream_state ogg2_stream_state;
+typedef struct ogg2pack_buffer ogg2pack_buffer;
typedef struct {
- ogg_reference *packet;
+ ogg2_reference *packet;
long bytes;
long b_o_s;
long e_o_s;
- ogg_int64_t granulepos;
+ ogg_int64_t start_granule;
+ ogg_int64_t end_granule;
ogg_int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a seperate abstraction
layer) also knows about the gap */
-} ogg_packet;
+} ogg2_packet;
typedef struct {
- ogg_reference *header;
+ ogg2_reference *header;
int header_len;
- ogg_reference *body;
+ ogg2_reference *body;
int body_len;
-} ogg_page;
+} ogg2_page;
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
-extern ogg_buffer_state *ogg_buffer_create(void);
-extern int oggpack_buffersize(void);
-extern void oggpack_writeinit(oggpack_buffer *b,ogg_buffer_state *bs);
-extern ogg_reference *oggpack_writebuffer(oggpack_buffer *b);
-extern void oggpack_writealign(oggpack_buffer *b);
-extern void oggpack_writeclear(oggpack_buffer *b);
-extern void oggpack_readinit(oggpack_buffer *b,ogg_reference *r);
-extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
-extern int oggpack_look(oggpack_buffer *b,int bits,unsigned long *ret);
-extern long oggpack_look1(oggpack_buffer *b);
-extern void oggpack_adv(oggpack_buffer *b,int bits);
-extern void oggpack_adv1(oggpack_buffer *b);
-extern int oggpack_read(oggpack_buffer *b,int bits,unsigned long *ret);
-extern long oggpack_read1(oggpack_buffer *b);
-extern long oggpack_bytes(oggpack_buffer *b);
-extern long oggpack_bits(oggpack_buffer *b);
-extern int oggpack_eop(oggpack_buffer *b);
+extern ogg2_buffer_state *ogg2_buffer_create(void);
+extern int ogg2pack_buffersize(void);
+extern void ogg2pack_writeinit(ogg2pack_buffer *b,ogg2_buffer_state *bs);
+extern ogg2_reference *ogg2pack_writebuffer(ogg2pack_buffer *b);
+extern void ogg2pack_writealign(ogg2pack_buffer *b);
+extern void ogg2pack_writeclear(ogg2pack_buffer *b);
+extern void ogg2pack_readinit(ogg2pack_buffer *b,ogg2_reference *r);
+extern void ogg2pack_write(ogg2pack_buffer *b,unsigned long value,int bits);
+extern int ogg2pack_look(ogg2pack_buffer *b,int bits,unsigned long *ret);
+extern long ogg2pack_look1(ogg2pack_buffer *b);
+extern void ogg2pack_adv(ogg2pack_buffer *b,int bits);
+extern void ogg2pack_adv1(ogg2pack_buffer *b);
+extern int ogg2pack_read(ogg2pack_buffer *b,int bits,unsigned long *ret);
+extern long ogg2pack_read1(ogg2pack_buffer *b);
+extern long ogg2pack_bytes(ogg2pack_buffer *b);
+extern long ogg2pack_bits(ogg2pack_buffer *b);
+extern int ogg2pack_eop(ogg2pack_buffer *b);
-extern void oggpackB_writeinit(oggpack_buffer *b,ogg_buffer_state *bs);
-extern ogg_reference *oggpackB_writebuffer(oggpack_buffer *b);
-extern void oggpackB_writealign(oggpack_buffer *b);
-extern void oggpackB_writeclear(oggpack_buffer *b);
-extern void oggpackB_readinit(oggpack_buffer *b,ogg_reference *r);
-extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
-extern int oggpackB_look(oggpack_buffer *b,int bits,unsigned long *ret);
-extern long oggpackB_look1(oggpack_buffer *b);
-extern void oggpackB_adv(oggpack_buffer *b,int bits);
-extern void oggpackB_adv1(oggpack_buffer *b);
-extern int oggpackB_read(oggpack_buffer *b,int bits,unsigned long *ret);
-extern long oggpackB_read1(oggpack_buffer *b);
-extern long oggpackB_bytes(oggpack_buffer *b);
-extern long oggpackB_bits(oggpack_buffer *b);
-extern int oggpackB_eop(oggpack_buffer *b);
+extern void ogg2packB_writeinit(ogg2pack_buffer *b,ogg2_buffer_state *bs);
+extern ogg2_reference *ogg2packB_writebuffer(ogg2pack_buffer *b);
+extern void ogg2packB_writealign(ogg2pack_buffer *b);
+extern void ogg2packB_writeclear(ogg2pack_buffer *b);
+extern void ogg2packB_readinit(ogg2pack_buffer *b,ogg2_reference *r);
+extern void ogg2packB_write(ogg2pack_buffer *b,unsigned long value,int bits);
+extern int ogg2packB_look(ogg2pack_buffer *b,int bits,unsigned long *ret);
+extern long ogg2packB_look1(ogg2pack_buffer *b);
+extern void ogg2packB_adv(ogg2pack_buffer *b,int bits);
+extern void ogg2packB_adv1(ogg2pack_buffer *b);
+extern int ogg2packB_read(ogg2pack_buffer *b,int bits,unsigned long *ret);
+extern long ogg2packB_read1(ogg2pack_buffer *b);
+extern long ogg2packB_bytes(ogg2pack_buffer *b);
+extern long ogg2packB_bits(ogg2pack_buffer *b);
+extern int ogg2packB_eop(ogg2pack_buffer *b);
/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
-extern long ogg_sync_bufferout(ogg_sync_state *oy, unsigned char **buffer);
-extern int ogg_sync_pagein(ogg_sync_state *oy,ogg_page *og);
-extern int ogg_sync_read(ogg_sync_state *oy,long bytes);
+extern long ogg2_sync_bufferout(ogg2_sync_state *oy, unsigned char **buffer);
+extern int ogg2_sync_pagein(ogg2_sync_state *oy,ogg2_page *og);
+extern int ogg2_sync_read(ogg2_sync_state *oy,long bytes);
-extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
-extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
-extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
+extern int ogg2_stream_packetin(ogg2_stream_state *os, ogg2_packet *op);
+extern int ogg2_stream_pageout(ogg2_stream_state *os, ogg2_page *og);
+extern int ogg2_stream_flush(ogg2_stream_state *os, ogg2_page *og);
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
-extern ogg_sync_state *ogg_sync_create(void);
-extern int ogg_sync_destroy(ogg_sync_state *oy);
-extern int ogg_sync_reset(ogg_sync_state *oy);
+extern ogg2_sync_state *ogg2_sync_create(void);
+extern int ogg2_sync_destroy(ogg2_sync_state *oy);
+extern int ogg2_sync_reset(ogg2_sync_state *oy);
-extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
-extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
-extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
-extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
-extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
-extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
-extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
+extern unsigned char *ogg2_sync_bufferin(ogg2_sync_state *oy, long size);
+extern int ogg2_sync_wrote(ogg2_sync_state *oy, long bytes);
+extern long ogg2_sync_pageseek(ogg2_sync_state *oy,ogg2_page *og);
+extern int ogg2_sync_pageout(ogg2_sync_state *oy, ogg2_page *og);
+extern int ogg2_stream_pagein(ogg2_stream_state *os, ogg2_page *og);
+extern int ogg2_stream_packetout(ogg2_stream_state *os,ogg2_packet *op);
+extern int ogg2_stream_packetpeek(ogg2_stream_state *os,ogg2_packet *op);
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
-extern ogg_stream_state *ogg_stream_create(int serialno);
-extern int ogg_stream_destroy(ogg_stream_state *os);
-extern int ogg_stream_reset(ogg_stream_state *os);
-extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
-extern int ogg_stream_eos(ogg_stream_state *os);
-extern int ogg_stream_setmode(ogg_stream_state *os, int mode);
+extern ogg2_stream_state *ogg2_stream_create(int serialno);
+extern int ogg2_stream_destroy(ogg2_stream_state *os);
+extern int ogg2_stream_reset(ogg2_stream_state *os);
+extern int ogg2_stream_reset_serialno(ogg2_stream_state *os,int serialno);
+extern int ogg2_stream_eos(ogg2_stream_state *os);
+extern int ogg2_stream_setdiscont(ogg2_stream_state *os);
-extern int ogg_page_version(ogg_page *og);
-extern int ogg_page_continued(ogg_page *og);
-extern int ogg_page_bos(ogg_page *og);
-extern int ogg_page_eos(ogg_page *og);
-extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
-extern ogg_uint32_t ogg_page_serialno(ogg_page *og);
-extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
-extern int ogg_page_packets(ogg_page *og);
+extern int ogg2_page_version(ogg2_page *og);
+extern int ogg2_page_continued(ogg2_page *og);
+extern int ogg2_page_bos(ogg2_page *og);
+extern int ogg2_page_eos(ogg2_page *og);
+extern ogg_int64_t ogg2_page_granulepos(ogg2_page *og);
+extern ogg_uint32_t ogg2_page_serialno(ogg2_page *og);
+extern ogg_uint32_t ogg2_page_pageno(ogg2_page *og);
+extern int ogg2_page_packets(ogg2_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 void ogg2_page_set_continued(ogg2_page *og, int value);
+extern void ogg2_page_set_bos(ogg2_page *og, int value);
+extern void ogg2_page_set_eos(ogg2_page *og, int value);
+extern void ogg2_page_set_granulepos(ogg2_page *og, ogg_int64_t value);
+extern void ogg2_page_set_serialno(ogg2_page *og, ogg_uint32_t value);
+extern void ogg2_page_set_pageno(ogg2_page *og, ogg_uint32_t value);
-extern int ogg_packet_release(ogg_packet *op);
-extern int ogg_page_release(ogg_page *og);
+extern int ogg2_packet_release(ogg2_packet *op);
+extern int ogg2_page_release(ogg2_page *og);
-/* Ogg BITSTREAM PRIMITIVES: mode flags *****************************/
-
-#define OGG_DISCONT 1
-
/* Ogg BITSTREAM PRIMITIVES: return codes ***************************/
-#define OGG_SUCCESS 0
+#define OGG2_SUCCESS 0
-#define OGG_HOLE -10
-#define OGG_SPAN -11
-#define OGG_EVERSION -12
-#define OGG_ESERIAL -13
-#define OGG_EINVAL -14
-#define OGG_EEOS -15
-#define OGG_EMODE -16
+#define OGG2_HOLE -10
+#define OGG2_SPAN -11
+#define OGG2_EVERSION -12
+#define OGG2_ESERIAL -13
+#define OGG2_EINVAL -14
+#define OGG2_EEOS -15
+#define OGG2_EMODE -16
#ifdef __cplusplus
}
#endif
-#endif /* _OGG_H */
-
-
-
-
-
-
+#endif /* _OGG2_H */
Modified: branches/ogg2-arc/src/bitwise.c
===================================================================
--- branches/ogg2-arc/src/bitwise.c 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/bitwise.c 2005-03-02 11:40:48 UTC (rev 9005)
@@ -15,7 +15,7 @@
********************************************************************/
-/* the 'oggpack_xxx functions are 'LSb' endian; if we write a word but
+/* the 'ogg2pack_xxx functions are 'LSb' endian; if we write a word but
read individual bits, then we'll read the lsb first */
/* the 'oggpackB_xxx functions are 'MSb' endian; if we write a word but
read individual bits, then we'll read the msb first */
@@ -33,28 +33,28 @@
0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
0x3fffffff,0x7fffffff,0xffffffff };
-int oggpack_buffersize(void){
- return sizeof(oggpack_buffer);
+int ogg2pack_buffersize(void){
+ return sizeof(ogg2pack_buffer);
}
-void oggpack_writeinit(oggpack_buffer *b,ogg_buffer_state *bs){
+void ogg2pack_writeinit(ogg2pack_buffer *b,ogg2_buffer_state *bs){
memset(b,0,sizeof(*b));
b->owner=bs;
}
-void oggpackB_writeinit(oggpack_buffer *b,ogg_buffer_state *bs){
- oggpack_writeinit(b,bs);
+void oggpackB_writeinit(ogg2pack_buffer *b,ogg2_buffer_state *bs){
+ ogg2pack_writeinit(b,bs);
b->owner=bs;
}
-static void _oggpack_extend(oggpack_buffer *b){
+static void _ogg2pack_extend(ogg2pack_buffer *b){
if(b->head){
b->head->length=b->head->buffer->size; /* only because ->begin is always
zero in a write buffer */
b->count+=b->head->length;
- b->head=ogg_buffer_extend(b->head,OGGPACK_CHUNKSIZE);
+ b->head=ogg2_buffer_extend(b->head,OGG2PACK_CHUNKSIZE);
}else{
- b->head=b->tail=ogg_buffer_alloc(b->owner,OGGPACK_CHUNKSIZE);
+ b->head=b->tail=ogg2_buffer_alloc(b->owner,OGG2PACK_CHUNKSIZE);
}
b->headptr=b->head->buffer->data;
@@ -62,35 +62,35 @@
}
/* Takes only up to 32 bits. */
-void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
+void ogg2pack_write(ogg2pack_buffer *b,unsigned long value,int bits){
value&=mask[bits];
bits+=b->headbit;
if(!b->headend){
- _oggpack_extend(b);
+ _ogg2pack_extend(b);
*b->headptr=value;
}else
*b->headptr|=value<<b->headbit;
if(bits>=8){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(8-b->headbit);
if(bits>=16){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(16-b->headbit);
if(bits>=24){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(24-b->headbit);
if(bits>=32){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
if(b->headbit)
*b->headptr=value>>(32-b->headbit);
else
@@ -105,35 +105,35 @@
}
/* Takes only up to 32 bits. */
-void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
+void oggpackB_write(ogg2pack_buffer *b,unsigned long value,int bits){
value=(value&mask[bits])<<(32-bits);
bits+=b->headbit;
if(!b->headend){
- _oggpack_extend(b);
+ _ogg2pack_extend(b);
*b->headptr=value>>24;
}else
*b->headptr|=value>>(24+b->headbit);
if(bits>=8){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(16+b->headbit);
if(bits>=16){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(8+b->headbit);
if(bits>=24){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
*b->headptr=value>>(b->headbit);
if(bits>=32){
++b->headptr;
- if(!--b->headend)_oggpack_extend(b);
+ if(!--b->headend)_ogg2pack_extend(b);
if(b->headbit)
*b->headptr=value<<(8-b->headbit);
else
@@ -146,42 +146,42 @@
b->headbit=bits&7;
}
-void oggpack_writealign(oggpack_buffer *b){
+void ogg2pack_writealign(ogg2pack_buffer *b){
int bits=8-b->headbit;
if(bits<8)
- oggpack_write(b,0,bits);
+ ogg2pack_write(b,0,bits);
}
-void oggpackB_writealign(oggpack_buffer *b){
+void oggpackB_writealign(ogg2pack_buffer *b){
int bits=8-b->headbit;
if(bits<8)
oggpackB_write(b,0,bits);
}
-ogg_reference *oggpack_writebuffer(oggpack_buffer *b){
- /* unlike generic ogg_buffer_references, the oggpack write buffers
- will never have any potential prefixed/unused ogg_buffer data */
+ogg2_reference *ogg2pack_writebuffer(ogg2pack_buffer *b){
+ /* unlike generic ogg2_buffer_references, the oggpack write buffers
+ will never have any potential prefixed/unused ogg2_buffer data */
b->head->length=b->headptr-b->head->buffer->data+(b->headbit+7)/8;
return(b->tail);
}
-ogg_reference *oggpackB_writebuffer(oggpack_buffer *b){
- return oggpack_writebuffer(b);
+ogg2_reference *oggpackB_writebuffer(ogg2pack_buffer *b){
+ return ogg2pack_writebuffer(b);
}
-/* frees and deallocates the oggpack_buffer ogg_buffer usage */
-void oggpack_writeclear(oggpack_buffer *b){
- ogg_buffer_release(b->tail);
+/* frees and deallocates the ogg2pack_buffer ogg2_buffer usage */
+void ogg2pack_writeclear(ogg2pack_buffer *b){
+ ogg2_buffer_release(b->tail);
memset(b,0,sizeof(*b));
}
-void oggpackB_writeclear(oggpack_buffer *b){
- oggpack_writeclear(b);
+void oggpackB_writeclear(ogg2pack_buffer *b){
+ ogg2pack_writeclear(b);
}
/* mark read process as having run off the end */
-static void _adv_halt(oggpack_buffer *b){
+static void _adv_halt(ogg2pack_buffer *b){
b->headptr=b->head->buffer->data+b->head->begin+b->head->length;
b->headend=-1;
b->headbit=0;
@@ -191,7 +191,7 @@
headend is zero, simply finds next byte. If we're up to the end
of the buffer, leaves headend at zero. If we've read past the end,
halt the decode process. */
-static void _span(oggpack_buffer *b){
+static void _span(ogg2pack_buffer *b){
while(b->headend<1){
if(b->head->next){
b->count+=b->head->length;
@@ -210,7 +210,7 @@
}
}
-void oggpack_readinit(oggpack_buffer *b,ogg_reference *r){
+void ogg2pack_readinit(ogg2pack_buffer *b,ogg2_reference *r){
memset(b,0,sizeof(*b));
b->tail=b->head=r;
@@ -220,8 +220,8 @@
_span(b);
}
-void oggpackB_readinit(oggpack_buffer *b,ogg_reference *r){
- oggpack_readinit(b,r);
+void oggpackB_readinit(ogg2pack_buffer *b,ogg2_reference *r){
+ ogg2pack_readinit(b,r);
}
#define _lookspan() while(!end){\
@@ -232,7 +232,7 @@
}
/* Read in bits without advancing the bitptr; bits <= 32 */
-int oggpack_look(oggpack_buffer *b,int bits,unsigned long *ret){
+int ogg2pack_look(ogg2pack_buffer *b,int bits,unsigned long *ret){
unsigned long m=mask[bits];
bits+=b->headbit;
@@ -240,7 +240,7 @@
if(bits >= b->headend*8){
int end=b->headend;
unsigned char *ptr=b->headptr;
- ogg_reference *head=b->head;
+ ogg2_reference *head=b->head;
if(end<0)return -1;
@@ -291,7 +291,7 @@
}
/* Read in bits without advancing the bitptr; bits <= 32 */
-int oggpackB_look(oggpack_buffer *b,int bits,unsigned long *ret){
+int oggpackB_look(ogg2pack_buffer *b,int bits,unsigned long *ret){
int m=32-bits;
bits+=b->headbit;
@@ -299,7 +299,7 @@
if(bits >= b->headend<<3){
int end=b->headend;
unsigned char *ptr=b->headptr;
- ogg_reference *head=b->head;
+ ogg2_reference *head=b->head;
if(end<0)return -1;
@@ -348,18 +348,18 @@
return 0;
}
-long oggpack_look1(oggpack_buffer *b){
+long ogg2pack_look1(ogg2pack_buffer *b){
if(b->headend<1)return -1;
return (b->headptr[0]>>b->headbit)&1;
}
-long oggpackB_look1(oggpack_buffer *b){
+long oggpackB_look1(ogg2pack_buffer *b){
if(b->headend<1)return -1;
return (b->headptr[0]>>(7-b->headbit))&1;
}
/* limited to 32 at a time */
-void oggpack_adv(oggpack_buffer *b,int bits){
+void ogg2pack_adv(ogg2pack_buffer *b,int bits){
bits+=b->headbit;
b->headend-=bits/8;
b->headbit=bits&7;
@@ -367,12 +367,12 @@
_span(b);
}
-void oggpackB_adv(oggpack_buffer *b,int bits){
- oggpack_adv(b,bits);
+void oggpackB_adv(ogg2pack_buffer *b,int bits){
+ ogg2pack_adv(b,bits);
}
/* spans forward and finds next byte. Never halts */
-static void _span_one(oggpack_buffer *b){
+static void _span_one(ogg2pack_buffer *b){
while(b->headend<1){
if(b->head->next){
b->count+=b->head->length;
@@ -384,7 +384,7 @@
}
}
-void oggpack_adv1(oggpack_buffer *b){
+void ogg2pack_adv1(ogg2pack_buffer *b){
if(b->headend<2){
if(b->headend<1){
_adv_halt(b);
@@ -406,11 +406,11 @@
}
}
-void oggpackB_adv1(oggpack_buffer *b){
- oggpack_adv1(b);
+void oggpackB_adv1(ogg2pack_buffer *b){
+ ogg2pack_adv1(b);
}
-static int _halt_one(oggpack_buffer *b){
+static int _halt_one(ogg2pack_buffer *b){
if(b->headend<1){
_adv_halt(b);
return -1;
@@ -419,7 +419,7 @@
}
/* bits <= 32 */
-int oggpack_read(oggpack_buffer *b,int bits,unsigned long *ret){
+int ogg2pack_read(ogg2pack_buffer *b,int bits,unsigned long *ret){
unsigned long m=mask[bits];
bits+=b->headbit;
@@ -499,7 +499,7 @@
}
/* bits <= 32 */
-int oggpackB_read(oggpack_buffer *b,int bits,unsigned long *ret){
+int oggpackB_read(ogg2pack_buffer *b,int bits,unsigned long *ret){
long m=32-bits;
bits+=b->headbit;
@@ -577,7 +577,7 @@
return 0;
}
-long oggpack_read1(oggpack_buffer *b){
+long ogg2pack_read1(ogg2pack_buffer *b){
long ret;
if(b->headend<2){
@@ -600,7 +600,7 @@
return ret&1;
}
-long oggpackB_read1(oggpack_buffer *b){
+long oggpackB_read1(ogg2pack_buffer *b){
long ret;
if(b->headend<2){
@@ -623,30 +623,30 @@
return ret&1;
}
-long oggpack_bytes(oggpack_buffer *b){
+long ogg2pack_bytes(ogg2pack_buffer *b){
return(b->count+b->headptr-b->head->buffer->data-b->head->begin+
(b->headbit+7)/8);
}
-long oggpack_bits(oggpack_buffer *b){
+long ogg2pack_bits(ogg2pack_buffer *b){
return((b->count+b->headptr-b->head->buffer->data-b->head->begin)*8+
b->headbit);
}
-long oggpackB_bytes(oggpack_buffer *b){
- return oggpack_bytes(b);
+long oggpackB_bytes(ogg2pack_buffer *b){
+ return ogg2pack_bytes(b);
}
-long oggpackB_bits(oggpack_buffer *b){
- return oggpack_bits(b);
+long oggpackB_bits(ogg2pack_buffer *b){
+ return ogg2pack_bits(b);
}
-int oggpack_eop(oggpack_buffer *b){
+int ogg2pack_eop(ogg2pack_buffer *b){
return(b->headend<0?-1:0);
}
-int oggpackB_eop(oggpack_buffer *b){
- return oggpack_eop(b);
+int oggpackB_eop(ogg2pack_buffer *b){
+ return ogg2pack_eop(b);
}
/* Self test of the bitwise routines; everything else is based on
@@ -664,10 +664,10 @@
return(ret);
}
-oggpack_buffer o;
-oggpack_buffer r;
-ogg_buffer_state *bs;
-ogg_reference *or;
+ogg2pack_buffer o;
+ogg2pack_buffer r;
+ogg2_buffer_state *bs;
+ogg2_reference *or;
#define TESTWORDS 4096
void report(char *in){
@@ -675,7 +675,7 @@
exit(1);
}
-int getbyte(ogg_reference *or,int position){
+int getbyte(ogg2_reference *or,int position){
while(or && position>=or->length){
position-=or->length;
or=or->next;
@@ -690,22 +690,22 @@
void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
long bytes,i,bitcount=0;
- ogg_reference *or;
+ ogg2_reference *or;
- oggpack_writeinit(&o,bs);
+ ogg2pack_writeinit(&o,bs);
for(i=0;i<vals;i++){
- oggpack_write(&o,b[i],bits?bits:ilog(b[i]));
+ ogg2pack_write(&o,b[i],bits?bits:ilog(b[i]));
bitcount+=bits?bits:ilog(b[i]);
- if(bitcount!=oggpack_bits(&o)){
+ if(bitcount!=ogg2pack_bits(&o)){
report("wrong number of bits while writing!\n");
}
- if((bitcount+7)/8!=oggpack_bytes(&o)){
+ if((bitcount+7)/8!=ogg2pack_bytes(&o)){
report("wrong number of bytes while writing!\n");
}
}
- or=oggpack_writebuffer(&o);
- bytes=oggpack_bytes(&o);
+ or=ogg2pack_writebuffer(&o);
+ bytes=ogg2pack_bytes(&o);
if(bytes!=compsize)report("wrong number of bytes!\n");
for(i=0;i<bytes;i++)if(getbyte(or,i)!=comp[i]){
@@ -714,24 +714,24 @@
}
bitcount=0;
- oggpack_readinit(&r,or);
+ ogg2pack_readinit(&r,or);
for(i=0;i<vals;i++){
unsigned long test;
int tbit=bits?bits:ilog(b[i]);
- if(oggpack_look(&r,tbit,&test))
+ if(ogg2pack_look(&r,tbit,&test))
report("out of data!\n");
if(test!=(b[i]&mask[tbit])){
fprintf(stderr,"%ld) %lx %lx\n",i,(b[i]&mask[tbit]),test);
report("looked at incorrect value!\n");
}
if(tbit==1)
- if(oggpack_look1(&r)!=(int)(b[i]&mask[tbit]))
+ if(ogg2pack_look1(&r)!=(int)(b[i]&mask[tbit]))
report("looked at single bit incorrect value!\n");
if(tbit==1){
- if(oggpack_read1(&r)!=(int)(b[i]&mask[tbit]))
+ if(ogg2pack_read1(&r)!=(int)(b[i]&mask[tbit]))
report("read incorrect single bit value!\n");
}else{
- if(oggpack_read(&r,tbit,&test)){
+ if(ogg2pack_read(&r,tbit,&test)){
report("premature end of data when reading!\n");
}
if(test!=(b[i]&mask[tbit])){
@@ -741,20 +741,20 @@
}
bitcount+=tbit;
- if(bitcount!=oggpack_bits(&r))
+ if(bitcount!=ogg2pack_bits(&r))
report("wrong number of bits while reading!\n");
- if((bitcount+7)/8!=oggpack_bytes(&r))
+ if((bitcount+7)/8!=ogg2pack_bytes(&r))
report("wrong number of bytes while reading!\n");
}
- if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
- oggpack_writeclear(&o);
+ if(ogg2pack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+ ogg2pack_writeclear(&o);
}
void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){
long bytes,i;
- ogg_reference *or;
+ ogg2_reference *or;
oggpackB_writeinit(&o,bs);
for(i=0;i<vals;i++)
@@ -793,7 +793,7 @@
int flatten (unsigned char *flat){
unsigned char *ptr=flat;
- ogg_reference *head=oggpack_writebuffer(&o);
+ ogg2_reference *head=ogg2pack_writebuffer(&o);
while(head){
memcpy(ptr,head->buffer->data+head->begin,head->length);
ptr+=head->length;
@@ -884,27 +884,27 @@
int i;
/* are the proper number of bits left over? */
- int leftover=count*8-oggpack_bits(&o);
+ int leftover=count*8-ogg2pack_bits(&o);
if(leftover>7)
report("\nERROR: too many bits reported left over.\n");
/* does reading to exactly byte alignment *not* trip EOF? */
- if(oggpack_read(&o,leftover,&temp))
+ if(ogg2pack_read(&o,leftover,&temp))
report("\nERROR: read to but not past exact end tripped EOF.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read to but not past exact end reported bad bitcount.\n");
/* does EOF trip properly after a single additional bit? */
- if(!oggpack_read(&o,1,&temp))
+ if(!ogg2pack_read(&o,1,&temp))
report("\nERROR: read past exact end did not trip EOF.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
/* does EOF stay set over additional bit reads? */
for(i=0;i<=32;i++){
- if(!oggpack_read(&o,i,&temp))
+ if(!ogg2pack_read(&o,i,&temp))
report("\nERROR: EOF did not stay set on stream.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
}
}
@@ -913,30 +913,30 @@
int i;
/* are the proper number of bits left over? */
- int leftover=count*8-oggpack_bits(&o);
+ int leftover=count*8-ogg2pack_bits(&o);
if(leftover>7)
report("\nERROR: too many bits reported left over.\n");
/* does reading to exactly byte alignment *not* trip EOF? */
- oggpack_adv(&o,leftover);
+ ogg2pack_adv(&o,leftover);
if(o.headend!=0)
report("\nERROR: read to but not past exact end tripped EOF.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read to but not past exact end reported bad bitcount.\n");
/* does EOF trip properly after a single additional bit? */
- oggpack_adv(&o,1);
+ ogg2pack_adv(&o,1);
if(o.headend>=0)
report("\nERROR: read past exact end did not trip EOF.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
/* does EOF stay set over additional bit reads? */
for(i=0;i<=32;i++){
- oggpack_adv(&o,i);
+ ogg2pack_adv(&o,i);
if(o.headend>=0)
report("\nERROR: EOF did not stay set on stream.\n");
- if(oggpack_bits(&o)!=count*8)
+ if(ogg2pack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
}
}
@@ -1072,7 +1072,7 @@
/* Test read/write together */
/* Later we test against pregenerated bitstreams */
- bs=ogg_buffer_create();
+ bs=ogg2_buffer_create();
fprintf(stderr,"\nSmall preclipped packing (LSb): ");
cliptest(testbuffer1,test1size,0,one,onesize);
@@ -1088,24 +1088,24 @@
fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
- oggpack_writeclear(&o);
- oggpack_writeinit(&o,bs);
+ ogg2pack_writeclear(&o);
+ ogg2pack_writeinit(&o,bs);
for(i=0;i<test2size;i++)
- oggpack_write(&o,large[i],32);
- or=oggpack_writebuffer(&o);
- bytes=oggpack_bytes(&o);
- oggpack_readinit(&r,or);
+ ogg2pack_write(&o,large[i],32);
+ or=ogg2pack_writebuffer(&o);
+ bytes=ogg2pack_bytes(&o);
+ ogg2pack_readinit(&r,or);
for(i=0;i<test2size;i++){
unsigned long test;
- if(oggpack_look(&r,32,&test)==-1)report("out of data. failed!");
+ if(ogg2pack_look(&r,32,&test)==-1)report("out of data. failed!");
if(test!=large[i]){
fprintf(stderr,"%ld != %ld (%lx!=%lx):",test,large[i],
test,large[i]);
report("read incorrect value!\n");
}
- oggpack_adv(&r,32);
+ ogg2pack_adv(&r,32);
}
- if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+ if(ogg2pack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
fprintf(stderr,"ok.");
fprintf(stderr,"\nSmall unclipped packing (LSb): ");
@@ -1122,48 +1122,48 @@
fprintf(stderr,"\nTesting read past end (LSb): ");
{
- ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0,1};
+ ogg2_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
+ ogg2_reference lor={&lob,0,8,0,1};
- oggpack_readinit(&r,&lor);
+ ogg2pack_readinit(&r,&lor);
for(i=0;i<64;i++){
- if(oggpack_read1(&r)!=0){
+ if(ogg2pack_read1(&r)!=0){
fprintf(stderr,"failed; got -1 prematurely.\n");
exit(1);
}
}
- if(oggpack_look1(&r)!=-1 ||
- oggpack_read1(&r)!=-1){
+ if(ogg2pack_look1(&r)!=-1 ||
+ ogg2pack_read1(&r)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
}
{
- ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0,1};
+ ogg2_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
+ ogg2_reference lor={&lob,0,8,0,1};
unsigned long test;
- oggpack_readinit(&r,&lor);
- if(oggpack_read(&r,30,&test)!=0 || oggpack_read(&r,16,&test)!=0){
+ ogg2pack_readinit(&r,&lor);
+ if(ogg2pack_read(&r,30,&test)!=0 || ogg2pack_read(&r,16,&test)!=0){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
}
- if(oggpack_look(&r,18,&test)!=0){
+ if(ogg2pack_look(&r,18,&test)!=0){
fprintf(stderr,"failed 3; got -1 prematurely.\n");
exit(1);
}
- if(oggpack_look(&r,19,&test)!=-1){
+ if(ogg2pack_look(&r,19,&test)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
- if(oggpack_look(&r,32,&test)!=-1){
+ if(ogg2pack_look(&r,32,&test)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
}
fprintf(stderr,"ok.\n");
- oggpack_writeclear(&o);
+ ogg2pack_writeclear(&o);
/********** lazy, cut-n-paste retest with MSb packing ***********/
@@ -1217,8 +1217,8 @@
fprintf(stderr,"\nTesting read past end (MSb): ");
{
- ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0,1};
+ ogg2_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
+ ogg2_reference lor={&lob,0,8,0,1};
unsigned long test;
oggpackB_readinit(&r,&lor);
@@ -1235,8 +1235,8 @@
}
}
{
- ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0,1};
+ ogg2_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
+ ogg2_reference lor={&lob,0,8,0,1};
unsigned long test;
oggpackB_readinit(&r,&lor);
@@ -1270,7 +1270,7 @@
unsigned char flat[4*TESTWORDS]; /* max possible needed size */
fprintf(stderr,"\rRandomized testing (LSb)... (%ld) ",10000-i);
- oggpack_writeinit(&o,bs);
+ ogg2pack_writeinit(&o,bs);
/* generate a list of words and lengths */
/* write the required number of bits out to packbuffer */
@@ -1278,17 +1278,17 @@
values[j]=rand();
len[j]=(rand()%33);
- oggpack_write(&o,values[j],len[j]);
+ ogg2pack_write(&o,values[j],len[j]);
bitcount+=len[j];
- if(oggpack_bits(&o)!=bitcount){
+ if(ogg2pack_bits(&o)!=bitcount){
fprintf(stderr,"\nERROR: Write bitcounter %d != %ld!\n",
- bitcount,oggpack_bits(&o));
+ bitcount,ogg2pack_bits(&o));
exit(1);
}
- if(oggpack_bytes(&o)!=(bitcount+7)/8){
+ if(ogg2pack_bytes(&o)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: Write bytecounter %d != %ld!\n",
- (bitcount+7)/8,oggpack_bytes(&o));
+ (bitcount+7)/8,ogg2pack_bytes(&o));
exit(1);
}
@@ -1300,7 +1300,7 @@
fprintf(stderr,"\nERROR: flattened write buffer incorrect length\n");
exit(1);
}
- oggpack_writeclear(&o);
+ ogg2pack_writeclear(&o);
/* verify against original list */
lsbverify(values,len,flat);
@@ -1308,7 +1308,7 @@
/* construct random-length buffer chain from flat vector; random
byte starting offset within the length of the vector */
{
- ogg_reference *or=NULL,*orl=NULL;
+ ogg2_reference *or=NULL,*orl=NULL;
unsigned char *ptr=flat;
/* build buffer chain */
@@ -1319,9 +1319,9 @@
if(ilen>count2)ilen=count2;
if(or)
- orl=ogg_buffer_extend(orl,ilen+ibegin);
+ orl=ogg2_buffer_extend(orl,ilen+ibegin);
else
- or=orl=ogg_buffer_alloc(bs,ilen+ibegin);
+ or=orl=ogg2_buffer_alloc(bs,ilen+ibegin);
memcpy(orl->buffer->data+ibegin,ptr,ilen);
@@ -1332,7 +1332,7 @@
ptr+=ilen;
}
- if(ogg_buffer_length(or)!=(bitcount+7)/8){
+ if(ogg2_buffer_length(or)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after build.\n");
exit(1);
}
@@ -1346,39 +1346,39 @@
for(j=0;j<begin;j++)
bitcount+=len[j];
- or=ogg_buffer_pretruncate(or,bitcount/8);
+ or=ogg2_buffer_pretruncate(or,bitcount/8);
bitoffset=bitcount%=8;
for(;j<begin+ilen;j++)
bitcount+=len[j];
- ogg_buffer_posttruncate(or,((bitcount+7)/8));
+ ogg2_buffer_posttruncate(or,((bitcount+7)/8));
- if((count=ogg_buffer_length(or))!=(bitcount+7)/8){
+ if((count=ogg2_buffer_length(or))!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after truncate.\n");
exit(1);
}
- oggpack_readinit(&o,or);
+ ogg2pack_readinit(&o,or);
/* verify bit count */
- if(oggpack_bits(&o)!=0){
+ if(ogg2pack_bits(&o)!=0){
fprintf(stderr,"\nERROR: Read bitcounter not zero!\n");
exit(1);
}
- if(oggpack_bytes(&o)!=0){
+ if(ogg2pack_bytes(&o)!=0){
fprintf(stderr,"\nERROR: Read bytecounter not zero!\n");
exit(1);
}
bitcount=bitoffset;
- oggpack_read(&o,bitoffset,&temp);
+ ogg2pack_read(&o,bitoffset,&temp);
/* read and compare to original list */
for(j=begin;j<begin+ilen;j++){
int ret;
if(len[j]==1 && rand()%1)
- temp=ret=oggpack_read1(&o);
+ temp=ret=ogg2pack_read1(&o);
else
- ret=oggpack_read(&o,len[j],&temp);
+ ret=ogg2pack_read(&o,len[j],&temp);
if(ret<0){
fprintf(stderr,"\nERROR: End of stream too soon! word: %d,%d\n",
j-begin,ilen);
@@ -1390,14 +1390,14 @@
exit(1);
}
bitcount+=len[j];
- if(oggpack_bits(&o)!=bitcount){
+ if(ogg2pack_bits(&o)!=bitcount){
fprintf(stderr,"\nERROR: Read bitcounter %d != %ld!\n",
- bitcount,oggpack_bits(&o));
+ bitcount,ogg2pack_bits(&o));
exit(1);
}
- if(oggpack_bytes(&o)!=(bitcount+7)/8){
+ if(ogg2pack_bytes(&o)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: Read bytecounter %d != %ld!\n",
- (bitcount+7)/8,oggpack_bytes(&o));
+ (bitcount+7)/8,ogg2pack_bytes(&o));
exit(1);
}
@@ -1405,17 +1405,17 @@
_end_verify(count);
/* look/adv version */
- oggpack_readinit(&o,or);
+ ogg2pack_readinit(&o,or);
bitcount=bitoffset;
- oggpack_adv(&o,bitoffset);
+ ogg2pack_adv(&o,bitoffset);
/* read and compare to original list */
for(j=begin;j<begin+ilen;j++){
int ret;
if(len[j]==1 && rand()%1)
- temp=ret=oggpack_look1(&o);
+ temp=ret=ogg2pack_look1(&o);
else
- ret=oggpack_look(&o,len[j],&temp);
+ ret=ogg2pack_look(&o,len[j],&temp);
if(ret<0){
fprintf(stderr,"\nERROR: End of stream too soon! word: %d\n",
@@ -1428,18 +1428,18 @@
exit(1);
}
if(len[j]==1 && rand()%1)
- oggpack_adv1(&o);
+ ogg2pack_adv1(&o);
else
- oggpack_adv(&o,len[j]);
+ ogg2pack_adv(&o,len[j]);
bitcount+=len[j];
- if(oggpack_bits(&o)!=bitcount){
+ if(ogg2pack_bits(&o)!=bitcount){
fprintf(stderr,"\nERROR: Look/Adv bitcounter %d != %ld!\n",
- bitcount,oggpack_bits(&o));
+ bitcount,ogg2pack_bits(&o));
exit(1);
}
- if(oggpack_bytes(&o)!=(bitcount+7)/8){
+ if(ogg2pack_bytes(&o)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: Look/Adv bytecounter %d != %ld!\n",
- (bitcount+7)/8,oggpack_bytes(&o));
+ (bitcount+7)/8,ogg2pack_bytes(&o));
exit(1);
}
@@ -1447,7 +1447,7 @@
_end_verify2(count);
}
- ogg_buffer_release(or);
+ ogg2_buffer_release(or);
}
}
fprintf(stderr,"\rRandomized testing (LSb)... ok. \n");
@@ -1499,7 +1499,7 @@
/* construct random-length buffer chain from flat vector; random
byte starting offset within the length of the vector */
{
- ogg_reference *or=NULL,*orl=NULL;
+ ogg2_reference *or=NULL,*orl=NULL;
unsigned char *ptr=flat;
/* build buffer chain */
@@ -1510,9 +1510,9 @@
if(ilen>count2)ilen=count2;
if(or)
- orl=ogg_buffer_extend(orl,ilen+ibegin);
+ orl=ogg2_buffer_extend(orl,ilen+ibegin);
else
- or=orl=ogg_buffer_alloc(bs,ilen+ibegin);
+ or=orl=ogg2_buffer_alloc(bs,ilen+ibegin);
memcpy(orl->buffer->data+ibegin,ptr,ilen);
@@ -1523,7 +1523,7 @@
ptr+=ilen;
}
- if(ogg_buffer_length(or)!=(bitcount+7)/8){
+ if(ogg2_buffer_length(or)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after build.\n");
exit(1);
}
@@ -1539,16 +1539,16 @@
bitcount+=len[j];
/* also exercise the split code */
{
- ogg_reference *temp=ogg_buffer_split(&or,0,bitcount/8);
- ogg_buffer_release(temp);
+ ogg2_reference *temp=ogg2_buffer_split(&or,0,bitcount/8);
+ ogg2_buffer_release(temp);
}
bitoffset=bitcount%=8;
for(;j<begin+ilen;j++)
bitcount+=len[j];
- ogg_buffer_posttruncate(or,((bitcount+7)/8));
+ ogg2_buffer_posttruncate(or,((bitcount+7)/8));
- if((count=ogg_buffer_length(or))!=(bitcount+7)/8){
+ if((count=ogg2_buffer_length(or))!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after truncate.\n");
exit(1);
}
@@ -1643,12 +1643,12 @@
_end_verify4(count);
}
- ogg_buffer_release(or);
+ ogg2_buffer_release(or);
}
}
fprintf(stderr,"\rRandomized testing (MSb)... ok. \n");
- ogg_buffer_destroy(bs);
+ ogg2_buffer_destroy(bs);
return(0);
}
#endif /* _V_SELFTEST */
Modified: branches/ogg2-arc/src/buffer.c
===================================================================
--- branches/ogg2-arc/src/buffer.c 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/buffer.c 2005-03-02 11:40:48 UTC (rev 9005)
@@ -30,9 +30,9 @@
/* management is here; actual production and consumption of data is
found in the rest of the libogg code */
-ogg_buffer_state *ogg_buffer_create(void){
- ogg_buffer_state *bs=_ogg_calloc(1,sizeof(*bs));
- ogg_mutex_init(&bs->mutex);
+ogg2_buffer_state *ogg2_buffer_create(void){
+ ogg2_buffer_state *bs=_ogg_calloc(1,sizeof(*bs));
+ ogg2_mutex_init(&bs->mutex);
return bs;
}
@@ -43,9 +43,9 @@
finish destruction. */
/* call the helper while holding lock */
-static void _ogg_buffer_destroy(ogg_buffer_state *bs){
- ogg_buffer *bt;
- ogg_reference *rt;
+static void _ogg2_buffer_destroy(ogg2_buffer_state *bs){
+ ogg2_buffer *bt;
+ ogg2_reference *rt;
if(bs->shutdown){
@@ -60,22 +60,22 @@
rt=bs->unused_references;
if(!bs->outstanding){
- ogg_mutex_unlock(&bs->mutex);
- ogg_mutex_clear(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
+ ogg2_mutex_clear(&bs->mutex);
_ogg_free(bs);
return;
}else
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
while(bt){
- ogg_buffer *b=bt;
+ ogg2_buffer *b=bt;
bt=b->ptr.next;
if(b->data)_ogg_free(b->data);
_ogg_free(b);
}
bs->unused_buffers=0;
while(rt){
- ogg_reference *r=rt;
+ ogg2_reference *r=rt;
rt=r->next;
_ogg_free(r);
}
@@ -83,22 +83,22 @@
}
}
-void ogg_buffer_destroy(ogg_buffer_state *bs){
- ogg_mutex_lock(&bs->mutex);
+void ogg2_buffer_destroy(ogg2_buffer_state *bs){
+ ogg2_mutex_lock(&bs->mutex);
bs->shutdown=1;
- _ogg_buffer_destroy(bs);
+ _ogg2_buffer_destroy(bs);
}
-static ogg_buffer *_fetch_buffer(ogg_buffer_state *bs,long bytes){
- ogg_buffer *ob;
- ogg_mutex_lock(&bs->mutex);
+static ogg2_buffer *_fetch_buffer(ogg2_buffer_state *bs,long bytes){
+ ogg2_buffer *ob;
+ ogg2_mutex_lock(&bs->mutex);
bs->outstanding++;
/* do we have an unused buffer sitting in the pool? */
if(bs->unused_buffers){
ob=bs->unused_buffers;
bs->unused_buffers=ob->ptr.next;
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
/* if the unused buffer is too small, grow it */
if(ob->size<bytes){
@@ -107,10 +107,10 @@
}
}else{
/* allocate a new buffer */
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
ob=_ogg_malloc(sizeof(*ob));
- ob->data=_ogg_malloc(bytes<OGGPACK_MINCHUNKSIZE?
- OGGPACK_MINCHUNKSIZE:bytes);
+ ob->data=_ogg_malloc(bytes<OGG2PACK_MINCHUNKSIZE?
+ OGG2PACK_MINCHUNKSIZE:bytes);
ob->size=bytes;
}
@@ -119,19 +119,19 @@
return ob;
}
-static ogg_reference *_fetch_ref(ogg_buffer_state *bs){
- ogg_reference *or;
- ogg_mutex_lock(&bs->mutex);
+static ogg2_reference *_fetch_ref(ogg2_buffer_state *bs){
+ ogg2_reference *or;
+ ogg2_mutex_lock(&bs->mutex);
bs->outstanding++;
/* do we have an unused reference sitting in the pool? */
if(bs->unused_references){
or=bs->unused_references;
bs->unused_references=or->next;
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
}else{
/* allocate a new reference */
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
or=_ogg_malloc(sizeof(*or));
}
@@ -146,16 +146,16 @@
/* fetch a reference pointing to a fresh, initially continguous buffer
of at least [bytes] length */
-ogg_reference *ogg_buffer_alloc(ogg_buffer_state *bs,long bytes){
- ogg_buffer *ob=_fetch_buffer(bs,bytes);
- ogg_reference *or=_fetch_ref(bs);
+ogg2_reference *ogg2_buffer_alloc(ogg2_buffer_state *bs,long bytes){
+ ogg2_buffer *ob=_fetch_buffer(bs,bytes);
+ ogg2_reference *or=_fetch_ref(bs);
or->buffer=ob;
return or;
}
/* enlarge the data buffer in the current link */
-void ogg_buffer_realloc(ogg_reference *or,long bytes){
- ogg_buffer *ob=or->buffer;
+void ogg2_buffer_realloc(ogg2_reference *or,long bytes){
+ ogg2_buffer *ob=or->buffer;
/* if the unused buffer is too small, grow it */
if(ob->size<bytes){
@@ -169,8 +169,8 @@
of range, NULL is returned; if the desired segment is simply zero
length, a zero length ref is returned. Partial range overlap
returns the overlap of the ranges */
-ogg_reference *ogg_buffer_sub(ogg_reference *or,long begin,long length){
- ogg_reference *ret=0,*head=0;
+ogg2_reference *ogg2_buffer_sub(ogg2_reference *or,long begin,long length){
+ ogg2_reference *ret=0,*head=0;
/* walk past any preceeding fragments we don't want */
while(or && begin>=or->length){
@@ -186,7 +186,7 @@
/* duplicate the reference chain; increment refcounts */
while(or && length){
- ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner);
+ ogg2_reference *temp=_fetch_ref(or->buffer->ptr.owner);
if(head)
head->next=temp;
else
@@ -212,16 +212,16 @@
or=or->next;
}
- ogg_buffer_mark(ret);
+ ogg2_buffer_mark(ret);
return ret;
}
-ogg_reference *ogg_buffer_dup(ogg_reference *or){
- ogg_reference *ret=0,*head=0;
+ogg2_reference *ogg2_buffer_dup(ogg2_reference *or){
+ ogg2_reference *ret=0,*head=0;
/* duplicate the reference chain; increment refcounts */
while(or){
- ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner);
+ ogg2_reference *temp=_fetch_ref(or->buffer->ptr.owner);
if(head)
head->next=temp;
else
@@ -241,13 +241,13 @@
or=or->next;
}
- ogg_buffer_mark(ret);
+ ogg2_buffer_mark(ret);
return ret;
}
-static void _ogg_buffer_mark_one(ogg_reference *or){
- ogg_buffer_state *bs=or->buffer->ptr.owner;
- ogg_mutex_lock(&bs->mutex); /* lock now in case someone is mixing
+static void _ogg2_buffer_mark_one(ogg2_reference *or){
+ ogg2_buffer_state *bs=or->buffer->ptr.owner;
+ ogg2_mutex_lock(&bs->mutex); /* lock now in case someone is mixing
pools */
#ifdef OGGBUFFER_DEBUG
@@ -262,21 +262,21 @@
#endif
or->buffer->refcount++;
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
}
/* split a reference into two references; 'return' is a reference to
the buffer preceeding pos and 'head'/'tail' are the buffer past the
split. If pos is at or past the end of the passed in segment,
'head/tail' are NULL */
-ogg_reference *ogg_buffer_split(ogg_reference **tail,
- ogg_reference **head,long pos){
+ogg2_reference *ogg2_buffer_split(ogg2_reference **tail,
+ ogg2_reference **head,long pos){
/* walk past any preceeding fragments to one of:
a) the exact boundary that seps two fragments
b) the fragment that needs split somewhere in the middle */
- ogg_reference *ret=*tail;
- ogg_reference *or=*tail;
+ ogg2_reference *ret=*tail;
+ ogg2_reference *or=*tail;
while(or && pos>or->length){
#ifdef OGGBUFFER_DEBUG
@@ -323,7 +323,7 @@
(*tail)->begin=beginB;
(*tail)->length=lengthB;
(*tail)->next=or->next;
- _ogg_buffer_mark_one(*tail);
+ _ogg2_buffer_mark_one(*tail);
if(head && or==*head)*head=*tail;
/* update the first piece */
@@ -336,7 +336,7 @@
}
/* add a new fragment link to the end of a chain; return ptr to the new link */
-ogg_reference *ogg_buffer_extend(ogg_reference *or,long bytes){
+ogg2_reference *ogg2_buffer_extend(ogg2_reference *or,long bytes){
if(or){
#ifdef OGGBUFFER_DEBUG
if(or->used==0){
@@ -353,33 +353,33 @@
}
#endif
}
- or->next=ogg_buffer_alloc(or->buffer->ptr.owner,bytes);
+ or->next=ogg2_buffer_alloc(or->buffer->ptr.owner,bytes);
return(or->next);
}
return 0;
}
/* increase the refcount of the buffers to which the reference points */
-void ogg_buffer_mark(ogg_reference *or){
+void ogg2_buffer_mark(ogg2_reference *or){
while(or){
- _ogg_buffer_mark_one(or);
+ _ogg2_buffer_mark_one(or);
or=or->next;
}
}
-void ogg_buffer_release_one(ogg_reference *or){
- ogg_buffer *ob=or->buffer;
- ogg_buffer_state *bs=ob->ptr.owner;
- ogg_mutex_lock(&bs->mutex);
+void ogg2_buffer_release_one(ogg2_reference *or){
+ ogg2_buffer *ob=or->buffer;
+ ogg2_buffer_state *bs=ob->ptr.owner;
+ ogg2_mutex_lock(&bs->mutex);
#ifdef OGGBUFFER_DEBUG
if(ob->refcount==0){
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
fprintf(stderr,"WARNING: releasing buffer fragment with refcount of zero!\n");
exit(1);
}
if(or->used==0){
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
fprintf(stderr,"WARNING: releasing previously released reference!\n");
exit(1);
}
@@ -396,28 +396,28 @@
bs->outstanding--; /* for the returned reference */
or->next=bs->unused_references;
bs->unused_references=or;
- ogg_mutex_unlock(&bs->mutex);
+ ogg2_mutex_unlock(&bs->mutex);
- _ogg_buffer_destroy(bs); /* lazy cleanup (if needed) */
+ _ogg2_buffer_destroy(bs); /* lazy cleanup (if needed) */
}
/* release the references, decrease the refcounts of buffers to which
they point, release any buffers with a refcount that drops to zero */
-void ogg_buffer_release(ogg_reference *or){
+void ogg2_buffer_release(ogg2_reference *or){
while(or){
- ogg_reference *next=or->next;
- ogg_buffer_release_one(or);
+ ogg2_reference *next=or->next;
+ ogg2_buffer_release_one(or);
or=next;
}
}
-ogg_reference *ogg_buffer_pretruncate(ogg_reference *or,long pos){
+ogg2_reference *ogg2_buffer_pretruncate(ogg2_reference *or,long pos){
/* release preceeding fragments we don't want */
while(or && pos>=or->length){
- ogg_reference *next=or->next;
+ ogg2_reference *next=or->next;
pos-=or->length;
- ogg_buffer_release_one(or);
+ ogg2_buffer_release_one(or);
or=next;
}
if (or) {
@@ -433,7 +433,7 @@
return or;
}
-void ogg_buffer_posttruncate(ogg_reference *or,long pos){
+void ogg2_buffer_posttruncate(ogg2_reference *or,long pos){
/* walk to the point where we want to begin truncate */
while(or && pos>or->length){
#ifdef OGGBUFFER_DEBUG
@@ -447,14 +447,14 @@
}
if(or){
/* release or->next and beyond */
- ogg_buffer_release(or->next);
+ ogg2_buffer_release(or->next);
or->next=0;
/* update length fencepost */
or->length=pos;
}
}
-ogg_reference *ogg_buffer_walk(ogg_reference *or){
+ogg2_reference *ogg2_buffer_walk(ogg2_reference *or){
if(!or)return NULL;
while(or->next){
#ifdef OGGBUFFER_DEBUG
@@ -476,7 +476,7 @@
/* *head is appended to the front end (head) of *tail; both continue to
be valid pointers, with *tail at the tail and *head at the head */
-ogg_reference *ogg_buffer_cat(ogg_reference *tail, ogg_reference *head){
+ogg2_reference *ogg2_buffer_cat(ogg2_reference *tail, ogg2_reference *head){
if(!tail)return head;
while(tail->next){
@@ -495,10 +495,10 @@
}
#endif
tail->next=head;
- return ogg_buffer_walk(head);
+ return ogg2_buffer_walk(head);
}
-long ogg_buffer_length(ogg_reference *or){
+long ogg2_buffer_length(ogg2_reference *or){
int count=0;
while(or){
#ifdef OGGBUFFER_DEBUG
@@ -513,7 +513,7 @@
return count;
}
-void ogg_buffer_outstanding(ogg_buffer_state *bs){
+void ogg2_buffer_outstanding(ogg2_buffer_state *bs){
#ifdef OGGBUFFER_DEBUG
fprintf(stderr,"Zero-copy pool %p: %d buffers outstanding.\n",
bs,bs->outstanding);
Modified: branches/ogg2-arc/src/bytewise.c
===================================================================
--- branches/ogg2-arc/src/bytewise.c 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/bytewise.c 2005-03-02 11:40:48 UTC (rev 9005)
@@ -22,7 +22,7 @@
/* this is an internal abstraction, and it is not guarded from misuse
or botching a fencepost. */
-static void _positionB(oggbyte_buffer *b,int pos){
+static void _positionB(ogg2byte_buffer *b,int pos){
if(pos<b->pos){
/* start at beginning, scan forward */
b->ref=b->baseref;
@@ -32,7 +32,7 @@
}
}
-static void _positionF(oggbyte_buffer *b,int pos){
+static void _positionF(ogg2byte_buffer *b,int pos){
/* scan forward for position */
while(pos>=b->end){
/* just seek forward */
@@ -43,7 +43,7 @@
}
}
-static void _positionFE(oggbyte_buffer *b,int pos){
+static void _positionFE(ogg2byte_buffer *b,int pos){
/* scan forward for position */
while(pos>=b->end){
if(!b->ref->next){
@@ -58,7 +58,7 @@
b->ref->length=b->ref->buffer->size-b->ref->begin;
/* extend the array and span */
b->pos+=b->ref->length;
- b->ref=ogg_buffer_extend(b->ref,OGGPACK_CHUNKSIZE);
+ b->ref=ogg2_buffer_extend(b->ref,OGG2PACK_CHUNKSIZE);
b->end=b->pos;
b->ptr=b->ref->buffer->data+b->ref->begin;
}
@@ -74,12 +74,12 @@
}
}
-int oggbyte_init(oggbyte_buffer *b,ogg_reference *or,ogg_buffer_state *bs){
+int ogg2byte_init(ogg2byte_buffer *b,ogg2_reference *or,ogg2_buffer_state *bs){
memset(b,0,sizeof(*b));
if(!or){
if(!bs)return -1;
- or=ogg_buffer_alloc(bs,OGGPACK_CHUNKSIZE);
+ or=ogg2_buffer_alloc(bs,OGG2PACK_CHUNKSIZE);
}else{
b->external=1;
}
@@ -93,27 +93,27 @@
return(0);
}
-ogg_reference *oggbyte_return_and_reset(oggbyte_buffer *b){
+ogg2_reference *ogg2byte_return_and_reset(ogg2byte_buffer *b){
if(!b->external){
- ogg_reference *ret=b->baseref;
+ ogg2_reference *ret=b->baseref;
memset(b,0,sizeof(*b));
return(ret);
}
return(NULL);
}
-void oggbyte_clear(oggbyte_buffer *b){
- if(!b->external)ogg_buffer_release(b->baseref);
+void ogg2byte_clear(ogg2byte_buffer *b){
+ if(!b->external)ogg2_buffer_release(b->baseref);
memset(b,0,sizeof(*b));
}
-void oggbyte_set1(oggbyte_buffer *b,unsigned char val,int pos){
+void ogg2byte_set1(ogg2byte_buffer *b,unsigned char val,int pos){
_positionB(b,pos);
_positionFE(b,pos);
b->ptr[pos-b->pos]=val;
}
-void oggbyte_set2(oggbyte_buffer *b,int val,int pos){
+void ogg2byte_set2(ogg2byte_buffer *b,int val,int pos){
_positionB(b,pos);
_positionFE(b,pos);
b->ptr[pos-b->pos]=val;
@@ -121,7 +121,7 @@
b->ptr[pos-b->pos]=val>>8;
}
-void oggbyte_set4(oggbyte_buffer *b,ogg_uint32_t val,int pos){
+void ogg2byte_set4(ogg2byte_buffer *b,ogg_uint32_t val,int pos){
int i;
_positionB(b,pos);
for(i=0;i<4;i++){
@@ -132,7 +132,7 @@
}
}
-void oggbyte_set8(oggbyte_buffer *b,ogg_int64_t val,int pos){
+void ogg2byte_set8(ogg2byte_buffer *b,ogg_int64_t val,int pos){
int i;
_positionB(b,pos);
for(i=0;i<8;i++){
@@ -143,13 +143,13 @@
}
}
-unsigned char oggbyte_read1(oggbyte_buffer *b,int pos){
+unsigned char ogg2byte_read1(ogg2byte_buffer *b,int pos){
_positionB(b,pos);
_positionF(b,pos);
return b->ptr[pos-b->pos];
}
-int oggbyte_read2(oggbyte_buffer *b,int pos){
+int ogg2byte_read2(ogg2byte_buffer *b,int pos){
int ret;
_positionB(b,pos);
_positionF(b,pos);
@@ -158,7 +158,7 @@
return ret|b->ptr[pos-b->pos]<<8;
}
-ogg_uint32_t oggbyte_read4(oggbyte_buffer *b,int pos){
+ogg_uint32_t ogg2byte_read4(ogg2byte_buffer *b,int pos){
ogg_uint32_t ret;
_positionB(b,pos);
_positionF(b,pos);
@@ -172,7 +172,7 @@
return ret;
}
-ogg_int64_t oggbyte_read8(oggbyte_buffer *b,int pos){
+ogg_int64_t ogg2byte_read8(ogg2byte_buffer *b,int pos){
ogg_int64_t ret;
unsigned char t[7];
int i;
@@ -199,15 +199,15 @@
unsigned char ref[TESTBYTES];
unsigned char work[TESTBYTES];
-ogg_buffer_state *bs;
+ogg2_buffer_state *bs;
-void _read_linear_test1(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_linear_test1(ogg2_reference *or){
+ ogg2byte_buffer obb;
int j;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(j=0;j<TESTBYTES;j++){
- unsigned char ret=oggbyte_read1(&obb,j);
+ unsigned char ret=ogg2byte_read1(&obb,j);
if(ref[j]!=ret){
fprintf(stderr,"\nERROR: %02x != %02x, position %d\n\n",
ref[j],ret,j);
@@ -216,14 +216,14 @@
}
}
-void _read_linear_test1b(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_linear_test1b(ogg2_reference *or){
+ ogg2byte_buffer obb;
int j;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(j=0;j<TESTBYTES;j++){
if(work[j]){
- unsigned char ret=oggbyte_read1(&obb,j);
+ unsigned char ret=ogg2byte_read1(&obb,j);
if(ref[j]!=ret){
fprintf(stderr,"\nERROR: %02x != %02x, position %d\n\n",
ref[j],ret,j);
@@ -233,13 +233,13 @@
}
}
-void _read_linear_test2(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_linear_test2(ogg2_reference *or){
+ ogg2byte_buffer obb;
int j;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(j=0;j+1<TESTBYTES;j++){
- int ret=oggbyte_read2(&obb,j);
+ int ret=ogg2byte_read2(&obb,j);
if(ref[j]!=(ret&0xff) || ref[j+1]!=((ret>>8)&0xff)){
fprintf(stderr,"\nERROR: %02x%02x != %04x, position %d\n\n",
ref[j+1],ref[j],ret,j);
@@ -248,14 +248,14 @@
}
}
-void _read_linear_test4(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_linear_test4(ogg2_reference *or){
+ ogg2byte_buffer obb;
int j;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(j=0;j+3<TESTBYTES;j++){
- ogg_uint32_t ret=oggbyte_read4(&obb,j);
+ ogg_uint32_t ret=ogg2byte_read4(&obb,j);
if(ref[j]!=(ret&0xff) ||
ref[j+1]!=((ret>>8)&0xff) ||
ref[j+2]!=((ret>>16)&0xff) ||
@@ -268,11 +268,11 @@
}
}
-void _read_linear_test8(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_linear_test8(ogg2_reference *or){
+ ogg2byte_buffer obb;
int j;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(j=0;j+7<TESTBYTES;j++){
ogg_int64_t ret=ref[j+7];
@@ -284,9 +284,9 @@
ret=(ret<<8)|ref[j+1];
ret=(ret<<8)|ref[j];
- if(ret!=oggbyte_read8(&obb,j)){
+ if(ret!=ogg2byte_read8(&obb,j)){
int i;
- ret=oggbyte_read8(&obb,j);
+ ret=ogg2byte_read8(&obb,j);
fprintf(stderr,"\nERROR: %02x%02x%02x%02x%02x%02x%02x%02x != ",
ref[j+7],ref[j+6],ref[j+5],ref[j+4],
ref[j+3],ref[j+2],ref[j+1],ref[j]);
@@ -303,18 +303,18 @@
}
}
-void _read_seek_test(ogg_reference *or){
- oggbyte_buffer obb;
+void _read_seek_test(ogg2_reference *or){
+ ogg2byte_buffer obb;
int i,j;
int length=TESTBYTES;
unsigned char *lref=ref;
- oggbyte_init(&obb,or,0);
+ ogg2byte_init(&obb,or,0);
for(i=0;i<TESTBYTES;i++){
unsigned char ret;
j=rand()%length;
- ret=oggbyte_read1(&obb,j);
+ ret=ogg2byte_read1(&obb,j);
if(lref[j]!=ret){
fprintf(stderr,"\nERROR: %02x != %02x, position %d\n\n",
lref[j],ret,j);
@@ -325,7 +325,7 @@
for(i=0;i<TESTBYTES;i++){
int ret;
j=rand()%(length-1);
- ret=oggbyte_read2(&obb,j);
+ ret=ogg2byte_read2(&obb,j);
if(lref[j]!=(ret&0xff) || lref[j+1]!=((ret>>8)&0xff)){
fprintf(stderr,"\nERROR: %02x%02x != %04x, position %d\n\n",
lref[j+1],lref[j],ret,j);
@@ -336,7 +336,7 @@
for(i=0;i<TESTBYTES;i++){
ogg_uint32_t ret;
j=rand()%(length-3);
- ret=oggbyte_read4(&obb,j);
+ ret=ogg2byte_read4(&obb,j);
if(lref[j]!=(ret&0xff) ||
lref[j+1]!=((ret>>8)&0xff) ||
lref[j+2]!=((ret>>16)&0xff) ||
@@ -360,9 +360,9 @@
ret=(ret<<8)|lref[j+1];
ret=(ret<<8)|lref[j];
- if(ret!=oggbyte_read8(&obb,j)){
+ if(ret!=ogg2byte_read8(&obb,j)){
int i;
- ret=oggbyte_read8(&obb,j);
+ ret=ogg2byte_read8(&obb,j);
fprintf(stderr,"\nERROR: %02x%02x%02x%02x%02x%02x%02x%02x != ",
lref[j+7],lref[j+6],lref[j+5],lref[j+4],
lref[j+3],lref[j+2],lref[j+1],lref[j]);
@@ -379,14 +379,14 @@
}
}
-void _head_prep(ogg_reference *head){
+void _head_prep(ogg2_reference *head){
int count=0;
while(head){
memset(head->buffer->data,0,head->buffer->size);
count+=head->length;
if(count>TESTBYTES/2+rand()%(TESTBYTES/4)){
- ogg_buffer_release(head->next);
+ ogg2_buffer_release(head->next);
head->next=0;
break;
}else{
@@ -395,90 +395,90 @@
}
}
-void _write_linear_test(ogg_reference *tail){
- oggbyte_buffer ob;
+void _write_linear_test(ogg2_reference *tail){
+ ogg2byte_buffer ob;
int i;
_head_prep(tail);
- oggbyte_init(&ob,tail,0);
+ ogg2byte_init(&ob,tail,0);
for(i=0;i<TESTBYTES;i++)
- oggbyte_set1(&ob,ref[i],i);
+ ogg2byte_set1(&ob,ref[i],i);
_read_linear_test1(tail);
- if(ogg_buffer_length(tail)!=TESTBYTES){
- fprintf(stderr,"\nERROR: oggbyte_set1 extended incorrectly.\n\n");
+ if(ogg2_buffer_length(tail)!=TESTBYTES){
+ fprintf(stderr,"\nERROR: ogg2byte_set1 extended incorrectly.\n\n");
exit(1);
}
_head_prep(tail);
- oggbyte_init(&ob,tail,0);
+ ogg2byte_init(&ob,tail,0);
for(i=0;i<TESTBYTES;i+=2){
unsigned int val=ref[i]|(ref[i+1]<<8);
- oggbyte_set2(&ob,val,i);
+ ogg2byte_set2(&ob,val,i);
}
_read_linear_test1(tail);
- if(ogg_buffer_length(tail)>TESTBYTES){
- fprintf(stderr,"\nERROR: oggbyte_set2 extended incorrectly.\n\n");
+ if(ogg2_buffer_length(tail)>TESTBYTES){
+ fprintf(stderr,"\nERROR: ogg2byte_set2 extended incorrectly.\n\n");
exit(1);
}
_head_prep(tail);
- oggbyte_init(&ob,tail,0);
+ ogg2byte_init(&ob,tail,0);
for(i=0;i<TESTBYTES;i+=4){
unsigned long val=ref[i+2]|(ref[i+3]<<8);
val=(val<<16)|ref[i]|(ref[i+1]<<8);
- oggbyte_set4(&ob,val,i);
+ ogg2byte_set4(&ob,val,i);
}
_read_linear_test1(tail);
- if(ogg_buffer_length(tail)>TESTBYTES){
- fprintf(stderr,"\nERROR: oggbyte_set4 extended incorrectly.\n\n");
+ if(ogg2_buffer_length(tail)>TESTBYTES){
+ fprintf(stderr,"\nERROR: ogg2byte_set4 extended incorrectly.\n\n");
exit(1);
}
_head_prep(tail);
- oggbyte_init(&ob,tail,0);
+ ogg2byte_init(&ob,tail,0);
for(i=0;i<TESTBYTES;i+=8){
ogg_int64_t val=ref[i+6]|(ref[i+7]<<8);
val=(val<<16)|ref[i+4]|(ref[i+5]<<8);
val=(val<<16)|ref[i+2]|(ref[i+3]<<8);
val=(val<<16)|ref[i]|(ref[i+1]<<8);
- oggbyte_set8(&ob,val,i);
+ ogg2byte_set8(&ob,val,i);
}
_read_linear_test1(tail);
- if(ogg_buffer_length(tail)>TESTBYTES){
- fprintf(stderr,"\nERROR: oggbyte_set8 extended incorrectly.\n\n");
+ if(ogg2_buffer_length(tail)>TESTBYTES){
+ fprintf(stderr,"\nERROR: ogg2byte_set8 extended incorrectly.\n\n");
exit(1);
}
}
void _write_zero_test(void){
- oggbyte_buffer ob;
+ ogg2byte_buffer ob;
int i;
- oggbyte_init(&ob,0,bs);
+ ogg2byte_init(&ob,0,bs);
for(i=0;i<TESTBYTES;i++)
- oggbyte_set1(&ob,ref[i],i);
+ ogg2byte_set1(&ob,ref[i],i);
_read_linear_test1(ob.baseref);
- if(ogg_buffer_length(ob.baseref)!=TESTBYTES){
- fprintf(stderr,"\nERROR: oggbyte_set1 extended incorrectly.\n\n");
+ if(ogg2_buffer_length(ob.baseref)!=TESTBYTES){
+ fprintf(stderr,"\nERROR: ogg2byte_set1 extended incorrectly.\n\n");
exit(1);
}
}
void _write_seek_test(void){
- oggbyte_buffer ob;
+ ogg2byte_buffer ob;
int i;
memset(work,0,TESTBYTES);
- oggbyte_init(&ob,0,bs);
+ ogg2byte_init(&ob,0,bs);
for(i=0;i<TESTBYTES;i++){
int j=rand()%TESTBYTES;
- oggbyte_set1(&ob,ref[j],j);
+ ogg2byte_set1(&ob,ref[j],j);
work[j]=1;
}
@@ -487,7 +487,7 @@
int main(void){
int i,j;
- bs=ogg_buffer_create();
+ bs=ogg2_buffer_create();
/* test all codepaths through randomly generated data set */
fprintf(stderr,"\nRandomized testing of byte aligned access abstraction: \n");
@@ -501,8 +501,8 @@
/* test basic reading using single synthetic reference 1,2,4,8 */
fprintf(stderr,"\r\t loops left (%d), basic read test... ",1000-i);
{
- ogg_buffer ob;
- ogg_reference or;
+ ogg2_buffer ob;
+ ogg2_reference or;
ob.data=ref;
ob.size=TESTBYTES;
@@ -519,8 +519,8 @@
/* test basic reading using multiple synthetic refs 1,2,4,8 */
fprintf(stderr,"\r\t loops left (%d), fragmented read test... ",1000-i);
{
- ogg_reference *tail=0;
- ogg_reference *head=0;
+ ogg2_reference *tail=0;
+ ogg2_reference *head=0;
long count=0;
@@ -532,9 +532,9 @@
if(length>TESTBYTES-count)length=TESTBYTES-count;
if(tail)
- head=ogg_buffer_extend(head,begin+length+pad);
+ head=ogg2_buffer_extend(head,begin+length+pad);
else
- tail=head=ogg_buffer_alloc(bs,begin+length+pad);
+ tail=head=ogg2_buffer_alloc(bs,begin+length+pad);
memcpy(head->buffer->data+begin,ref+count,length);
head->begin=begin;
@@ -555,7 +555,7 @@
fprintf(stderr,"\r\t loops left (%d), linear write test... ",1000-i);
_write_linear_test(tail);
- ogg_buffer_release(tail);
+ ogg2_buffer_release(tail);
}
/* test writing, init blank reference */
@@ -570,7 +570,7 @@
}
fprintf(stderr,"\r\t all tests ok. \n\n");
- ogg_buffer_destroy(bs);
+ ogg2_buffer_destroy(bs);
return 0;
}
Modified: branches/ogg2-arc/src/mutex.h
===================================================================
--- branches/ogg2-arc/src/mutex.h 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/mutex.h 2005-03-02 11:40:48 UTC (rev 9005)
@@ -22,29 +22,29 @@
Mutexing code isn't requird for a platform, it's only required to
use threads with libogg and oggfile. */
-#ifndef _OGG_MUTEX_H_
-#define _OGG_MUTEX_H_
+#ifndef _OGG2_MUTEX_H_
+#define _OGG2_MUTEX_H_
#ifdef USE_POSIX_THREADS
#define _REENTRANT 1
#include <pthread.h>
-typedef pthread_mutex_t ogg_mutex_t;
-#define ogg_mutex_init(m) (pthread_mutex_init((m),NULL))
-#define ogg_mutex_clear(m) (pthread_mutex_destroy(m))
-#define ogg_mutex_lock(m) (pthread_mutex_lock(m))
-#define ogg_mutex_unlock(m) (pthread_mutex_unlock(m))
+typedef pthread_mutex_t ogg2_mutex_t;
+#define ogg2_mutex_init(m) (pthread_mutex_init((m),NULL))
+#define ogg2_mutex_clear(m) (pthread_mutex_destroy(m))
+#define ogg2_mutex_lock(m) (pthread_mutex_lock(m))
+#define ogg2_mutex_unlock(m) (pthread_mutex_unlock(m))
#elif USE_NO_THREADS
-typedef int ogg_mutex_t;
+typedef int ogg2_mutex_t;
#define noop() do {} while(0)
-#define ogg_mutex_init(m) noop()
-#define ogg_mutex_clear(m) noop()
-#define ogg_mutex_lock(m) noop()
-#define ogg_mutex_unlock(m) noop()
+#define ogg2_mutex_init(m) noop()
+#define ogg2_mutex_clear(m) noop()
+#define ogg2_mutex_lock(m) noop()
+#define ogg2_mutex_unlock(m) noop()
#else
#error "configure proper threading wrappers for this platform, or compile with -DUSE_NO_THREADS to build without threading support."
#endif
-#endif /*_OGG_MUTEX_H_*/
+#endif /*_OGG2_MUTEX_H_*/
Modified: branches/ogg2-arc/src/ogginternal.h
===================================================================
--- branches/ogg2-arc/src/ogginternal.h 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/ogginternal.h 2005-03-02 11:40:48 UTC (rev 9005)
@@ -15,76 +15,76 @@
********************************************************************/
-#ifndef _OGGI_H
-#define _OGGI_H
+#ifndef _OGG2I_H
+#define _OGG2I_H
#include <ogg2/ogg.h>
#include "mutex.h"
-struct ogg_buffer_state{
- ogg_buffer *unused_buffers;
- ogg_reference *unused_references;
+struct ogg2_buffer_state{
+ ogg2_buffer *unused_buffers;
+ ogg2_reference *unused_references;
int outstanding;
- ogg_mutex_t mutex;
+ ogg2_mutex_t mutex;
int shutdown;
};
-struct ogg_buffer {
+struct ogg2_buffer {
unsigned char *data;
long size;
int refcount;
union {
- ogg_buffer_state *owner;
- ogg_buffer *next;
+ ogg2_buffer_state *owner;
+ ogg2_buffer *next;
} ptr;
};
-struct ogg_reference {
- struct ogg_buffer *buffer;
+struct ogg2_reference {
+ struct ogg2_buffer *buffer;
long begin;
long length;
- struct ogg_reference *next;
-#ifdef OGGBUFFER_DEBUG
+ struct ogg2_reference *next;
+#ifdef OGG2BUFFER_DEBUG
int used;
#endif
};
-struct oggpack_buffer {
+struct ogg2pack_buffer {
int headbit;
unsigned char *headptr;
long headend;
/* memory management */
- ogg_reference *head;
- ogg_reference *tail;
+ ogg2_reference *head;
+ ogg2_reference *tail;
/* render the byte/bit counter API constant time */
long count; /* doesn't count the tail */
- ogg_buffer_state *owner; /* useful on encode side */
+ ogg2_buffer_state *owner; /* useful on encode side */
};
-typedef struct oggbyte_buffer {
- ogg_reference *baseref;
+typedef struct ogg2byte_buffer {
+ ogg2_reference *baseref;
- ogg_reference *ref;
+ ogg2_reference *ref;
unsigned char *ptr;
long pos;
long end;
- ogg_buffer_state *owner; /* if it's to be extensible; encode side */
+ ogg2_buffer_state *owner; /* if it's to be extensible; encode side */
int external; /* did baseref come from outside? */
-} oggbyte_buffer;
+} ogg2byte_buffer;
-struct ogg_sync_state {
+struct ogg2_sync_state {
/* decode memory management pool */
- ogg_buffer_state *bufferpool;
+ ogg2_buffer_state *bufferpool;
/* stream buffers */
- ogg_reference *fifo_head;
- ogg_reference *fifo_tail;
+ ogg2_reference *fifo_head;
+ ogg2_reference *fifo_tail;
long fifo_fill;
/* stream sync management */
@@ -94,14 +94,14 @@
};
-struct ogg_stream_state {
+struct ogg2_stream_state {
/* encode memory management pool */
- ogg_buffer_state *bufferpool;
+ ogg2_buffer_state *bufferpool;
- ogg_reference *header_head;
- ogg_reference *header_tail;
- ogg_reference *body_head;
- ogg_reference *body_tail;
+ ogg2_reference *header_head;
+ ogg2_reference *header_tail;
+ ogg2_reference *body_head;
+ ogg2_reference *body_tail;
int e_o_s; /* set when we have buffered the last
packet in the logical bitstream */
@@ -122,7 +122,7 @@
/* encode-side header build */
unsigned int watermark;
- oggbyte_buffer header_build;
+ ogg2byte_buffer header_build;
int continued;
int packets;
@@ -135,50 +135,49 @@
};
-extern ogg_buffer_state *ogg_buffer_create(void);
-extern void ogg_buffer_destroy(ogg_buffer_state *bs);
-extern ogg_reference *ogg_buffer_alloc(ogg_buffer_state *bs,long bytes);
-extern void ogg_buffer_realloc(ogg_reference *or,long bytes);
-extern ogg_reference *ogg_buffer_sub(ogg_reference *or,long begin,long length);
-extern ogg_reference *ogg_buffer_dup(ogg_reference *or);
-extern ogg_reference *ogg_buffer_extend(ogg_reference *or,long bytes);
-extern void ogg_buffer_mark(ogg_reference *or);
-extern void ogg_buffer_release(ogg_reference *or);
-extern void ogg_buffer_release_one(ogg_reference *or);
-extern ogg_reference *ogg_buffer_pretruncate(ogg_reference *or,long pos);
-extern void ogg_buffer_posttruncate(ogg_reference *or,long pos);
-extern ogg_reference *ogg_buffer_cat(ogg_reference *tail, ogg_reference *head);
-extern ogg_reference *ogg_buffer_walk(ogg_reference *or);
-extern long ogg_buffer_length(ogg_reference *or);
-extern ogg_reference *ogg_buffer_split(ogg_reference **tail,
- ogg_reference **head,long pos);
-extern void ogg_buffer_outstanding(ogg_buffer_state *bs);
+extern ogg2_buffer_state *ogg2_buffer_create(void);
+extern void ogg2_buffer_destroy(ogg2_buffer_state *bs);
+extern ogg2_reference *ogg2_buffer_alloc(ogg2_buffer_state *bs,long bytes);
+extern void ogg2_buffer_realloc(ogg2_reference *or,long bytes);
+extern ogg2_reference *ogg2_buffer_sub(ogg2_reference *or,long begin,long length);
+extern ogg2_reference *ogg2_buffer_dup(ogg2_reference *or);
+extern ogg2_reference *ogg2_buffer_extend(ogg2_reference *or,long bytes);
+extern void ogg2_buffer_mark(ogg2_reference *or);
+extern void ogg2_buffer_release(ogg2_reference *or);
+extern void ogg2_buffer_release_one(ogg2_reference *or);
+extern ogg2_reference *ogg2_buffer_pretruncate(ogg2_reference *or,long pos);
+extern void ogg2_buffer_posttruncate(ogg2_reference *or,long pos);
+extern ogg2_reference *ogg2_buffer_cat(ogg2_reference *tail, ogg2_reference *head);
+extern ogg2_reference *ogg2_buffer_walk(ogg2_reference *or);
+extern long ogg2_buffer_length(ogg2_reference *or);
+extern ogg2_reference *ogg2_buffer_split(ogg2_reference **tail,
+ ogg2_reference **head,long pos);
+extern void ogg2_buffer_outstanding(ogg2_buffer_state *bs);
-extern int oggbyte_init(oggbyte_buffer *b,ogg_reference *or,
- ogg_buffer_state *bs);
-extern void oggbyte_clear(oggbyte_buffer *b);
-extern ogg_reference *oggbyte_return_and_reset(oggbyte_buffer *b);
-extern void oggbyte_set1(oggbyte_buffer *b,unsigned char val,
+extern int ogg2byte_init(ogg2byte_buffer *b,ogg2_reference *or,
+ ogg2_buffer_state *bs);
+extern void ogg2byte_clear(ogg2byte_buffer *b);
+extern ogg2_reference *ogg2byte_return_and_reset(ogg2byte_buffer *b);
+extern void ogg2byte_set1(ogg2byte_buffer *b,unsigned char val,
int pos);
-extern void oggbyte_set2(oggbyte_buffer *b,int val,int pos);
-extern void oggbyte_set4(oggbyte_buffer *b,ogg_uint32_t val,int pos);
-extern void oggbyte_set8(oggbyte_buffer *b,ogg_int64_t val,int pos);
-extern unsigned char oggbyte_read1(oggbyte_buffer *b,int pos);
-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);
+extern void ogg2byte_set2(ogg2byte_buffer *b,int val,int pos);
+extern void ogg2byte_set4(ogg2byte_buffer *b,ogg_uint32_t val,int pos);
+extern void ogg2byte_set8(ogg2byte_buffer *b,ogg_int64_t val,int pos);
+extern unsigned char ogg2byte_read1(ogg2byte_buffer *b,int pos);
+extern int ogg2byte_read2(ogg2byte_buffer *b,int pos);
+extern ogg_uint32_t ogg2byte_read4(ogg2byte_buffer *b,int pos);
+extern ogg_int64_t ogg2byte_read8(ogg2byte_buffer *b,int pos);
+extern int ogg2_page_checksum_set(ogg2_page *og);
#ifdef _V_SELFTEST
-#define OGGPACK_CHUNKSIZE 3
-#define OGGPACK_MINCHUNKSIZE 1
+#define OGG2PACK_CHUNKSIZE 3
+#define OGG2PACK_MINCHUNKSIZE 1
#else
-#define OGGPACK_CHUNKSIZE 128
-#define OGGPACK_MINCHUNKSIZE 16
+#define OGG2PACK_CHUNKSIZE 128
+#define OGG2PACK_MINCHUNKSIZE 16
#endif
#endif
-
Modified: branches/ogg2-arc/src/stream.c
===================================================================
--- branches/ogg2-arc/src/stream.c 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/stream.c 2005-03-02 11:40:48 UTC (rev 9005)
@@ -23,15 +23,15 @@
/* A complete description of Ogg framing exists in docs/framing.html */
-ogg_stream_state *ogg_stream_create(int serialno){
- ogg_stream_state *os=_ogg_calloc(1,sizeof(*os));
+ogg2_stream_state *ogg2_stream_create(int serialno){
+ ogg2_stream_state *os=_ogg_calloc(1,sizeof(*os));
os->watermark=4096;
os->serialno=serialno;
- os->bufferpool=ogg_buffer_create();
+ os->bufferpool=ogg2_buffer_create();
return os;
}
-int ogg_stream_setmode(ogg_stream_state *os, int mode){
+int ogg2_stream_setmode(ogg2_stream_state *os, int mode){
/* I don't know what extra modes may be needed, but we might as well
provide support for them in the API. */
@@ -39,67 +39,67 @@
if(mode&1){
if(os->pageno==0||(os->pageno==1&&os->packets==0)){
os->mode=mode;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
}
- return OGG_EMODE;
+ return OGG2_EMODE;
}
-int ogg_stream_setfill(ogg_stream_state *os,int watermark){
+int ogg2_stream_setfill(ogg2_stream_state *os,int watermark){
if(os){
if(watermark>65535)watermark=65535;
os->watermark=watermark;
return watermark;
}
- return OGG_EINVAL;
+ return OGG2_EINVAL;
}
/* _clear does not free os, only the non-flat storage within */
-int ogg_stream_destroy(ogg_stream_state *os){
+int ogg2_stream_destroy(ogg2_stream_state *os){
if(os){
- ogg_buffer_release(os->header_tail);
- ogg_buffer_release(os->body_tail);
- oggbyte_clear(&os->header_build);
- ogg_buffer_destroy(os->bufferpool);
+ ogg2_buffer_release(os->header_tail);
+ ogg2_buffer_release(os->body_tail);
+ ogg2byte_clear(&os->header_build);
+ ogg2_buffer_destroy(os->bufferpool);
memset(os,0,sizeof(*os));
}
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
/* finish building a header then flush the current page header and
body to the output buffer */
-static void _packet_flush(ogg_stream_state *os,int nextcomplete){
- oggbyte_buffer *obb=&os->header_build;
+static void _packet_flush(ogg2_stream_state *os,int nextcomplete){
+ ogg2byte_buffer *obb=&os->header_build;
unsigned char ctemp;
if(os->lacing_fill){
/* build header */
- oggbyte_set1(obb,'O',0);
- oggbyte_set1(obb,'g',1);
- oggbyte_set1(obb,'g',2);
- oggbyte_set1(obb,'S',3);
+ ogg2byte_set1(obb,'O',0);
+ ogg2byte_set1(obb,'g',1);
+ ogg2byte_set1(obb,'g',2);
+ ogg2byte_set1(obb,'S',3);
- oggbyte_set1(obb,0x00,4); /* stream structure version */
+ ogg2byte_set1(obb,0x00,4); /* stream structure version */
ctemp=0x00;
if(os->continued)ctemp|=0x01; /* continued packet flag? */
os->continued=nextcomplete;
if(os->b_o_s==0)ctemp|=0x02; /* first page flag? */
if(os->e_o_s)ctemp|=0x04; /* last page flag? */
- oggbyte_set1(obb,ctemp,5);
+ ogg2byte_set1(obb,ctemp,5);
/* 64 bits of granule position */
if(!os->b_o_s)
- oggbyte_set8(obb,0,6);
+ ogg2byte_set8(obb,0,6);
else
- oggbyte_set8(obb,os->granulepos,6);
+ ogg2byte_set8(obb,os->granulepos,6);
os->b_o_s=1;
os->packets=0;
/* 32 bits of stream serial number */
- oggbyte_set4(obb,os->serialno,14);
+ ogg2byte_set4(obb,os->serialno,14);
/* 32 bits of page counter (we have both counter and page header
because this val can roll over) */
@@ -108,21 +108,21 @@
strange thing to do in an
encode stream, but it has
plausible uses */
- oggbyte_set4(obb,os->pageno++,18);
+ ogg2byte_set4(obb,os->pageno++,18);
/* CRC filled in later */
/* segment table size */
- oggbyte_set1(obb,os->lacing_fill,26);
+ ogg2byte_set1(obb,os->lacing_fill,26);
/* toss the header on the fifo */
if(os->header_tail){
- ogg_reference *ret=oggbyte_return_and_reset(&os->header_build);
- os->header_head=ogg_buffer_cat(os->header_head,ret);
- if(nextcomplete)oggbyte_init(&os->header_build,0,os->bufferpool);
+ ogg2_reference *ret=ogg2byte_return_and_reset(&os->header_build);
+ os->header_head=ogg2_buffer_cat(os->header_head,ret);
+ if(nextcomplete)ogg2byte_init(&os->header_build,0,os->bufferpool);
}else{
- os->header_tail=oggbyte_return_and_reset(&os->header_build);
- os->header_head=ogg_buffer_walk(os->header_tail);
- if(nextcomplete)oggbyte_init(&os->header_build,0,os->bufferpool);
+ os->header_tail=ogg2byte_return_and_reset(&os->header_build);
+ os->header_head=ogg2_buffer_walk(os->header_tail);
+ if(nextcomplete)ogg2byte_init(&os->header_build,0,os->bufferpool);
}
os->lacing_fill=0;
os->body_fill=0;
@@ -130,20 +130,20 @@
}
/* submit data to the internal buffer of the framing engine */
-int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
+int ogg2_stream_packetin(ogg2_stream_state *os,ogg2_packet *op){
/* get sizing */
- long bytes=ogg_buffer_length(op->packet);
+ long bytes=ogg2_buffer_length(op->packet);
long lacing_vals=bytes/255+1;
int remainder=bytes%255;
int i;
if(os->e_o_s){
- ogg_packet_release(op);
- return OGG_EEOS;
+ ogg2_packet_release(op);
+ return OGG2_EEOS;
}
if(!os->lacing_fill)
- oggbyte_init(&os->header_build,0,os->bufferpool);
+ ogg2byte_init(&os->header_build,0,os->bufferpool);
/* for discontinuous mode */
if(os->mode&1&&!os->packets)os->granulepos=op->granulepos;
@@ -151,7 +151,7 @@
/* concat packet data */
if(os->body_head)
- os->body_head=ogg_buffer_cat(os->body_head,op->packet);
+ os->body_head=ogg2_buffer_cat(os->body_head,op->packet);
else
os->body_tail=os->body_head=op->packet;
@@ -159,7 +159,7 @@
(watermark && not initial page) */
for(i=0;i<lacing_vals-1;i++){ /* handle the 255s first */
os->body_fill+=255;
- oggbyte_set1(&os->header_build,255,27+os->lacing_fill++);
+ ogg2byte_set1(&os->header_build,255,27+os->lacing_fill++);
if(os->body_fill>=os->watermark && os->b_o_s)_packet_flush(os,1);
if(os->lacing_fill==255)_packet_flush(os,1);
@@ -172,7 +172,7 @@
if(!(os->mode&1))os->granulepos=op->granulepos;
os->packetno++; /* for the sake of completeness */
if(op->e_o_s)os->e_o_s=1;
- oggbyte_set1(&os->header_build,remainder,27+os->lacing_fill++);
+ ogg2byte_set1(&os->header_build,remainder,27+os->lacing_fill++);
if(os->e_o_s ||
os->body_fill>=os->watermark ||
@@ -180,41 +180,41 @@
os->lacing_fill==255)_packet_flush(os,0);
memset(op,0,sizeof(*op));
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
/* This constructs pages from buffered packet segments. */
-int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
- oggbyte_buffer ob;
+int ogg2_stream_pageout(ogg2_stream_state *os, ogg2_page *og){
+ ogg2byte_buffer ob;
long header_bytes;
long body_bytes=0;
int i;
/* if the incoming page is still valid (and thus unconsumed),
release it to prevent a leak */
- ogg_page_release(og);
+ ogg2_page_release(og);
/* is there a page waiting to come back? */
if(!os->header_tail) return 0;
/* get header and body sizes */
- oggbyte_init(&ob,os->header_tail,0);
- header_bytes=oggbyte_read1(&ob,26)+27;
+ ogg2byte_init(&ob,os->header_tail,0);
+ header_bytes=ogg2byte_read1(&ob,26)+27;
for(i=27;i<header_bytes;i++)
- body_bytes+=oggbyte_read1(&ob,i);
+ body_bytes+=ogg2byte_read1(&ob,i);
/* split page references out of the fifos */
if(og){
- og->header=ogg_buffer_split(&os->header_tail,&os->header_head,header_bytes);
+ og->header=ogg2_buffer_split(&os->header_tail,&os->header_head,header_bytes);
og->header_len=header_bytes;
- og->body=ogg_buffer_split(&os->body_tail,&os->body_head,body_bytes);
+ og->body=ogg2_buffer_split(&os->body_tail,&os->body_head,body_bytes);
og->body_len=body_bytes;
/* checksum */
- ogg_page_checksum_set(og);
+ ogg2_page_checksum_set(og);
}else{
- os->header_tail=ogg_buffer_pretruncate(os->header_tail,header_bytes);
- os->body_tail=ogg_buffer_pretruncate(os->body_tail,body_bytes);
+ os->header_tail=ogg2_buffer_pretruncate(os->header_tail,header_bytes);
+ os->body_tail=ogg2_buffer_pretruncate(os->body_tail,body_bytes);
if(!os->header_tail)os->header_head=0;
if(!os->body_tail)os->body_head=0;
}
@@ -224,27 +224,27 @@
/* This will flush remaining packets into a page (returning nonzero),
even if there is not enough data to trigger a flush normally
(undersized page). If there are no packets or partial packets to
- flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
- try to flush a normal sized page like ogg_stream_pageout; a call to
- ogg_stream_flush does not guarantee that all packets have flushed.
- Only a return value of 0 from ogg_stream_flush indicates all packet
+ flush, ogg2_stream_flush returns 0. Note that ogg2_stream_flush will
+ try to flush a normal sized page like ogg2_stream_pageout; a call to
+ ogg2_stream_flush does not guarantee that all packets have flushed.
+ Only a return value of 0 from ogg2_stream_flush indicates all packet
data is flushed into pages.
- since ogg_stream_flush will flush the last page in a stream even if
- it's undersized, you almost certainly want to use ogg_stream_pageout
- (and *not* ogg_stream_flush) unless you specifically need to flush
+ since ogg2_stream_flush will flush the last page in a stream even if
+ it's undersized, you almost certainly want to use ogg2_stream_pageout
+ (and *not* ogg2_stream_flush) unless you specifically need to flush
an page regardless of size in the middle of a stream. */
-int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
+int ogg2_stream_flush(ogg2_stream_state *os,ogg2_page *og){
/* If there's no page already waiting for output, flush a partial
page... assuming we have one */
if(!os->header_tail)_packet_flush(os,0);
- return ogg_stream_pageout(os,og);
+ return ogg2_stream_pageout(os,og);
}
-int ogg_stream_eos(ogg_stream_state *os){
+int ogg2_stream_eos(ogg2_stream_state *os){
return os->e_o_s;
}
@@ -253,11 +253,11 @@
#define FINFLAG 0x80000000UL
#define FINMASK 0x7fffffffUL
-static void _next_lace(oggbyte_buffer *ob,ogg_stream_state *os){
+static void _next_lace(ogg2byte_buffer *ob,ogg2_stream_state *os){
/* search ahead one lace */
os->body_fill_next=0;
while(os->laceptr<os->lacing_fill){
- int val=oggbyte_read1(ob,27+os->laceptr++);
+ int val=ogg2byte_read1(ob,27+os->laceptr++);
os->body_fill_next+=val;
if(val<255){
os->body_fill_next|=FINFLAG;
@@ -284,7 +284,7 @@
declared span. Naturally, this error should also not be
mistriggered due to seek or reset, or reported redundantly. */
-static void _span_queued_page(ogg_stream_state *os){
+static void _span_queued_page(ogg2_stream_state *os){
while( !(os->body_fill&FINFLAG) ){
if(!os->header_tail)break;
@@ -293,7 +293,7 @@
flushed as it's consumed, so that's not done here. */
if(os->lacing_fill>=0)
- os->header_tail=ogg_buffer_pretruncate(os->header_tail,
+ os->header_tail=ogg2_buffer_pretruncate(os->header_tail,
os->lacing_fill+27);
os->lacing_fill=0;
os->laceptr=0;
@@ -307,15 +307,15 @@
/* process/prepare next page, if any */
- ogg_page og; /* only for parsing header values */
+ ogg2_page og; /* only for parsing header values */
long pageno;
- oggbyte_buffer ob;
+ ogg2byte_buffer ob;
og.header=os->header_tail; /* only for parsing header values */
- pageno=ogg_page_pageno(&og);
+ pageno=ogg2_page_pageno(&og);
- oggbyte_init(&ob,os->header_tail,0);
- os->lacing_fill=oggbyte_read1(&ob,26);
+ ogg2byte_init(&ob,os->header_tail,0);
+ os->lacing_fill=ogg2byte_read1(&ob,26);
/* are we in sequence? */
if(pageno!=os->pageno){
@@ -324,21 +324,21 @@
else
os->holeflag=2; /* set for external reporting */
- os->body_tail=ogg_buffer_pretruncate(os->body_tail,
+ os->body_tail=ogg2_buffer_pretruncate(os->body_tail,
os->body_fill);
if(os->body_tail==0)os->body_head=0;
os->body_fill=0;
}
- if(ogg_page_continued(&og)){
+ if(ogg2_page_continued(&og)){
os->continued=1;
if(os->body_fill==0){
/* continued packet, but no preceeding data to continue */
/* dump the first partial packet on the page */
_next_lace(&ob,os);
os->body_tail=
- ogg_buffer_pretruncate(os->body_tail,os->body_fill_next&FINMASK);
+ ogg2_buffer_pretruncate(os->body_tail,os->body_fill_next&FINMASK);
if(os->body_tail==0)os->body_head=0;
/* set span flag */
if(!os->spanflag && !os->holeflag)os->spanflag=2;
@@ -348,7 +348,7 @@
if(os->body_fill>0){
/* preceeding data to continue, but not a continued page */
/* dump body_fill */
- os->body_tail=ogg_buffer_pretruncate(os->body_tail,
+ os->body_tail=ogg2_buffer_pretruncate(os->body_tail,
os->body_fill);
if(os->body_tail==0)os->body_head=0;
os->body_fill=0;
@@ -359,7 +359,7 @@
}
if(os->laceptr<os->lacing_fill){
- os->granulepos=ogg_page_granulepos(&og);
+ os->granulepos=ogg2_page_granulepos(&og);
/* get current packet size & flag */
_next_lace(&ob,os);
@@ -371,8 +371,8 @@
}
os->pageno=pageno+1;
- os->e_o_s=ogg_page_eos(&og);
- os->b_o_s=ogg_page_bos(&og);
+ os->e_o_s=ogg2_page_eos(&og);
+ os->b_o_s=ogg2_page_bos(&og);
}
}
@@ -381,44 +381,44 @@
/* add the incoming page to the stream state; we decompose the page
into packet segments here as well. */
-int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){
+int ogg2_stream_pagein(ogg2_stream_state *os, ogg2_page *og){
- int serialno=ogg_page_serialno(og);
- int version=ogg_page_version(og);
+ int serialno=ogg2_page_serialno(og);
+ int version=ogg2_page_version(og);
/* check the serial number */
if(serialno!=os->serialno){
- ogg_page_release(og);
- return OGG_ESERIAL;
+ ogg2_page_release(og);
+ return OGG2_ESERIAL;
}
if(version>0){
- ogg_page_release(og);
- return OGG_EVERSION;
+ ogg2_page_release(og);
+ return OGG2_EVERSION;
}
/* add to fifos */
if(!os->body_tail){
os->body_tail=og->body;
- os->body_head=ogg_buffer_walk(og->body);
+ os->body_head=ogg2_buffer_walk(og->body);
}else{
- os->body_head=ogg_buffer_cat(os->body_head,og->body);
+ os->body_head=ogg2_buffer_cat(os->body_head,og->body);
}
if(!os->header_tail){
os->header_tail=og->header;
- os->header_head=ogg_buffer_walk(og->header);
+ os->header_head=ogg2_buffer_walk(og->header);
os->lacing_fill=-27;
}else{
- os->header_head=ogg_buffer_cat(os->header_head,og->header);
+ os->header_head=ogg2_buffer_cat(os->header_head,og->header);
}
memset(og,0,sizeof(*og));
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-int ogg_stream_reset(ogg_stream_state *os){
+int ogg2_stream_reset(ogg2_stream_state *os){
- ogg_buffer_release(os->header_tail);
- ogg_buffer_release(os->body_tail);
+ ogg2_buffer_release(os->header_tail);
+ ogg2_buffer_release(os->body_tail);
os->header_tail=os->header_head=0;
os->body_tail=os->body_head=0;
@@ -430,7 +430,7 @@
os->body_fill=0;
os->lacing_fill=0;
- oggbyte_clear(&os->header_build);
+ ogg2byte_clear(&os->header_build);
os->packets=0;
os->holeflag=0;
@@ -439,20 +439,20 @@
os->laceptr=0;
os->body_fill_next=0;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){
- ogg_stream_reset(os);
+int ogg2_stream_reset_serialno(ogg2_stream_state *os,int serialno){
+ ogg2_stream_reset(os);
os->serialno=serialno;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
+static int _packetout(ogg2_stream_state *os,ogg2_packet *op,int adv){
/* if the incoming packet is a valid reference, release it such that
we don't leak the memory */
- ogg_packet_release(op);
+ ogg2_packet_release(op);
/* buffer packets for return */
_span_queued_page(os);
@@ -465,7 +465,7 @@
os->holeflag=1;
if(temp==2){
os->packetno++;
- return OGG_HOLE;
+ return OGG2_HOLE;
}
}
if(os->spanflag){
@@ -476,7 +476,7 @@
os->spanflag=1;
if(temp==2){
os->packetno++;
- return OGG_SPAN;
+ return OGG2_SPAN;
}
}
@@ -513,15 +513,15 @@
}
if(adv){
- oggbyte_buffer ob;
- oggbyte_init(&ob,os->header_tail,0);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,os->header_tail,0);
/* split the body contents off */
if(op){
- op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,os->body_fill&FINMASK);
+ op->packet=ogg2_buffer_split(&os->body_tail,&os->body_head,os->body_fill&FINMASK);
op->bytes=os->body_fill&FINMASK;
}else{
- os->body_tail=ogg_buffer_pretruncate(os->body_tail,os->body_fill&FINMASK);
+ os->body_tail=ogg2_buffer_pretruncate(os->body_tail,os->body_fill&FINMASK);
if(os->body_tail==0)os->body_head=0;
}
@@ -530,7 +530,7 @@
_next_lace(&ob,os);
}else{
if(op){
- op->packet=ogg_buffer_sub(os->body_tail,0,os->body_fill&FINMASK);
+ op->packet=ogg2_buffer_sub(os->body_tail,0,os->body_fill&FINMASK);
op->bytes=os->body_fill&FINMASK;
}
}
@@ -543,45 +543,45 @@
return 1;
}
-int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){
+int ogg2_stream_packetout(ogg2_stream_state *os,ogg2_packet *op){
return _packetout(os,op,1);
}
-int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){
+int ogg2_stream_packetpeek(ogg2_stream_state *os,ogg2_packet *op){
return _packetout(os,op,0);
}
-int ogg_packet_release(ogg_packet *op) {
+int ogg2_packet_release(ogg2_packet *op) {
if(op){
- ogg_buffer_release(op->packet);
+ ogg2_buffer_release(op->packet);
memset(op, 0, sizeof(*op));
}
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-int ogg_page_release(ogg_page *og) {
+int ogg2_page_release(ogg2_page *og) {
if(og){
- ogg_buffer_release(og->header);
- ogg_buffer_release(og->body);
+ ogg2_buffer_release(og->header);
+ ogg2_buffer_release(og->body);
memset(og, 0, sizeof(*og));
}
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
#ifdef _V_SELFTEST2
#include <stdio.h>
-ogg_stream_state *os_en, *os_de;
-ogg_sync_state *oy;
-ogg_buffer_state *bs;
+ogg2_stream_state *os_en, *os_de;
+ogg2_sync_state *oy;
+ogg2_buffer_state *bs;
-void checkpacket(ogg_packet *op,int len, int no, int pos){
+void checkpacket(ogg2_packet *op,int len, int no, int pos){
long j;
static int sequence=0;
static int lastno=0;
- oggbyte_buffer ob;
+ ogg2byte_buffer ob;
- if(ogg_buffer_length(op->packet)!=len){
+ if(ogg2_buffer_length(op->packet)!=len){
fprintf(stderr,"incorrect packet length!\n");
exit(1);
}
@@ -607,18 +607,18 @@
}
/* Test data */
- oggbyte_init(&ob,op->packet,0);
- for(j=0;j<ogg_buffer_length(op->packet);j++)
- if(oggbyte_read1(&ob,j)!=((j+no)&0xff)){
+ ogg2byte_init(&ob,op->packet,0);
+ for(j=0;j<ogg2_buffer_length(op->packet);j++)
+ if(ogg2byte_read1(&ob,j)!=((j+no)&0xff)){
fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n",
- j,oggbyte_read1(&ob,j),(j+no)&0xff);
+ j,ogg2byte_read1(&ob,j),(j+no)&0xff);
exit(1);
}
}
-void check_page(unsigned char *data,const int *header,ogg_page *og){
+void check_page(unsigned char *data,const int *header,ogg2_page *og){
long j;
- oggbyte_buffer ob;
+ ogg2byte_buffer ob;
/* test buffer lengths */
long header_len=header[26]+27;
@@ -627,65 +627,65 @@
for(j=27;j<header_len;j++)
body_len+=header[j];
- if(header_len!=ogg_buffer_length(og->header)){
+ if(header_len!=ogg2_buffer_length(og->header)){
fprintf(stderr,"page header length mismatch: %ld correct, buffer is %ld\n",
- header_len,ogg_buffer_length(og->header));
+ header_len,ogg2_buffer_length(og->header));
exit(1);
}
- if(body_len!=ogg_buffer_length(og->body)){
+ if(body_len!=ogg2_buffer_length(og->body)){
fprintf(stderr,"page body length mismatch: %ld correct, buffer is %ld\n",
- body_len,ogg_buffer_length(og->body));
+ body_len,ogg2_buffer_length(og->body));
exit(1);
}
/* Test data */
- oggbyte_init(&ob,og->body,0);
- for(j=0;j<ogg_buffer_length(og->body);j++)
- if(oggbyte_read1(&ob,j)!=data[j]){
+ ogg2byte_init(&ob,og->body,0);
+ for(j=0;j<ogg2_buffer_length(og->body);j++)
+ if(ogg2byte_read1(&ob,j)!=data[j]){
fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n",
- j,data[j],oggbyte_read1(&ob,j));
+ j,data[j],ogg2byte_read1(&ob,j));
exit(1);
}
/* Test header */
- oggbyte_init(&ob,og->header,0);
- for(j=0;j<ogg_buffer_length(og->header);j++){
- if(oggbyte_read1(&ob,j)!=header[j]){
+ ogg2byte_init(&ob,og->header,0);
+ for(j=0;j<ogg2_buffer_length(og->header);j++){
+ if(ogg2byte_read1(&ob,j)!=header[j]){
fprintf(stderr,"header content mismatch at pos %ld:\n",j);
for(j=0;j<header[26]+27;j++)
- fprintf(stderr," (%ld)%02x:%02x",j,header[j],oggbyte_read1(&ob,j));
+ fprintf(stderr," (%ld)%02x:%02x",j,header[j],ogg2byte_read1(&ob,j));
fprintf(stderr,"\n");
exit(1);
}
}
- if(ogg_buffer_length(og->header)!=header[26]+27){
+ if(ogg2_buffer_length(og->header)!=header[26]+27){
fprintf(stderr,"header length incorrect! (%ld!=%d)\n",
- ogg_buffer_length(og->header),header[26]+27);
+ ogg2_buffer_length(og->header),header[26]+27);
exit(1);
}
}
-void print_header(ogg_page *og){
+void print_header(ogg2_page *og){
int j;
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
fprintf(stderr,"\nHEADER:\n");
fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n",
- oggbyte_read1(&ob,0),oggbyte_read1(&ob,1),
- oggbyte_read1(&ob,2),oggbyte_read1(&ob,3),
- (int)oggbyte_read1(&ob,4),(int)oggbyte_read1(&ob,5));
+ ogg2byte_read1(&ob,0),ogg2byte_read1(&ob,1),
+ ogg2byte_read1(&ob,2),ogg2byte_read1(&ob,3),
+ (int)ogg2byte_read1(&ob,4),(int)ogg2byte_read1(&ob,5));
fprintf(stderr," granulepos: %08x%08x serialno: %x pageno: %ld\n",
- oggbyte_read4(&ob,10),oggbyte_read4(&ob,6),
- oggbyte_read4(&ob,14),
- (long)oggbyte_read4(&ob,18));
+ ogg2byte_read4(&ob,10),ogg2byte_read4(&ob,6),
+ ogg2byte_read4(&ob,14),
+ (long)ogg2byte_read4(&ob,18));
fprintf(stderr," checksum: %08x\n segments: %d (",
- oggbyte_read4(&ob,22),(int)oggbyte_read1(&ob,26));
+ ogg2byte_read4(&ob,22),(int)ogg2byte_read1(&ob,26));
- for(j=27;j<ogg_buffer_length(og->header);j++)
- fprintf(stderr,"%d ",(int)oggbyte_read1(&ob,j));
+ for(j=27;j<ogg2_buffer_length(og->header);j++)
+ fprintf(stderr,"%d ",(int)ogg2byte_read1(&ob,j));
fprintf(stderr,")\n\n");
}
@@ -880,7 +880,7 @@
0xd4,0xe0,0x60,0xe5,
1,0};
-void bufcpy(void *data,ogg_reference *or){
+void bufcpy(void *data,ogg2_reference *or){
while(or){
memcpy(data,or->buffer->data+or->begin,or->length);
data+=or->length;
@@ -888,7 +888,7 @@
}
}
-void bufcpy2(void *data,ogg_reference *or,int begin){
+void bufcpy2(void *data,ogg2_reference *or,int begin){
while(or){
if(or->length-begin>0){
memcpy(data,or->buffer->data+or->begin+begin,or->length-begin);
@@ -899,7 +899,7 @@
}
}
-int bufcmp(void *data,ogg_reference *or){
+int bufcmp(void *data,ogg2_reference *or){
while(or){
int ret=memcmp(data,or->buffer->data+or->begin,or->length);
if(ret)return ret;
@@ -924,10 +924,10 @@
for(i=0;i<packets;i++){
/* construct a test packet */
- ogg_packet op={0,0,0,0,0,0};
+ ogg2_packet op={0,0,0,0,0,0};
int len=pl[i];
- op.packet=ogg_buffer_alloc(bs,len);
+ op.packet=ogg2_buffer_alloc(bs,len);
op.e_o_s=(pl[i+1]<0?1:0);
op.granulepos=granulepos;
@@ -939,13 +939,13 @@
inptr+=j;
/* submit the test packet */
- ogg_stream_packetin(os_en,&op);
+ ogg2_stream_packetin(os_en,&op);
/* retrieve any finished pages */
{
- ogg_page og={0,0,0,0};
+ ogg2_page og={0,0,0,0};
- while(ogg_stream_pageout(os_en,&og)){
+ while(ogg2_stream_pageout(os_en,&og)){
/* We have a page. Check it carefully */
fprintf(stderr,"%ld, ",pageno);
@@ -957,34 +957,34 @@
check_page(data+outptr,headers[pageno],&og);
- outptr+=ogg_buffer_length(og.body);
+ outptr+=ogg2_buffer_length(og.body);
pageno++;
/* have a complete page; submit it to sync/decode */
{
- ogg_page og_de={0,0,0,0};
- ogg_packet op_de={0,0,0,0,0,0},op_de2={0,0,0,0,0,0};
- int blen=ogg_buffer_length(og.header)+ogg_buffer_length(og.body);
- char *buf=ogg_sync_bufferin(oy,blen);
+ ogg2_page og_de={0,0,0,0};
+ ogg2_packet op_de={0,0,0,0,0,0},op_de2={0,0,0,0,0,0};
+ int blen=ogg2_buffer_length(og.header)+ogg2_buffer_length(og.body);
+ char *buf=ogg2_sync_bufferin(oy,blen);
bufcpy(buf,og.header);
- bufcpy(buf+ogg_buffer_length(og.header),og.body);
- ogg_sync_wrote(oy,blen);
+ bufcpy(buf+ogg2_buffer_length(og.header),og.body);
+ ogg2_sync_wrote(oy,blen);
- while(ogg_sync_pageout(oy,&og_de)>0){
+ while(ogg2_sync_pageout(oy,&og_de)>0){
/* got a page. Happy happy. Verify that it's good. */
check_page(data+deptr,headers[pageout],&og_de);
- deptr+=ogg_buffer_length(og_de.body);
+ deptr+=ogg2_buffer_length(og_de.body);
pageout++;
/* submit it to deconstitution */
- ogg_stream_pagein(os_de,&og_de);
+ ogg2_stream_pagein(os_de,&og_de);
/* packets out? */
- while(ogg_stream_packetpeek(os_de,NULL)>0){
- ogg_stream_packetpeek(os_de,&op_de2);
- ogg_stream_packetout(os_de,&op_de); /* just catching them all */
+ while(ogg2_stream_packetpeek(os_de,NULL)>0){
+ ogg2_stream_packetpeek(os_de,&op_de2);
+ ogg2_stream_packetout(os_de,&op_de); /* just catching them all */
/* verify the packets! */
/* check data */
@@ -1016,7 +1016,7 @@
exit(1);
}
bosflag=1;
- depacket+=ogg_buffer_length(op_de.packet);
+ depacket+=ogg2_buffer_length(op_de.packet);
/* check eos flag */
if(eosflag){
@@ -1038,12 +1038,12 @@
exit(1);
}
- ogg_packet_release(&op_de);
- ogg_packet_release(&op_de2);
+ ogg2_packet_release(&op_de);
+ ogg2_packet_release(&op_de2);
}
}
}
- ogg_page_release(&og);
+ ogg2_page_release(&og);
}
}
}
@@ -1074,18 +1074,18 @@
}
fprintf(stderr,"ok.\n");
- ogg_stream_reset(os_en);
- ogg_stream_reset(os_de);
- ogg_sync_reset(oy);
+ ogg2_stream_reset(os_en);
+ ogg2_stream_reset(os_de);
+ ogg2_sync_reset(oy);
}
int main(void){
- os_en=ogg_stream_create(0x04030201);
- os_de=ogg_stream_create(0x04030201);
- oy=ogg_sync_create();
- bs=ogg_buffer_create();
+ os_en=ogg2_stream_create(0x04030201);
+ os_de=ogg2_stream_create(0x04030201);
+ oy=ogg2_sync_create();
+ bs=ogg2_buffer_create();
/* Exercise each code path in the framing code. Also verify that
the checksums are working. */
@@ -1201,16 +1201,16 @@
unsigned char *data=_ogg_malloc(1024*1024);
int pl[]={0,100,4079,2956,2057,76,34,912,0,234,1000,1000,1000,300,-1};
int inptr=0,i,j;
- ogg_page og[5];
+ ogg2_page og[5];
memset(og,0,sizeof(og));
- ogg_stream_reset(os_en);
+ ogg2_stream_reset(os_en);
for(i=0;pl[i]!=-1;i++){
- ogg_packet op;
+ ogg2_packet op;
int len=pl[i];
- op.packet=ogg_buffer_alloc(bs,len);
+ op.packet=ogg2_buffer_alloc(bs,len);
op.e_o_s=(pl[i+1]<0?1:0);
op.granulepos=(i+1)*1000;
@@ -1218,7 +1218,7 @@
memcpy(op.packet->buffer->data,data+inptr,len);
op.packet->length=len;
- ogg_stream_packetin(os_en,&op);
+ ogg2_stream_packetin(os_en,&op);
inptr+=j;
}
@@ -1226,14 +1226,14 @@
/* retrieve finished pages */
for(i=0;i<5;i++){
- if(ogg_stream_pageout(os_en,&og[i])==0){
+ if(ogg2_stream_pageout(os_en,&og[i])==0){
fprintf(stderr,"Too few pages output building sync tests!\n");
exit(1);
}
}
{
- ogg_page temp;
- if(ogg_stream_pageout(os_en,&temp)>0){
+ ogg2_page temp;
+ if(ogg2_stream_pageout(os_en,&temp)>0){
fprintf(stderr,"Too many pages output building sync tests!\n");
exit(1);
}
@@ -1241,269 +1241,269 @@
/* Test lost pages on pagein/packetout: no rollback */
{
- ogg_page temp={0,0,0,0};
- ogg_packet test={0,0,0,0,0,0};
+ ogg2_page temp={0,0,0,0};
+ ogg2_packet test={0,0,0,0,0,0};
fprintf(stderr,"Testing loss of pages... ");
- ogg_sync_reset(oy);
- ogg_stream_reset(os_de);
+ ogg2_sync_reset(oy);
+ ogg2_stream_reset(os_de);
for(i=0;i<5;i++){
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[i].header)),
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[i].header)),
og[i].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[i].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[i].body)),
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[i].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[i].body)),
og[i].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[i].body));
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[i].body));
}
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
- ogg_sync_pageout(oy,&temp);
- ogg_page_release(&temp);/* skip */
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_page_release(&temp);/* skip */
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
/* do we get the expected results/packets? */
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,0,0,0);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,100,1,-1);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,4079,2,3000);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=OGG_HOLE){
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=OGG2_HOLE){
fprintf(stderr,"Error: loss of page did not return error\n");
exit(1);
}
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,76,5,-1);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,34,6,-1);
- ogg_packet_release(&test);
+ ogg2_packet_release(&test);
fprintf(stderr,"ok.\n");
}
/* Test lost pages on pagein/packetout: rollback with continuation */
{
- ogg_page temp={0,0,0,0};
- ogg_packet test={0,0,0,0,0,0};
+ ogg2_page temp={0,0,0,0};
+ ogg2_packet test={0,0,0,0,0,0};
fprintf(stderr,"Testing loss of pages (rollback required)... ");
- ogg_sync_reset(oy);
- ogg_stream_reset(os_de);
+ ogg2_sync_reset(oy);
+ ogg2_stream_reset(os_de);
for(i=0;i<5;i++){
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[i].header)),
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[i].header)),
og[i].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[i].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[i].body)),
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[i].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[i].body)),
og[i].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[i].body));
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[i].body));
}
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
- ogg_sync_pageout(oy,&temp);
- ogg_page_release(&temp);/* skip */
- ogg_sync_pageout(oy,&temp);
- ogg_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_page_release(&temp);/* skip */
+ ogg2_sync_pageout(oy,&temp);
+ ogg2_stream_pagein(os_de,&temp);
/* do we get the expected results/packets? */
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,0,0,0);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,100,1,-1);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,4079,2,3000);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,2956,3,4000);
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=OGG_HOLE){
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=OGG2_HOLE){
fprintf(stderr,"Error: loss of page did not return error\n");
exit(1);
}
- ogg_packet_release(&test);
- if(ogg_stream_packetout(os_de,&test)!=1)error();
+ ogg2_packet_release(&test);
+ if(ogg2_stream_packetout(os_de,&test)!=1)error();
checkpacket(&test,300,13,14000);
- ogg_packet_release(&test);
+ ogg2_packet_release(&test);
fprintf(stderr,"ok.\n");
}
/* the rest only test sync */
{
- ogg_page og_de={0,0,0,0};
+ ogg2_page og_de={0,0,0,0};
/* Test fractional page inputs: incomplete capture */
fprintf(stderr,"Testing sync on partial inputs... ");
- ogg_sync_reset(oy);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
- ogg_sync_wrote(oy,3);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ ogg2_sync_reset(oy);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header);
+ ogg2_sync_wrote(oy,3);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
/* Test fractional page inputs: incomplete fixed header */
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,3);
- ogg_sync_wrote(oy,20);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header,3);
+ ogg2_sync_wrote(oy,20);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
/* Test fractional page inputs: incomplete header */
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,23);
- ogg_sync_wrote(oy,5);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header,23);
+ ogg2_sync_wrote(oy,5);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
/* Test fractional page inputs: incomplete body */
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,28);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].header)-28);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header,28);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].header)-28);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,1000);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,1000);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body,1000);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body)-1000);
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body,1000);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body)-1000);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
fprintf(stderr,"ok.\n");
}
/* Test fractional page inputs: page + incomplete capture */
{
- ogg_page og_de={0,0,0,0};
+ ogg2_page og_de={0,0,0,0};
fprintf(stderr,"Testing sync on 1+partial inputs... ");
- ogg_sync_reset(oy);
+ ogg2_sync_reset(oy);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
- ogg_sync_wrote(oy,20);
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header);
+ ogg2_sync_wrote(oy,20);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,20);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].header)-20);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header,20);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].header)-20);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body));
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
fprintf(stderr,"ok.\n");
}
/* Test recapture: garbage + page */
{
- ogg_page og_de={0,0,0,0};
+ ogg2_page og_de={0,0,0,0};
fprintf(stderr,"Testing search for capture... ");
- ogg_sync_reset(oy);
+ ogg2_sync_reset(oy);
/* 'garbage' */
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].header)),og[2].header);
- ogg_sync_wrote(oy,20);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].header)),og[2].header);
+ ogg2_sync_wrote(oy,20);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
- bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].header)),og[2].header,20);
- ogg_sync_wrote(oy,ogg_buffer_length(og[2].header)-20);
+ bufcpy2(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].header)),og[2].header,20);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[2].header)-20);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].body)),og[2].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[2].body));
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].body)),og[2].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[2].body));
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
fprintf(stderr,"ok.\n");
}
/* Test recapture: page + garbage + page */
{
- ogg_page og_de={0,0,0,0};
+ ogg2_page og_de={0,0,0,0};
fprintf(stderr,"Testing recapture... ");
- ogg_sync_reset(oy);
+ ogg2_sync_reset(oy);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].header)),og[1].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[1].body)),og[1].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[1].body));
/* garbage */
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].header)),og[2].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[2].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].header)),og[2].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[2].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].header)),og[2].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[2].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].header)),og[2].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[2].header));
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].body)),og[2].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[2].body)-5);
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[2].body)),og[2].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[2].body)-5);
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[3].header)),og[3].header);
- ogg_sync_wrote(oy,ogg_buffer_length(og[3].header));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[3].header)),og[3].header);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[3].header));
- bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[3].body)),og[3].body);
- ogg_sync_wrote(oy,ogg_buffer_length(og[3].body));
+ bufcpy(ogg2_sync_bufferin(oy,ogg2_buffer_length(og[3].body)),og[3].body);
+ ogg2_sync_wrote(oy,ogg2_buffer_length(og[3].body));
- if(ogg_sync_pageout(oy,&og_de)>0)error();
- ogg_page_release(&og_de);
- if(ogg_sync_pageout(oy,&og_de)<=0)error();
- ogg_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)>0)error();
+ ogg2_page_release(&og_de);
+ if(ogg2_sync_pageout(oy,&og_de)<=0)error();
+ ogg2_page_release(&og_de);
fprintf(stderr,"ok.\n");
}
- ogg_stream_destroy(os_en);
+ ogg2_stream_destroy(os_en);
for(i=0;i<5;i++)
- ogg_page_release(&og[i]);
+ ogg2_page_release(&og[i]);
}
- ogg_stream_destroy(os_de);
- ogg_sync_destroy(oy);
+ ogg2_stream_destroy(os_de);
+ ogg2_sync_destroy(oy);
- ogg_buffer_destroy(bs);
+ ogg2_buffer_destroy(bs);
return 0;
}
Modified: branches/ogg2-arc/src/sync.c
===================================================================
--- branches/ogg2-arc/src/sync.c 2005-03-02 08:31:35 UTC (rev 9004)
+++ branches/ogg2-arc/src/sync.c 2005-03-02 11:40:48 UTC (rev 9005)
@@ -27,46 +27,46 @@
/* A complete description of Ogg framing exists in docs/framing.html */
-int ogg_page_version(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read1(&ob,4);
+int ogg2_page_version(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read1(&ob,4);
}
-int ogg_page_continued(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read1(&ob,5)&0x01;
+int ogg2_page_continued(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read1(&ob,5)&0x01;
}
-int ogg_page_bos(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read1(&ob,5)&0x02;
+int ogg2_page_bos(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read1(&ob,5)&0x02;
}
-int ogg_page_eos(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read1(&ob,5)&0x04;
+int ogg2_page_eos(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read1(&ob,5)&0x04;
}
-ogg_int64_t ogg_page_granulepos(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read8(&ob,6);
+ogg_int64_t ogg2_page_granulepos(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read8(&ob,6);
}
-ogg_uint32_t ogg_page_serialno(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read4(&ob,14);
+ogg_uint32_t ogg2_page_serialno(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read4(&ob,14);
}
-ogg_uint32_t ogg_page_pageno(ogg_page *og){
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
- return oggbyte_read4(&ob,18);
+ogg_uint32_t ogg2_page_pageno(ogg2_page *og){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ return ogg2byte_read4(&ob,18);
}
/* returns the number of packets that are completed on this page (if
@@ -76,26 +76,26 @@
/* NOTE:
If a page consists of a packet begun on a previous page, and a new
packet begun (but not completed) on this page, the return will be:
- ogg_page_packets(page) ==1,
- ogg_page_continued(page) !=0
+ ogg2_page_packets(page) ==1,
+ ogg2_page_continued(page) !=0
If a page happens to be a single packet that was begun on a
previous page, and spans to the next page (in the case of a three or
more page packet), the return will be:
- ogg_page_packets(page) ==0,
- ogg_page_continued(page) !=0
+ ogg2_page_packets(page) ==0,
+ ogg2_page_continued(page) !=0
*/
-int ogg_page_packets(ogg_page *og){
+int ogg2_page_packets(ogg2_page *og){
int i;
int n;
int count=0;
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header,0);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
- n=oggbyte_read1(&ob,26);
+ n=ogg2byte_read1(&ob,26);
for(i=0;i<n;i++)
- if(oggbyte_read1(&ob,27+i)<255)count++;
+ if(ogg2byte_read1(&ob,27+i)<255)count++;
return(count);
}
@@ -107,55 +107,55 @@
to test how your application will react to the erronious data.
*/
-void ogg_page_set_continued(ogg_page *og, int value){
+void ogg2_page_set_continued(ogg2_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);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ b=ogg2byte_read1(&ob,5);
+ if(value)ogg2byte_set1(&ob,b|0x01,5);
+ else ogg2byte_set1(&ob,b&0xFE,5);
+ ogg2_page_checksum_set(og);
}
-void ogg_page_set_bos(ogg_page *og, int value){
+void ogg2_page_set_bos(ogg2_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);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ b=ogg2byte_read1(&ob,5);
+ if(value)ogg2byte_set1(&ob,b|0x02,5);
+ else ogg2byte_set1(&ob,b&0xFD,5);
+ ogg2_page_checksum_set(og);
}
-void ogg_page_set_eos(ogg_page *og, int value){
+void ogg2_page_set_eos(ogg2_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);
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ b=ogg2byte_read1(&ob,5);
+ if(value)ogg2byte_set1(&ob,b|0x04,5);
+ else ogg2byte_set1(&ob,b&0xFB,5);
+ ogg2_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 ogg2_page_set_granulepos(ogg2_page *og, ogg_int64_t value){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ ogg2byte_set8(&ob,value,6);
+ ogg2_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 ogg2_page_set_serialno(ogg2_page *og, ogg_uint32_t value){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ ogg2byte_set4(&ob,value,14);
+ ogg2_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);
+void ogg2_page_set_pageno(ogg2_page *og, ogg_uint32_t value){
+ ogg2byte_buffer ob;
+ ogg2byte_init(&ob,og->header,0);
+ ogg2byte_set4(&ob,value,18);
+ ogg2_page_checksum_set(og);
}
@@ -233,34 +233,34 @@
/* This has two layers (split page decode and packet decode) to place
more of the multi-serialno and paging control in the hands of
higher layers (eg, OggFile). First, we expose a data buffer using
- ogg_sync_buffer(). The app either copies into the buffer, or
- passes it directly to read(), etc. We then call ogg_sync_wrote()
+ ogg2_sync_buffer(). The app either copies into the buffer, or
+ passes it directly to read(), etc. We then call ogg2_sync_wrote()
to tell how many bytes we just added.
Efficiency note: request the same buffer size each time if at all
possible.
- Pages are returned (pointers into the buffer in ogg_sync_state)
- by ogg_sync_pageout(). */
+ Pages are returned (pointers into the buffer in ogg2_sync_state)
+ by ogg2_sync_pageout(). */
-ogg_sync_state *ogg_sync_create(void){
- ogg_sync_state *oy=_ogg_calloc(1,sizeof(*oy));
+ogg2_sync_state *ogg2_sync_create(void){
+ ogg2_sync_state *oy=_ogg_calloc(1,sizeof(*oy));
memset(oy,0,sizeof(*oy));
- oy->bufferpool=ogg_buffer_create();
+ oy->bufferpool=ogg2_buffer_create();
return oy;
}
-int ogg_sync_destroy(ogg_sync_state *oy){
+int ogg2_sync_destroy(ogg2_sync_state *oy){
if(oy){
- ogg_sync_reset(oy);
- ogg_buffer_destroy(oy->bufferpool);
+ ogg2_sync_reset(oy);
+ ogg2_buffer_destroy(oy->bufferpool);
memset(oy,0,sizeof(*oy));
_ogg_free(oy);
}
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long bytes){
+unsigned char *ogg2_sync_bufferin(ogg2_sync_state *oy, long bytes){
/* [allocate and] expose a buffer for data submission.
@@ -278,7 +278,7 @@
/* base case; fifo uninitialized */
if(!oy->fifo_head){
- oy->fifo_head=oy->fifo_tail=ogg_buffer_alloc(oy->bufferpool,bytes);
+ oy->fifo_head=oy->fifo_tail=ogg2_buffer_alloc(oy->bufferpool,bytes);
return oy->fifo_head->buffer->data;
}
@@ -291,29 +291,29 @@
/* current fragment is unused, but too small */
if(!oy->fifo_head->length){
- ogg_buffer_realloc(oy->fifo_head,bytes);
+ ogg2_buffer_realloc(oy->fifo_head,bytes);
return oy->fifo_head->buffer->data+oy->fifo_head->begin;
}
/* current fragment used/full; get new fragment */
{
- ogg_reference *new=ogg_buffer_alloc(oy->bufferpool,bytes);
+ ogg2_reference *new=ogg2_buffer_alloc(oy->bufferpool,bytes);
oy->fifo_head->next=new;
oy->fifo_head=new;
}
return oy->fifo_head->buffer->data;
}
-int ogg_sync_wrote(ogg_sync_state *oy, long bytes){
- if(!oy->fifo_head)return OGG_EINVAL;
+int ogg2_sync_wrote(ogg2_sync_state *oy, long bytes){
+ if(!oy->fifo_head)return OGG2_EINVAL;
if(oy->fifo_head->buffer->size-oy->fifo_head->length-oy->fifo_head->begin <
- bytes)return OGG_EINVAL;
+ bytes)return OGG2_EINVAL;
oy->fifo_head->length+=bytes;
oy->fifo_fill+=bytes;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-static ogg_uint32_t _checksum(ogg_reference *or, int bytes){
+static ogg_uint32_t _checksum(ogg2_reference *or, int bytes){
ogg_uint32_t crc_reg=0;
int j,post;
@@ -340,26 +340,26 @@
8*/
-long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
- oggbyte_buffer page;
+long ogg2_sync_pageseek(ogg2_sync_state *oy,ogg2_page *og){
+ ogg2byte_buffer page;
long bytes,ret=0;
/* don't leak a valid reference */
- ogg_page_release(og);
+ ogg2_page_release(og);
bytes=oy->fifo_fill;
- oggbyte_init(&page,oy->fifo_tail,0);
+ ogg2byte_init(&page,oy->fifo_tail,0);
if(oy->headerbytes==0){
if(bytes<27)goto sync_out; /* not enough for even a minimal header */
/* verify capture pattern */
- if(oggbyte_read1(&page,0)!=(int)'O' ||
- oggbyte_read1(&page,1)!=(int)'g' ||
- oggbyte_read1(&page,2)!=(int)'g' ||
- oggbyte_read1(&page,3)!=(int)'S' ) goto sync_fail;
+ if(ogg2byte_read1(&page,0)!=(int)'O' ||
+ ogg2byte_read1(&page,1)!=(int)'g' ||
+ ogg2byte_read1(&page,2)!=(int)'g' ||
+ ogg2byte_read1(&page,3)!=(int)'S' ) goto sync_fail;
- oy->headerbytes=oggbyte_read1(&page,26)+27;
+ oy->headerbytes=ogg2byte_read1(&page,26)+27;
}
if(bytes<oy->headerbytes)goto sync_out; /* not enough for header +
seg table */
@@ -367,7 +367,7 @@
int i;
/* count up body length in the segment table */
for(i=0;i<oy->headerbytes-27;i++)
- oy->bodybytes+=oggbyte_read1(&page,27+i);
+ oy->bodybytes+=ogg2byte_read1(&page,27+i);
}
if(oy->bodybytes+oy->headerbytes>bytes)goto sync_out;
@@ -375,8 +375,8 @@
/* we have what appears to be a complete page; last test: verify
checksum */
{
- ogg_uint32_t chksum=oggbyte_read4(&page,22);
- oggbyte_set4(&page,0,22);
+ ogg_uint32_t chksum=ogg2byte_read4(&page,22);
+ ogg2byte_set4(&page,0,22);
/* Compare checksums; memory continues to be common access */
if(chksum!=_checksum(oy->fifo_tail,oy->bodybytes+oy->headerbytes)){
@@ -385,23 +385,23 @@
at all). replace the computed checksum with the one actually
read in; remember all the memory is common access */
- oggbyte_set4(&page,chksum,22);
+ ogg2byte_set4(&page,chksum,22);
goto sync_fail;
}
- oggbyte_set4(&page,chksum,22);
+ ogg2byte_set4(&page,chksum,22);
}
/* We have a page. Set up page return. */
if(og){
/* set up page output */
- og->header=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->headerbytes);
+ og->header=ogg2_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->headerbytes);
og->header_len=oy->headerbytes;
- og->body=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->bodybytes);
+ og->body=ogg2_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->bodybytes);
og->body_len=oy->bodybytes;
}else{
/* simply advance */
oy->fifo_tail=
- ogg_buffer_pretruncate(oy->fifo_tail,oy->headerbytes+oy->bodybytes);
+ ogg2_buffer_pretruncate(oy->fifo_tail,oy->headerbytes+oy->bodybytes);
if(!oy->fifo_tail)oy->fifo_head=0;
}
@@ -417,7 +417,7 @@
oy->headerbytes=0;
oy->bodybytes=0;
- oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,1);
+ oy->fifo_tail=ogg2_buffer_pretruncate(oy->fifo_tail,1);
ret--;
/* search forward through fragments for possible capture */
@@ -429,14 +429,14 @@
if(next){
/* possible capture in this segment */
long bytes=next-now;
- oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes);
+ oy->fifo_tail=ogg2_buffer_pretruncate(oy->fifo_tail,bytes);
ret-=bytes;
break;
}else{
/* no capture. advance to next segment */
long bytes=oy->fifo_tail->length;
ret-=bytes;
- oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes);
+ oy->fifo_tail=ogg2_buffer_pretruncate(oy->fifo_tail,bytes);
}
}
if(!oy->fifo_tail)oy->fifo_head=0;
@@ -450,21 +450,21 @@
Supress 'sync errors' after reporting the first.
return values:
- OGG_HOLE) recapture (hole in data)
+ OGG2_HOLE) recapture (hole in data)
0) need more data
1) page returned
Returns pointers into buffered data; invalidated by next call to
_stream, _clear, _init, or _buffer */
-int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){
+int ogg2_sync_pageout(ogg2_sync_state *oy, ogg2_page *og){
/* all we need to do is verify a page at the head of the stream
buffer. If it doesn't verify, we look for the next potential
frame */
while(1){
- long ret=ogg_sync_pageseek(oy,og);
+ long ret=ogg2_sync_pageseek(oy,og);
if(ret>0){
/* have a page */
return 1;
@@ -477,7 +477,7 @@
/* head did not start a synced page... skipped some bytes */
if(!oy->unsynced){
oy->unsynced=1;
- return OGG_HOLE;
+ return OGG2_HOLE;
}
/* loop. keep looking */
@@ -486,9 +486,9 @@
}
/* clear things to an initial state. Good to call, eg, before seeking */
-int ogg_sync_reset(ogg_sync_state *oy){
+int ogg2_sync_reset(ogg2_sync_state *oy){
- ogg_buffer_release(oy->fifo_tail);
+ ogg2_buffer_release(oy->fifo_tail);
oy->fifo_tail=0;
oy->fifo_head=0;
oy->fifo_fill=0;
@@ -496,21 +496,21 @@
oy->unsynced=0;
oy->headerbytes=0;
oy->bodybytes=0;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
/* checksum the page; direct table CRC */
-int ogg_page_checksum_set(ogg_page *og){
+int ogg2_page_checksum_set(ogg2_page *og){
if(og && og->header){
- oggbyte_buffer ob;
- ogg_reference *or;
+ ogg2byte_buffer ob;
+ ogg2_reference *or;
ogg_uint32_t crc_reg=0;
int j;
/* safety; needed for API behavior, but not framing code */
- oggbyte_init(&ob,og->header,0);
- oggbyte_set4(&ob,0,22);
+ ogg2byte_init(&ob,og->header,0);
+ ogg2byte_set4(&ob,0,22);
or=og->header;
while(or){
@@ -528,11 +528,11 @@
or=or->next;
}
- oggbyte_set4(&ob,crc_reg,22);
+ ogg2byte_set4(&ob,crc_reg,22);
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
- return OGG_EINVAL;
+ return OGG2_EINVAL;
}
/* ENCODING PRIMITIVES: raw stream and page layer *******************/
@@ -540,20 +540,20 @@
/* On encode side, the sync layer provides centralized memory
management, buffering, and and abstraction to deal with fragmented
linked buffers as an iteration over flat char buffers.
- ogg_sync_encode and ogg_sync_destroy are as in decode. */
+ ogg2_sync_encode and ogg2_sync_destroy are as in decode. */
-int ogg_sync_pagein(ogg_sync_state *oy,ogg_page *og){
+int ogg2_sync_pagein(ogg2_sync_state *oy,ogg2_page *og){
/* buffer new */
if(oy->fifo_head)
- oy->fifo_head=ogg_buffer_cat(oy->fifo_head,og->header);
+ oy->fifo_head=ogg2_buffer_cat(oy->fifo_head,og->header);
else
- oy->fifo_head=ogg_buffer_walk(oy->fifo_tail=og->header);
- oy->fifo_head=ogg_buffer_cat(oy->fifo_head,og->body);
+ oy->fifo_head=ogg2_buffer_walk(oy->fifo_tail=og->header);
+ oy->fifo_head=ogg2_buffer_cat(oy->fifo_head,og->body);
memset(og,0,sizeof(*og));
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-long ogg_sync_bufferout(ogg_sync_state *oy, unsigned char **buffer){
+long ogg2_sync_bufferout(ogg2_sync_state *oy, unsigned char **buffer){
long ret=0;
/* return next fragment */
@@ -572,27 +572,27 @@
return ret;
}
-int ogg_sync_read(ogg_sync_state *oy, long bytes){
- if(!oy->fifo_tail)return OGG_EINVAL;
- oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes);
+int ogg2_sync_read(ogg2_sync_state *oy, long bytes){
+ if(!oy->fifo_tail)return OGG2_EINVAL;
+ oy->fifo_tail=ogg2_buffer_pretruncate(oy->fifo_tail,bytes);
if(!oy->fifo_tail)oy->fifo_head=0;
- return OGG_SUCCESS;
+ return OGG2_SUCCESS;
}
-void ogg_page_dup(ogg_page *dup,ogg_page *orig){
+void ogg2_page_dup(ogg2_page *dup,ogg2_page *orig){
dup->header_len=orig->header_len;
dup->body_len=orig->body_len;
- dup->header=ogg_buffer_dup(orig->header);
- dup->body=ogg_buffer_dup(orig->body);
+ dup->header=ogg2_buffer_dup(orig->header);
+ dup->body=ogg2_buffer_dup(orig->body);
}
-void ogg_packet_dup(ogg_packet *dup,ogg_packet *orig){
+void ogg2_packet_dup(ogg2_packet *dup,ogg2_packet *orig){
dup->bytes=orig->bytes;
dup->b_o_s=orig->b_o_s;
dup->e_o_s=orig->e_o_s;
dup->granulepos=orig->granulepos;
dup->packetno=orig->packetno;
- dup->packet=ogg_buffer_dup(orig->packet);
+ dup->packet=ogg2_buffer_dup(orig->packet);
}
More information about the commits
mailing list