[xiph-cvs] cvs commit: ogg/src bitwise.c buffer.c ogginternal.h stream.c sync.c
Monty
xiphmont at xiph.org
Wed Mar 26 23:12:45 PST 2003
xiphmont 03/03/27 02:12:45
Modified: src Tag: libogg2-zerocopy bitwise.c buffer.c
ogginternal.h stream.c sync.c
Log:
Incremental
Revision Changes Path
No revision
<p>No revision
<p>1.14.2.14 +6 -7 ogg/src/bitwise.c
Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/bitwise.c,v
retrieving revision 1.14.2.13
retrieving revision 1.14.2.14
diff -u -r1.14.2.13 -r1.14.2.14
--- bitwise.c 23 Mar 2003 23:40:58 -0000 1.14.2.13
+++ bitwise.c 27 Mar 2003 07:12:45 -0000 1.14.2.14
@@ -11,7 +11,7 @@
********************************************************************
function: pack variable sized words into an octet stream
- last mod: $Id: bitwise.c,v 1.14.2.13 2003/03/23 23:40:58 xiphmont Exp $
+ last mod: $Id: bitwise.c,v 1.14.2.14 2003/03/27 07:12:45 xiphmont Exp $
********************************************************************/
@@ -1112,7 +1112,7 @@
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};
+ ogg_reference lor={&lob,0,8,0,1};
oggpack_readinit(&r,&lor);
for(i=0;i<64;i++){
@@ -1129,7 +1129,7 @@
}
{
ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0};
+ ogg_reference lor={&lob,0,8,0,1};
unsigned long test;
oggpack_readinit(&r,&lor);
@@ -1207,7 +1207,7 @@
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};
+ ogg_reference lor={&lob,0,8,0,1};
unsigned long test;
oggpackB_readinit(&r,&lor);
@@ -1225,7 +1225,7 @@
}
{
ogg_buffer lob={"\0\0\0\0\0\0\0\0",8,0,{0}};
- ogg_reference lor={&lob,0,8,0};
+ ogg_reference lor={&lob,0,8,0,1};
unsigned long test;
oggpackB_readinit(&r,&lor);
@@ -1528,8 +1528,7 @@
bitcount+=len[j];
/* also exercise the split code */
{
- ogg_reference *temp=or;
- or=ogg_buffer_split(or,bitcount/8);
+ ogg_reference *temp=ogg_buffer_split(&or,0,bitcount/8);
ogg_buffer_release(temp);
}
<p><p>1.1.2.11 +58 -47 ogg/src/Attic/buffer.c
Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/buffer.c,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- buffer.c 26 Mar 2003 23:49:26 -0000 1.1.2.10
+++ buffer.c 27 Mar 2003 07:12:45 -0000 1.1.2.11
@@ -11,7 +11,7 @@
********************************************************************
function: centralized fragment buffer management
- last mod: $Id: buffer.c,v 1.1.2.10 2003/03/26 23:49:26 xiphmont Exp $
+ last mod: $Id: buffer.c,v 1.1.2.11 2003/03/27 07:12:45 xiphmont Exp $
********************************************************************/
@@ -176,9 +176,11 @@
/* duplicate the reference chain; increment refcounts */
while(or && length){
ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner);
- if(head)head->next=temp;
+ if(head)
+ head->next=temp;
+ else
+ ret=temp;
head=temp;
- if(!ret)ret=head;
#ifdef OGGBUFFER_DEBUG
if(or->used==0){
@@ -191,11 +193,12 @@
head->begin=or->begin+begin;
head->length=length;
- if(head->begin+head->length>or->begin+or->length)
- head->length=or->begin+or->length-head->begin;
-
+ if(head->length>or->length-begin)
+ head->length=or->length-begin;
+
begin=0;
length-=head->length;
+ or=or->next;
}
ogg_buffer_mark(ret);
@@ -222,16 +225,19 @@
ogg_mutex_unlock(&bs->mutex);
}
-/* split a reference into two references; on return the passed in
- pointer points to the first segment (pos of zero disallowed).
- pointer to the beginning of the secrond reference is returned. If
- pos is at or past the end of the passed in segment, returns NULL */
-ogg_reference *ogg_buffer_split(ogg_reference *or,long pos){
+/* 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){
/* 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;
+
while(or && pos>or->length){
#ifdef OGGBUFFER_DEBUG
if(or->used==0){
@@ -243,45 +249,50 @@
or=or->next;
}
- if(!or)return NULL;
-
- if(pos>=or->length){
- /* exact split, or off the end */
- if(or->next){
-
- /* a split */
- ogg_reference *ret=or->next;
- or->next=0;
- return ret;
+ if(!or || pos==0){
+ return 0;
+
+ }else{
+
+ if(pos>=or->length){
+ /* exact split, or off the end? */
+ if(or->next){
+
+ /* a split */
+ *tail=or->next;
+ or->next=0;
+
+ }else{
+
+ /* off or at the end */
+ *tail=*head=0;
+
+ }
}else{
-
- /* off or at the end */
- return NULL;
-
+
+ /* split within a fragment */
+ long lengthA=pos;
+ long beginB=or->begin+pos;
+ long lengthB=or->length-pos;
+
+ /* make a new reference to tail the second piece */
+ *tail=_fetch_ref(or->buffer->ptr.owner);
+
+ (*tail)->buffer=or->buffer;
+ (*tail)->begin=beginB;
+ (*tail)->length=lengthB;
+ (*tail)->next=or->next;
+ _ogg_buffer_mark_one(*tail);
+ if(head && or==*head)*head=*tail;
+
+ /* update the first piece */
+ or->next=0;
+ or->length=lengthA;
+
}
- }else{
-
- /* split within a fragment */
- long lengthA=pos;
- long beginB=or->begin+pos;
- long lengthB=or->length-pos;
-
- /* make a new reference to head the second piece */
- ogg_reference *ret=_fetch_ref(or->buffer->ptr.owner);
-
- ret->buffer=or->buffer;
- ret->begin=beginB;
- ret->length=lengthB;
- ret->next=or->next;
- _ogg_buffer_mark_one(ret);
-
- /* update the first piece */
- or->next=0;
- or->length=lengthA;
-
- return ret;
}
+ return ret;
}
/* add a new fragment link to the end of a chain; return ptr to the new link */
<p><p>1.1.2.12 +2 -1 ogg/src/Attic/ogginternal.h
Index: ogginternal.h
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/ogginternal.h,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -r1.1.2.11 -r1.1.2.12
--- ogginternal.h 26 Mar 2003 23:49:26 -0000 1.1.2.11
+++ ogginternal.h 27 Mar 2003 07:12:45 -0000 1.1.2.12
@@ -11,7 +11,7 @@
********************************************************************
function: internal/hidden data representation structures
- last mod: $Id: ogginternal.h,v 1.1.2.11 2003/03/26 23:49:26 xiphmont Exp $
+ last mod: $Id: ogginternal.h,v 1.1.2.12 2003/03/27 07:12:45 xiphmont Exp $
********************************************************************/
@@ -147,7 +147,8 @@
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 *or,long pos);
+extern ogg_reference *ogg_buffer_split(ogg_reference **tail,
+ ogg_reference **head,long pos);
extern int oggbyte_init(oggbyte_buffer *b,ogg_reference *or,
ogg_buffer_state *bs);
<p><p>1.1.2.7 +29 -11 ogg/src/Attic/stream.c
Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/stream.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- stream.c 26 Mar 2003 23:49:26 -0000 1.1.2.6
+++ stream.c 27 Mar 2003 07:12:45 -0000 1.1.2.7
@@ -12,7 +12,7 @@
function: code raw packets into framed Ogg logical stream and
decode Ogg logical streams back into raw packets
- last mod: $Id: stream.c,v 1.1.2.6 2003/03/26 23:49:26 xiphmont Exp $
+ last mod: $Id: stream.c,v 1.1.2.7 2003/03/27 07:12:45 xiphmont Exp $
********************************************************************/
@@ -177,19 +177,17 @@
/* split page references out of the fifos */
if(og){
- og->header=os->header_tail;
- og->body=os->body_tail;
- os->header_tail=ogg_buffer_split(os->header_tail,header_bytes);
- os->body_tail=ogg_buffer_split(os->body_tail,body_bytes);
+ og->header=ogg_buffer_split(&os->header_tail,&os->header_head,header_bytes);
+ og->body=ogg_buffer_split(&os->body_tail,&os->body_head,body_bytes);
/* checksum */
ogg_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);
+ if(!os->header_tail)os->header_head=0;
+ if(!os->body_tail)os->body_head=0;
}
- if(!os->header_tail)os->header_head=0;
- if(!os->body_tail)os->body_head=0;
return 1;
}
@@ -452,12 +450,11 @@
/* split the body contents off */
if(op){
- op->packet=os->body_tail;
- os->body_tail=ogg_buffer_split(os->body_tail,os->body_fill&FINMASK);
+ op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,os->body_fill&FINMASK);
}else{
os->body_tail=ogg_buffer_pretruncate(os->body_tail,os->body_fill&FINMASK);
+ if(os->body_tail==0)os->body_head=0;
}
- if(os->body_tail==0)os->body_head=0;
/* update lacing pointers */
os->body_fill=os->body_fill_next;
@@ -547,6 +544,24 @@
long j;
oggbyte_buffer ob;
+ /* test buffer lengths */
+ long header_len=header[26]+27;
+ long body_len=0;
+
+ for(j=27;j<header_len;j++)
+ body_len+=header[j];
+
+ if(header_len!=ogg_buffer_length(og->header)){
+ fprintf(stderr,"page header length mismatch: %ld correct, buffer is %ld\n",
+ header_len,ogg_buffer_length(og->header));
+ exit(1);
+ }
+ if(body_len!=ogg_buffer_length(og->body)){
+ fprintf(stderr,"page body length mismatch: %ld correct, buffer is %ld\n",
+ body_len,ogg_buffer_length(og->body));
+ exit(1);
+ }
+
/* Test data */
oggbyte_init(&ob,og->body,0);
for(j=0;j<ogg_buffer_length(og->body);j++)
@@ -895,8 +910,8 @@
ogg_stream_pagein(os_de,&og_de);
/* packets out? */
- while(ogg_stream_packetpeek(os_de,&op_de2)>0){
- ogg_stream_packetpeek(os_de,NULL);
+ 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 */
/* verify the packets! */
@@ -950,6 +965,9 @@
fprintf(stderr,"packet/peek granpos mismatch!\n");
exit(1);
}
+
+ ogg_packet_release(&op_de);
+ ogg_packet_release(&op_de2);
}
}
}
<p><p>1.1.2.8 +4 -6 ogg/src/Attic/sync.c
Index: sync.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/sync.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- sync.c 26 Mar 2003 23:49:26 -0000 1.1.2.7
+++ sync.c 27 Mar 2003 07:12:45 -0000 1.1.2.8
@@ -12,7 +12,7 @@
function: decode stream sync and memory management foundation code;
takes in raw data, spits out packets
- last mod: $Id: sync.c,v 1.1.2.7 2003/03/26 23:49:26 xiphmont Exp $
+ last mod: $Id: sync.c,v 1.1.2.8 2003/03/27 07:12:45 xiphmont Exp $
note: The CRC code is directly derived from public domain code by
Ross Williams (ross at guest.adelaide.edu.au). See docs/framing.html
@@ -335,21 +335,19 @@
/* We have a page. Set up page return. */
if(og){
/* set up page output */
- og->header=oy->fifo_tail;
- oy->fifo_tail=ogg_buffer_split(oy->fifo_tail,oy->headerbytes);
- og->body=oy->fifo_tail;
- oy->fifo_tail=ogg_buffer_split(oy->fifo_tail,oy->bodybytes);
+ og->header=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->headerbytes);
+ og->body=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->bodybytes);
}else{
/* simply advance */
oy->fifo_tail=
ogg_buffer_pretruncate(oy->fifo_tail,oy->headerbytes+oy->bodybytes);
+ if(!oy->fifo_tail)oy->fifo_head=0;
}
ret=oy->headerbytes+oy->bodybytes;
oy->unsynced=0;
oy->headerbytes=0;
oy->bodybytes=0;
- if(!oy->fifo_tail)oy->fifo_head=0;
oy->fifo_fill-=ret;
return ret;
<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