Commit 6aa3617f authored by Philipp Schafft's avatar Philipp Schafft 🦁
Browse files

Update: Made merged Opus and FLAC code in print_summary()

Note: This does not yet merge the Vorbis, Theora, and Kate
      code to avoid early breaking of translations.
parent 0f709a57
Pipeline #2307 failed with stage
in 1 minute and 21 seconds
......@@ -299,21 +299,6 @@ static void flac_process(stream_processor *stream, ogg_page *page)
static void flac_end(stream_processor *stream)
{
misc_flac_info *self = stream->data;
long minutes, seconds, milliseconds;
double bitrate, time;
/* This should be lastgranulepos - startgranulepos, or something like that*/
time = (double)self->lastgranulepos / self->rate;
minutes = (long)time / 60;
seconds = (long)time - minutes*60;
milliseconds = (long)((time - minutes*60 - seconds)*1000);
bitrate = self->bytes*8 / time / 1000.0;
info(_("FLAC stream %d:\n"
"\tTotal data length: %" PRId64 " bytes\n"
"\tPlayback length: %ldm:%02ld.%03lds\n"
"\tAverage bitrate: %f kb/s\n"),
stream->num, self->bytes, minutes, seconds, milliseconds, bitrate);
if (!self->seen_streaminfo)
warn(_("WARNING: stream (%d) did not contain STREAMINFO\n"), stream->num);
......@@ -321,6 +306,9 @@ static void flac_end(stream_processor *stream)
if (!self->seen_data)
warn(_("WARNING: stream (%d) did not contain data packets\n"), stream->num);
/* This should be lastgranulepos - startgranulepos, or something like that*/
print_summary(stream, self->bytes, (double)self->lastgranulepos / self->rate);
free(stream->data);
}
......
......@@ -179,8 +179,6 @@ static void opus_process(stream_processor *stream, ogg_page *page)
static void opus_end(stream_processor *stream)
{
misc_opus_info *self = stream->data;
long minutes, seconds, milliseconds;
double bitrate, time;
if (!self->seen_opushead)
warn(_("WARNING: stream (%d) did not contain OpusHead header\n"), stream->num);
......@@ -191,17 +189,7 @@ static void opus_end(stream_processor *stream)
if (!self->seen_data)
warn(_("WARNING: stream (%d) did not contain data packets\n"), stream->num);
time = (double)(self->lastgranulepos - self->firstgranulepos - self->pre_skip) / 48000.;
minutes = (long)time / 60;
seconds = (long)time - minutes*60;
milliseconds = (long)((time - minutes*60 - seconds)*1000);
bitrate = self->bytes*8 / time / 1000.0;
info(_("Opus stream %d:\n"
"\tTotal data length: %" PRId64 " bytes\n"
"\tPlayback length: %ldm:%02ld.%03lds\n"
"\tAverage bitrate: %f kb/s\n"),
stream->num, self->bytes, minutes, seconds, milliseconds, bitrate);
print_summary(stream, self->bytes, (double)(self->lastgranulepos - self->firstgranulepos - self->pre_skip) / 48000.);
free(stream->data);
}
......
......@@ -101,6 +101,23 @@ void error(const char *format, ...)
va_end(ap);
}
void print_summary(stream_processor *stream, size_t bytes, double time)
{
long minutes, seconds, milliseconds;
double bitrate;
minutes = (long)time / 60;
seconds = (long)time - minutes*60;
milliseconds = (long)((time - minutes*60 - seconds)*1000);
bitrate = bytes*8 / time / 1000.0;
info(_("%s stream %d:\n"
"\tTotal data length: %" PRId64 " bytes\n"
"\tPlayback length: %ldm:%02ld.%03lds\n"
"\tAverage bitrate: %f kb/s\n"),
stream->type, stream->num, bytes, minutes, seconds, milliseconds, bitrate);
}
static void print_vendor(const unsigned char *str, size_t len)
{
char *buf = malloc(len + 1);
......
......@@ -47,6 +47,7 @@ void info(const char *format, ...);
void warn(const char *format, ...);
void error(const char *format, ...);
void print_summary(stream_processor *stream, size_t bytes, double time);
int handle_vorbis_comments(stream_processor *stream, const unsigned char *in, size_t length, size_t *end);
void check_xiph_comment(stream_processor *stream, int i, const char *comment, int comment_length);
......
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