[xiph-cvs] cvs commit: ogg/src bitwise.c
Monty
xiphmont at xiph.org
Tue May 7 20:34:11 PDT 2002
xiphmont 02/05/07 20:34:11
Modified: include/ogg ogg.h
src bitwise.c
Log:
Tested changes needed for ongoing work on branches in vorbis/
Add bitpack copy and checkpoint functions
Revision Changes Path
1.15 +10 -1 ogg/include/ogg/ogg.h
Index: ogg.h
===================================================================
RCS file: /usr/local/cvsroot/ogg/include/ogg/ogg.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ogg.h 2002/03/07 03:36:52 1.14
+++ ogg.h 2002/05/08 03:34:09 1.15
@@ -11,7 +11,7 @@
********************************************************************
function: toplevel libogg include
- last mod: $Id: ogg.h,v 1.14 2002/03/07 03:36:52 xiphmont Exp $
+ last mod: $Id: ogg.h,v 1.15 2002/05/08 03:34:09 xiphmont Exp $
********************************************************************/
#ifndef _OGG_H
@@ -110,6 +110,9 @@
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
extern void oggpack_writeinit(oggpack_buffer *b);
+extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
+extern void oggpack_writealign(oggpack_buffer *b);
+extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
extern void oggpack_reset(oggpack_buffer *b);
extern void oggpack_writeclear(oggpack_buffer *b);
extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
@@ -175,3 +178,9 @@
#endif
#endif /* _OGG_H */
+
+
+
+
+
+
<p><p>1.12 +45 -1 ogg/src/bitwise.c
Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/bitwise.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- bitwise.c 2002/01/19 04:06:53 1.11
+++ bitwise.c 2002/05/08 03:34:10 1.12
@@ -11,7 +11,7 @@
********************************************************************
function: packing variable sized words into an octet stream
- last mod: $Id: bitwise.c,v 1.11 2002/01/19 04:06:53 xiphmont Exp $
+ last mod: $Id: bitwise.c,v 1.12 2002/05/08 03:34:10 xiphmont Exp $
********************************************************************/
@@ -38,6 +38,50 @@
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
b->buffer[0]='\0';
b->storage=BUFFER_INCREMENT;
+}
+
+void oggpack_writetrunc(oggpack_buffer *b,long bits){
+ long bytes=bits>>3;
+ bits-=bytes*8;
+ b->ptr=b->buffer+bytes;
+ b->endbit=bits;
+ b->endbyte=bytes;
+ *b->ptr|=mask[bits];
+}
+
+void oggpack_writealign(oggpack_buffer *b){
+ int bits=8-b->endbit;
+ if(bits<8)
+ oggpack_write(b,0,bits);
+}
+
+void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){
+ unsigned char *ptr=(unsigned char *)source;
+
+ long bytes=bits/8;
+ bits-=bytes*8;
+
+ if(b->endbit){
+ int i;
+ /* unaligned copy. Do it the hard way. */
+ for(i=0;i<bytes;i++)
+ oggpack_write(b,(long)(ptr[i]),8);
+ }else{
+ /* aligned block copy */
+ if(b->endbyte+bytes+1>=b->storage){
+ b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
+ b->buffer=_ogg_realloc(b->buffer,b->storage);
+ b->ptr=b->buffer+b->endbyte;
+ }
+
+ memmove(b->ptr,source,bytes);
+ b->ptr+=bytes;
+ b->buffer+=bytes;
+ *b->ptr=0;
+
+ }
+ if(bits)
+ oggpack_write(b,(long)(ptr[bytes]),bits);
}
void oggpack_reset(oggpack_buffer *b){
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list