Commit 5d6f689c authored by conrad's avatar conrad

generalize granulepos printing in oggz tools, use in oggzdump and oggzinfo


git-svn-id: http://svn.annodex.net/liboggz/trunk@2883 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent fdc0a767
......@@ -43,6 +43,12 @@
#define snprintf _snprintf
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
# define PRId64 "I64d"
#endif
static ogg_uint32_t
_le_32 (ogg_uint32_t i)
{
......@@ -346,6 +352,25 @@ ot_fprint_time (FILE * stream, double seconds)
return fprintf (stream, "%s%02d:%02d:%06.3f", sign, hrs, min, sec);
}
int
ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
ogg_int64_t granulepos)
{
int ret, granuleshift = oggz_get_granuleshift (oggz, serialno);
if (granuleshift < 1) {
ret = fprintf (stream, "%" PRId64, granulepos);
} else {
ogg_int64_t iframe, pframe;
iframe = granulepos >> granuleshift;
pframe = granulepos - (iframe << granuleshift);
ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
}
return ret;
}
void
ot_init (void)
{
......
......@@ -52,6 +52,9 @@ int ot_print_bitrate (long bps);
int ot_fprint_time (FILE * stream, double seconds);
int ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
ogg_int64_t granulepos);
/*
* Tool initialization function. Sets stdin, stdio to binary on windows etc.
* Call this at the beginning of main().
......
......@@ -244,7 +244,6 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
ODData * oddata = (ODData *) user_data;
ogg_int64_t units;
double time_offset;
int granuleshift;
if (oddata->hide_offset) {
fprintf (outfile, "oOo");
......@@ -261,23 +260,14 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
fprintf (outfile, ": serialno %010ld, ",
oddata->hide_serialno ? -1 : serialno);
fprintf (outfile, "granulepos ");
if (oddata->hide_granulepos) {
fprintf (outfile, "granulepos gGg,");
fprintf (outfile, "gGg");
} else {
granuleshift = oggz_get_granuleshift (oggz, serialno);
if (granuleshift < 1) {
fprintf (outfile, "granulepos %" PRId64 ",", op->granulepos);
} else {
ogg_int64_t iframe, pframe;
iframe = op->granulepos >> granuleshift;
pframe = op->granulepos - (iframe << granuleshift);
fprintf (outfile, "granulepos %" PRId64 "|%" PRId64 ",",
iframe, pframe);
}
ot_fprint_granulepos (outfile, oggz, serialno, op->granulepos);
}
fprintf (outfile, " packetno %" PRId64,
fprintf (outfile, ", packetno %" PRId64,
oddata->hide_packetno ? -1 : op->packetno);
if (op->b_o_s) {
......
......@@ -93,6 +93,7 @@ typedef struct _OI_TrackInfo OI_TrackInfo;
typedef void (*OI_TrackFunc) (OI_Info * info, OI_TrackInfo * oit, long serialno);
struct _OI_Info {
OGGZ * oggz;
OggzTable * tracks;
ogg_int64_t duration;
long length_total;
......@@ -217,16 +218,18 @@ ot_fishead_print(OI_TrackInfo *oit) {
}
static void
ot_fisbone_print(OI_TrackInfo *oit) {
ot_fisbone_print(OI_Info * info, OI_TrackInfo *oit) {
char *messages, *token;
if (oit->has_fisbone) {
printf("\n\tExtra information from Ogg Skeleton\n");
printf("\tserialno: %010d\n", oit->fbInfo.serial_no);
printf("\n\tExtra information from Ogg Skeleton track:\n");
/*printf("\tserialno: %010d\n", oit->fbInfo.serial_no);*/
printf("\tNumber of header packets: %d\n", oit->fbInfo.nr_header_packet);
printf("\tGranule rate: %.2f\n", (double)oit->fbInfo.granule_rate_n/oit->fbInfo.granule_rate_d);
printf("\tStart granule: %" PRId64 "\n", oit->fbInfo.start_granule);
printf("\tStart granule: ");
ot_fprint_granulepos(stdout, info->oggz, oit->fbInfo.serial_no, oit->fbInfo.start_granule);
printf ("\n");
printf("\tPreroll: %d\n", oit->fbInfo.preroll);
messages = token = _ogg_calloc(oit->fbInfo.current_header_size+1, sizeof(char));
strcpy(messages, oit->fbInfo.message_header_fields);
......@@ -282,7 +285,7 @@ oit_print (OI_Info * info, OI_TrackInfo * oit, long serialno)
ot_fishead_print(oit);
}
if (show_extra_skeleton_info && oit->has_fisbone) {
ot_fisbone_print(oit);
ot_fisbone_print(info, oit);
}
}
......@@ -572,6 +575,7 @@ main (int argc, char ** argv)
return (1);
}
info.oggz = oggz;
info.tracks = oggz_table_new ();
info.length_total = 0;
......@@ -581,8 +585,6 @@ main (int argc, char ** argv)
oi_pass2 (oggz, &info);
oggz_close (oggz);
/* Print summary information */
if (many_files)
printf ("Filename: %s\n", infilename);
......@@ -607,6 +609,8 @@ main (int argc, char ** argv)
oggzinfo_apply (oit_delete, &info);
oggz_table_delete (info.tracks);
oggz_close (oggz);
if (optind < argc) puts (SEP);
}
......
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