[xiph-cvs] cvs commit: ogg-tools/oggmerge midi.c vorbis.c
Jack Moffitt
jack at xiph.org
Tue Sep 4 10:38:05 PDT 2001
jack 01/09/04 10:38:05
Modified: oggmerge midi.c vorbis.c
Log:
Midi pages need to be much smaller so that they are more evenly spread out.
Each page only contains one packet now, and packets are ~128 bytes.
Also, we sync the stream so that pages _start_ together instead of
_end_ together.
This is a result of today's conversations with Monty.
Revision Changes Path
1.4 +8 -5 ogg-tools/oggmerge/midi.c
Index: midi.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggmerge/midi.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- midi.c 2001/09/04 02:45:57 1.3
+++ midi.c 2001/09/04 17:38:04 1.4
@@ -48,6 +48,7 @@
unsigned long ppos;
midi_page_t *pages;
int serialno;
+ ogg_int64_t old_granulepos;
// timing information
int ticks;
long tempo;
@@ -77,6 +78,7 @@
midistate->op = NULL;
midistate->pages = NULL;
midistate->serialno = serialno;
+ midistate->old_granulepos = 0;
midistate->ticks = 480;
midistate->tempo = 500000; // 120 bpm == 500,000 microseconds per beat
midistate->frames = 0;
@@ -326,12 +328,14 @@
u_int64_t timestamp;
if (midistate->smtpe) {
- timestamp = (double)granulepos * ((double)(midistate->frames * midistate->ticks) / (double)1000000);
+ timestamp = (double)midistate->old_granulepos * ((double)(midistate->frames * midistate->ticks) / (double)1000000);
} else {
// tempo is in us/quartnernote
- timestamp = (double)granulepos * (double)midistate->tempo / (double)midistate->ticks;
+ timestamp = (double)midistate->old_granulepos * (double)midistate->tempo / (double)midistate->ticks;
}
+ midistate->old_granulepos = granulepos;
+
return timestamp;
}
@@ -697,16 +701,15 @@
continue;
case e_endofevent:
midistate->current += midistate->timestamp;
- if (midistate->ppos >= 512 || all_done) {
+ if (midistate->ppos >= 128 || all_done) {
// close out this packet and start a new one
_resize_packet(midistate, midistate->ppos);
midistate->op->granulepos = midistate->current;
ogg_stream_packetin(&midistate->os, midistate->op);
midistate->op = NULL;
- _queue_pages(midistate);
+ _flush_pages(midistate);
if (all_done) {
midistate->ps = e_done;
- _flush_pages(midistate);
} else {
midistate->ps = e_newpacket;
}
1.4 +10 -2 ogg-tools/oggmerge/vorbis.c
Index: vorbis.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggmerge/vorbis.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vorbis.c 2001/09/04 02:45:57 1.3
+++ vorbis.c 2001/09/04 17:38:04 1.4
@@ -18,6 +18,7 @@
typedef struct {
ogg_sync_state oy;
int serialno;
+ ogg_int64_t old_granulepos;
int first_page;
unsigned long samplerate;
vorbis_page_t *pages;
@@ -25,6 +26,7 @@
static void _add_vorbis_page(vorbis_state_t *vstate, ogg_page *og);
+
int vorbis_state_init(oggmerge_state_t *state, int serialno)
{
vorbis_state_t *vstate;
@@ -37,7 +39,11 @@
ogg_sync_init(&vstate->oy);
vstate->first_page = 1;
vstate->samplerate = 0;
-
+ vstate->old_granulepos = 0;
+
+ // NOTE: we just ignore serialno for now
+ // until a future libogg supports ogg_page_set_serialno
+
state->private = (void *)vstate;
return 1;
@@ -146,7 +152,9 @@
if (vstate->samplerate == 0) return 0;
- stamp = (double)granulepos * (double)1000000 / (double)vstate->samplerate;
+ stamp = (double)vstate->old_granulepos * (double)1000000 / (double)vstate->samplerate;
+
+ vstate->old_granulepos = granulepos;
return stamp;
}
--- >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