Two mux-fix patches against current liboggz

Monty Montgomery <[email protected]>
Newsgroups gmane.comp.multimedia.ogg.theora.general
Message-ID <AANLkTikzQ8Qbmpe0tv=ax-zmVyC2jcRPKFtPP9KQw9CB__38567.381774965$1289741707$gmane$org@mail.gmail.com>
Two bugs in liboggz mux ordering bit me tonight.  These are patches
against current GIT, I'll apply if no one else volunteers, but I'd
prefer a quick review.  I'm surprised they'd not been caught, as it
was causing oggz-sort/oggz-merge to mis-mux potentially all files
containing theora (the frame->time calculation accounted for stream
version backwards, and the result was always off by one frame).  I
suppose it was just more likely at lower fps, and I'm working in 24
right now.

Monty

_______________________________________________
theora mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/theora
0001-The-correction-for-different-starting-frame-numbers-.patch (text/x-c, 1.6 KB)
From 142efb04e59a1666abf90ff6838d20e70f29e17d Mon Sep 17 00:00:00 2001
From: root <root@fishcore.(none)>
Date: Sun, 19 Sep 2010 05:02:37 -0400
Subject: [PATCH 1/2] The correction for different starting frame numbers on early Theora streams
 was backward, resulting in the timestamp calculation being off by
 a frame on all stream version.  This was causing oggz-sort and oggz-merge
 to mis-mux streams (which oggz-validate was catching properly)

---
 src/liboggz/oggz_auto.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/liboggz/oggz_auto.c b/src/liboggz/oggz_auto.c
index e7eba10..e477c0d 100644
--- a/src/liboggz/oggz_auto.c
+++ b/src/liboggz/oggz_auto.c
@@ -174,8 +174,15 @@ auto_theora (OGGZ * oggz, long serialno, unsigned char * data, long length, void
 			OGGZ_AUTO_MULT * (ogg_int64_t)fps_denominator);
   oggz_set_granuleshift (oggz, serialno, keyframe_shift);
 
-  if (version > THEORA_VERSION(3,2,0))
-    oggz_set_first_granule (oggz, serialno, 1);
+  /* the theora granpos->time calculation always adds one to the
+     index, but 3.2.0 streams count from zero and later versions count
+     from one.  So... for a 3.2.0 stream, the intitial frame number is
+     zero, but we add one (or in this case, subtract -1 in
+     oggz_metric_default_granuleshift).  For 3.2.1 and later, we
+     subtract one from the first frame number (1) to get an initial index
+     of zero, then add one to compute time for a net change of zero */
+  if (version < THEORA_VERSION(3,2,0))
+    oggz_set_first_granule (oggz, serialno, -1);
 
   oggz_stream_set_numheaders (oggz, serialno, 3);
 
-- 
1.6.3.1
0002-oggz-sort-would-miss-an-input-on-an-iteration-in-whi.patch (text/x-c, 1.2 KB)
From a5b673405beb78412486ef7edcfb51a9bb57f737 Mon Sep 17 00:00:00 2001
From: root <root@fishcore.(none)>
Date: Sun, 19 Sep 2010 05:04:26 -0400
Subject: [PATCH 2/2] oggz-sort would miss an input on an iteration in which a stream ends
 and is removed from the stream table.

---
 src/tools/oggz-sort.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/tools/oggz-sort.c b/src/tools/oggz-sort.c
index 7cc12bd..a5d9d14 100644
--- a/src/tools/oggz-sort.c
+++ b/src/tools/oggz-sort.c
@@ -336,7 +336,8 @@ oggz_sort (OSData * osdata, FILE * outfile)
 	  }
 	} else if (osdata->verbose) {
 	  if (input == NULL) {
-	    printf ("*** index %d NULL\n", i);
+	    printf ("*** index %d NULL, removing\n", i);
+            i--; // on next iteration, the 'next' input is now in our slot.
 	  } else {
 	    printf ("*** No page from index %d\n", i);
 	  }
@@ -351,6 +352,7 @@ oggz_sort (OSData * osdata, FILE * outfile)
     if (min_i != -1) {
       input = (OSInput *) oggz_table_nth (osdata->inputs, min_i, &key);
       og = input->og;
+
       checked_fwrite (og->header, 1, og->header_len, outfile);
       checked_fwrite (og->body, 1, og->body_len, outfile);
 
-- 
1.6.3.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.