[xiph-cvs] cvs commit: ogg-tools/oggplay oggplay.c

Ralph Giles giles at xiph.org
Mon Sep 3 12:11:33 PDT 2001



giles       01/09/03 12:11:33

  Modified:    oggplay  oggplay.c
  Log:
  interm checkin. still not functional

Revision  Changes    Path
1.2       +43 -6     ogg-tools/oggplay/oggplay.c

Index: oggplay.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggplay/oggplay.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- oggplay.c	2001/08/25 22:22:31	1.1
+++ oggplay.c	2001/09/03 19:11:33	1.2
@@ -3,7 +3,7 @@
 
         a testbed player for ogg multimedia
 
-	$Date: 2001/08/25 22:22:31 $
+	$Date: 2001/09/03 19:11:33 $
 
         Ralph Giles <giles at thaumas.net>
 
@@ -134,14 +134,51 @@
         if (stuff->og_last && stuff->op_last) {
                 fprintf(stderr, "found packet %ld from last time\n",
                         stuff->op_last->packetno);
-			copybytes = MIN(byteswanted, stuff->op_last->bytes - stuff->op_bytes);
-			fprintf(stderr, "  submitting %d bytes to the mng decoder\n", copybytes);
+		copybytes = MIN(byteswanted, stuff->op_last->bytes - stuff->op_bytes);
+		fprintf(stderr, "  submitting %d bytes to the mng decoder\n", copybytes);
 
-			/* copy it into the mng decode buffer */
-			memcpy(buffer, stuff->op_last->packet, copybytes);
-			*bytesread += copybytes;
+		/* copy it into the mng decode buffer */
+		memcpy(buffer, stuff->op_last->packet, copybytes);
+		*bytesread += copybytes;
+
+		stuff->op_last = NULL;
+
+		/* are we done? */
+		if (*bytesread >= byteswanted)
+			return MNG_TRUE;
         }
 
+	/* we still need more data, so look for more packets in the saved page */
+	if (stuff->og_last) {
+	while (ogg_stream_packetout(stuff->os, op) > 0) {
+		fprintf(stderr, "  got packet %ld\n", op->packetno);
+		
+		/* copy it into the mng decode buffer */
+		copybytes = MIN(byteswanted - *bytesread, stuff->op_last->bytes - stuff->op_bytes);
+		fprintf(stderr, "  submitting %d bytes to the mng decoder\n", copybytes);
+                memcpy(buffer + (*bytesread), op->packet, copybytes);
+                *bytesread += copybytes;
+
+		/* are we done? */
+                if (*bytesread >= byteswanted) {
+			/* save any state */
+			if (copybytes < op->bytes) {
+                                stuff->op_last = op;
+                                stuff->op_bytes = copybytes;
+                                fprintf(stderr, "saving state: %d bytes left in packet number %ld\n",
+					op->bytes-copybytes, op->packetno);
+			} 
+			return MNG_TRUE;
+		}
+	}
+	/* end of any stored data */
+	fprintf(stderr, " end of page %ld\n", ogg_page_pageno(stuff->og_last));
+	stuff->og_last = NULL;
+        stuff->op_last = NULL;
+        stuff->op_bytes= 0;   
+        free(op);
+	free(og);
+	}
 
         /* get a decoding buffer */
         buf = ogg_sync_buffer(stuff->oy, byteswanted+4096);

--- >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