[xiph-commits] r3780 - liboggz/trunk/src/tools
conrad at svn.annodex.net
conrad at svn.annodex.net
Fri Nov 14 13:15:35 PST 2008
Author: conrad
Date: 2008-11-14 13:15:35 -0800 (Fri, 14 Nov 2008)
New Revision: 3780
Added:
liboggz/trunk/src/tools/oggz_tools_dirac.h
Modified:
liboggz/trunk/src/tools/Makefile.am
liboggz/trunk/src/tools/oggz_tools.c
Log:
oggz-tools: split Dirac granulepos parsing out into a separate function, and use ogg int types
Modified: liboggz/trunk/src/tools/Makefile.am
===================================================================
--- liboggz/trunk/src/tools/Makefile.am 2008-11-14 20:26:32 UTC (rev 3779)
+++ liboggz/trunk/src/tools/Makefile.am 2008-11-14 21:15:35 UTC (rev 3780)
@@ -27,7 +27,7 @@
endif
-noinst_HEADERS = oggz_tools.h skeleton.h
+noinst_HEADERS = oggz_tools.h oggz_tools_dirac.h skeleton.h
# Programs to build
bin_PROGRAMS = $(oggz_any_programs) $(oggz_read_programs) $(oggz_rw_programs)
Modified: liboggz/trunk/src/tools/oggz_tools.c
===================================================================
--- liboggz/trunk/src/tools/oggz_tools.c 2008-11-14 20:26:32 UTC (rev 3779)
+++ liboggz/trunk/src/tools/oggz_tools.c 2008-11-14 21:15:35 UTC (rev 3780)
@@ -38,7 +38,9 @@
#include <getopt.h>
#include <oggz/oggz.h>
+
#include "dirac.h"
+#include "oggz_tools_dirac.h"
#if defined (WIN32) || defined (__EMX__)
#include <fcntl.h>
@@ -441,6 +443,16 @@
return fprintf (stream, "%s%02d:%02d:%06.3f", sign, hrs, min, sec);
}
+void
+ot_dirac_gpos_parse (ogg_int64_t iframe, ogg_int64_t pframe,
+ struct ot_dirac_gpos * dg)
+{
+ dg->pt = (iframe + pframe) >> 9;
+ dg->dist = ((iframe & 0xff) << 8) | (pframe & 0xff);
+ dg->delay = pframe >> 9;
+ dg->dt = (int64_t)dg->pt - dg->delay;
+}
+
int
ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
ogg_int64_t granulepos)
@@ -457,13 +469,11 @@
if (oggz_stream_get_content (oggz, serialno) != OGGZ_CONTENT_DIRAC) {
ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
} else {
- uint32_t pt = (iframe + pframe) >> 9;
- uint16_t dist = ((iframe & 0xff) << 8) | (pframe & 0xff);
- uint16_t delay = pframe >> 9;
- int64_t dt = (int64_t)pt - delay;
+ struct ot_dirac_gpos dg;
+ ot_dirac_gpos_parse (iframe, pframe, &dg);
ret = fprintf (stream,
"(pt:%u,dt:%" PRId64 ",dist:%hu,delay:%hu)",
- pt, dt, dist, delay);
+ dg.pt, dg.dt, dg.dist, dg.delay);
}
}
Added: liboggz/trunk/src/tools/oggz_tools_dirac.h
===================================================================
--- liboggz/trunk/src/tools/oggz_tools_dirac.h (rev 0)
+++ liboggz/trunk/src/tools/oggz_tools_dirac.h 2008-11-14 21:15:35 UTC (rev 3780)
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2008 Annodex Association
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ - Neither the name of the Annodex Association or the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ASSOCIATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __OGGZ_TOOLS_DIRAC_H__
+#define __OGGZ_TOOLS_DIRAC_H__
+
+#include "config.h"
+
+/*
+ * Dirac specific granulepos interpretation
+ */
+struct ot_dirac_gpos {
+ ogg_uint32_t pt;
+ ogg_uint16_t dist;
+ ogg_uint16_t delay;
+ ogg_int64_t dt;
+};
+
+/* Parse a granulepos value using Dirac interpretation */
+void ot_dirac_gpos_parse (ogg_int64_t iframe, ogg_int64_t pframe,
+ struct ot_dirac_gpos * dg);
+
+#endif /* __OGGZ_TOOLS_DIRAC_H__ */
More information about the commits
mailing list