Commit a8c81974 authored by conrad's avatar conrad

add "-c content-type" option to oggzdump; eg:

$ oggzdump -c theora pants.ogg
will just dump the theora stream, and
$ oggzdump -c theora -n pants.ogg
will just dump the theora BOS.
(theora, vorbis, speex, cmml supported, as for oggzrip, via oggz_tools.c)


git-svn-id: http://svn.annodex.net/liboggz/trunk@1191 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 8d5cc343
...\" $Header: /var/lib/cvsd/annodex/liboggz/doc/oggzdump.1,v 1.1 2004/01/04 05:28:25 zen Exp $
...\"
...\" transcript compatibility for postscript use.
...\"
...\" synopsis: .P! <file.ps>
...\"
.\" $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/cmd/docbook-to-man.sh,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $
.\"
.\" transcript compatibility for postscript use.
.\"
.\" synopsis: .P! <file.ps>
.\"
.de P!
.fl
\!!1 setgray
......@@ -15,7 +15,7 @@
\!!save /psv exch def currentpoint translate 0 0 moveto
\!!/showpage{}def
.fl \" prolog
.sy sed -e 's/^/!/' \\$1\" bring in postscript file
.sy sed \-e 's/^/!/' \\$1\" bring in postscript file
\!!psv restore
.
.de pF
......@@ -58,7 +58,7 @@ such a hexdump
.SH "SYNOPSIS"
.PP
\fBoggzdump\fR [-b | --binary ] [-x | --hexadecimal ] [-n | --new ] [-o \fBfilename\fR | --output \fBfilename\fR ] [-s \fBserialno\fR | --serialno \fBserialno\fR ] [-O | --hide-offset ] [-S | --hide-serialno ] [-G | --hide-granulepos ] [-P | --hide-packetno ] [-h | --help ] filename
\fBoggzdump\fR [-b | --binary ] [-x | --hexadecimal ] [-n | --new ] [-o \fBfilename\fR | --output \fBfilename\fR ] [-c \fBcontent-type\fR | --content-type \fBcontent-type\fR ] [-s \fBserialno\fR | --serialno \fBserialno\fR ] [-O | --hide-offset ] [-S | --hide-serialno ] [-G | --hide-granulepos ] [-P | --hide-packetno ] [-h | --help ] filename
.PP
\fBoggzdump\fR [-r | --revert ] [-o \fBfilename\fR | --output \fBfilename\fR ] filename
.SH "Description"
......@@ -75,7 +75,7 @@ oggzdump file.
.IP "-b, --binary" 10
Generate a binary dump of each packet
.IP "-x, --hexadeciaml" 10
.IP "-x, --hexadecimal" 10
Generate a hexadecimal dump of each packet
.SS "Filtering options"
......@@ -84,6 +84,11 @@ Only dump the first packet of each new logical
bitstream found; for correctly formed Ogg files, this dumps
only the beginning-of-stream packets.
.IP "-c \fBcontent-type\fR, --content-type \fBcontent-type\fR" 10
Dump only the logical bitstreams for a specific
\fBcontent-type\fR. The following codec names
are currently detected: "theora", "vorbis", "speex", "cmml"
.IP "-s \fBserialno\fR, --serialno \fBserialno\fR" 10
Dump only the logical bitstream with specified
\fBserialno\fR.
......@@ -147,4 +152,4 @@ Copyright \(co 2003 CSIRO Australia
\fBoggzdiff\fP\fB(1)\fP,
\fBxxd\fP\fB(1)\fP,
\fBhexdump\fP\fB(1)\fP
...\" created by instant / docbook-to-man, Wed 19 Nov 2003, 11:46
.\" created by instant / docbook-to-man, Wed 30 Mar 2005, 23:06
......@@ -78,6 +78,11 @@ manpage.1: manpage.sgml
<arg choice="opt">--output <parameter>filename</parameter></arg>
</group>
<group>
<arg choice="opt">-c <parameter>content-type</parameter></arg>
<arg choice="opt">--content-type <parameter>content-type</parameter></arg>
</group>
<group>
<arg choice="opt">-s <parameter>serialno</parameter></arg>
<arg choice="opt">--serialno <parameter>serialno</parameter></arg>
......@@ -163,6 +168,14 @@ manpage.1: manpage.sgml
</para></listitem>
</varlistentry>
<varlistentry>
<term>-c <parameter>content-type</parameter>, --content-type <parameter>content-type</parameter></term>
<listitem><para>Dump only the logical bitstreams for a specific
<parameter>content-type</parameter>. The following codec names
are currently detected: "theora", "vorbis", "speex", "cmml"
</para></listitem>
</varlistentry>
<varlistentry>
<term>-s <parameter>serialno</parameter>, --serialno <parameter>serialno</parameter></term>
<listitem><para>Dump only the logical bitstream with specified
......
......@@ -54,11 +54,15 @@
#undef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
typedef struct {
OggzTable * content_types_table;
OggzReadPacket read_packet;
} ODData;
static char * progname;
static FILE * outfile = NULL;
static int dump_bits = 0;
static int dump_char = 1;
static int dump_all_serialnos = 1;
static int truth = 1;
static int hide_offset = 0;
......@@ -76,6 +80,10 @@ usage (char * progname)
printf (" -x, --hexadecimal Generate a hexadecimal dump of each packet\n");
printf ("\nFiltering options\n");
printf (" -n, --new Only dump the first packet of each logical bitstream\n");
printf (" -c content-type, --content-type content-type\n");
printf (" Dump only the logical bitstreams for a specified\n");
printf (" content-type. The following codecs are currently\n");
printf (" detected: theora, vorbis, speex, cmml\n");
printf (" -s serialno, --serialno serialno\n");
printf (" Dump only the logical bitstream with specified serialno\n");
printf (" -O, --hide-offset Hide the byte offset of each packet\n");
......@@ -94,6 +102,25 @@ usage (char * progname)
printf ("Please report bugs to <ogg-dev@xiph.org>\n");
}
static ODData *
oddata_new ()
{
ODData * oddata = malloc (sizeof (ODData));
memset (oddata, 0, sizeof (ODData));
oddata->content_types_table = oggz_table_new ();
return oddata;
}
static void
oddata_delete (ODData * oddata)
{
oggz_table_delete (oddata->content_types_table);
free (oddata);
}
static void
dump_char_line (unsigned char * buf, long n)
{
......@@ -242,6 +269,27 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
return 0;
}
static int
filter_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
{
ODData * oddata = (ODData *) user_data;
const char * ident;
int i, n;
if (ogg_page_bos ((ogg_page *)og)) {
ident = ot_page_identify (og, NULL);
n = oggz_table_size (oddata->content_types_table);
for (i = 0; i < n; i++) {
char * c = oggz_table_nth (oddata->content_types_table, i, NULL);
if (strcasecmp (c, ident) == 0) {
oggz_set_read_callback (oggz, serialno, oddata->read_packet, NULL);
}
}
}
return 0;
}
static int
ignore_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
......@@ -390,15 +438,18 @@ main (int argc, char ** argv)
int show_version = 0;
int show_help = 0;
ODData * oddata;
OGGZ * oggz;
char * infilename = NULL, * outfilename = NULL;
int revert = 0;
OggzTable * table = NULL;
long serialno;
OggzReadPacket my_read_packet = read_packet;
int i, size;
long n;
int filter_serialnos = 0;
int filter_content_types = 0;
ot_init ();
progname = argv[0];
......@@ -408,10 +459,14 @@ main (int argc, char ** argv)
return (1);
}
oddata = oddata_new ();
oddata->read_packet = read_packet;
table = oggz_table_new();
while (1) {
char * optstring = "hvbxnro:s:OSGP";
char * optstring = "hvbxnro:s:c:OSGP";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
......@@ -423,6 +478,7 @@ main (int argc, char ** argv)
{"revert", no_argument, 0, 'r'},
{"output", required_argument, 0, 'o'},
{"serialno", required_argument, 0, 's'},
{"content-type", required_argument, 0, 'c'},
{"hide-offset", no_argument, 0, 'O'},
{"hide-serialno", no_argument, 0, 'S'},
{"hide-granulepos", no_argument, 0, 'G'},
......@@ -451,7 +507,7 @@ main (int argc, char ** argv)
dump_bits = 1;
break;
case 'n': /* new */
my_read_packet = read_new_packet;
oddata->read_packet = read_new_packet;
break;
case 'o': /* output */
outfilename = optarg;
......@@ -460,10 +516,15 @@ main (int argc, char ** argv)
revert = 1;
break;
case 's': /* serialno */
dump_all_serialnos = 0;
filter_serialnos = 1;
serialno = atol (optarg);
oggz_table_insert (table, serialno, &truth);
break;
case 'c': /* content-type */
filter_content_types = 1;
n = (long)oggz_table_size (oddata->content_types_table);
oggz_table_insert (oddata->content_types_table, (long)n, optarg);
break;
case 'O': /* hide offset */
hide_offset = 1;
break;
......@@ -538,13 +599,19 @@ main (int argc, char ** argv)
goto exit_err;
}
if (dump_all_serialnos) {
oggz_set_read_callback (oggz, -1, my_read_packet, NULL);
if (!filter_serialnos && !filter_content_types) {
oggz_set_read_callback (oggz, -1, oddata->read_packet, NULL);
} else {
size = oggz_table_size (table);
for (i = 0; i < size; i++) {
oggz_table_nth (table, i, &serialno);
oggz_set_read_callback (oggz, serialno, my_read_packet, NULL);
if (filter_serialnos) {
size = oggz_table_size (table);
for (i = 0; i < size; i++) {
oggz_table_nth (table, i, &serialno);
oggz_set_read_callback (oggz, serialno, oddata->read_packet, NULL);
}
}
if (filter_content_types) {
oggz_set_read_page (oggz, -1, filter_page, oddata);
}
}
......@@ -554,10 +621,12 @@ main (int argc, char ** argv)
}
exit_ok:
oddata_delete (oddata);
oggz_table_delete (table);
exit (0);
exit_err:
oddata_delete (oddata);
oggz_table_delete (table);
exit (1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment