Commit a3258faf authored by Michael Smith's avatar Michael Smith

Some improvements to reduce the number of spurious errors shown in some

cases where there are some minor errors in the stream.

svn path=/trunk/vorbis-tools/; revision=4606
parent a5d8b7bc
...@@ -41,18 +41,16 @@ struct vorbis_release { ...@@ -41,18 +41,16 @@ struct vorbis_release {
/* TODO: /* TODO:
* *
* - detect decreasing granulepos
* - detect violations of muxing constraints * - detect violations of muxing constraints
* - better EOS detection (when EOS not explicitly set) * - detect granulepos 'gaps' (possibly vorbis-specific). (seperate from
* - detect granulepos 'gaps' (possibly vorbis-specific). * serial-number gaps)
* - check for serial number == (unsigned)-1 (will break some tools?)
* - more options (e.g. less or more verbose)
*/ */
typedef struct _stream_processor { typedef struct _stream_processor {
void (*process_page)(struct _stream_processor *, ogg_page *); void (*process_page)(struct _stream_processor *, ogg_page *);
void (*process_end)(struct _stream_processor *); void (*process_end)(struct _stream_processor *);
int isillegal; int isillegal;
int constraint_violated;
int shownillegal; int shownillegal;
int isnew; int isnew;
long seqno; long seqno;
...@@ -94,6 +92,9 @@ static int verbose = 1; ...@@ -94,6 +92,9 @@ static int verbose = 1;
static int flawed; static int flawed;
#define CONSTRAINT_PAGE_AFTER_EOS 1
#define CONSTRAINT_MUXING_VIOLATED 2
static stream_set *create_stream_set(void) { static stream_set *create_stream_set(void) {
stream_set *set = calloc(1, sizeof(stream_set)); stream_set *set = calloc(1, sizeof(stream_set));
...@@ -488,6 +489,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page) ...@@ -488,6 +489,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page)
ogg_uint32_t serial = ogg_page_serialno(page); ogg_uint32_t serial = ogg_page_serialno(page);
int i, found = 0; int i, found = 0;
int invalid = 0; int invalid = 0;
int constraint = 0;
stream_processor *stream; stream_processor *stream;
for(i=0; i < set->used; i++) { for(i=0; i < set->used; i++) {
...@@ -500,6 +502,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page) ...@@ -500,6 +502,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page)
/* if we have detected EOS, then this can't occur here. */ /* if we have detected EOS, then this can't occur here. */
if(stream->end) { if(stream->end) {
stream->isillegal = 1; stream->isillegal = 1;
stream->constraint_violated = CONSTRAINT_PAGE_AFTER_EOS;
return stream; return stream;
} }
...@@ -516,8 +519,10 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page) ...@@ -516,8 +519,10 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page)
* XXX: might this sometimes catch ok streams if EOS flag is missing, * XXX: might this sometimes catch ok streams if EOS flag is missing,
* but the stream is otherwise ok? * but the stream is otherwise ok?
*/ */
if(streams_open(set) && !set->in_headers) if(streams_open(set) && !set->in_headers) {
constraint = CONSTRAINT_MUXING_VIOLATED;
invalid = 1; invalid = 1;
}
set->in_headers = 1; set->in_headers = 1;
...@@ -534,6 +539,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page) ...@@ -534,6 +539,7 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page)
stream->isnew = 1; stream->isnew = 1;
stream->isillegal = invalid; stream->isillegal = invalid;
stream->constraint_violated = constraint;
{ {
int res; int res;
...@@ -569,6 +575,11 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page) ...@@ -569,6 +575,11 @@ static stream_processor *find_stream_processor(stream_set *set, ogg_page *page)
stream->end = ogg_page_eos(page); stream->end = ogg_page_eos(page);
stream->serial = serial; stream->serial = serial;
if(stream->serial == 0 || stream->serial == -1) {
info(_("Note: Stream %d has serial number %d, which is legal but may "
"cause problems with some tools."), stream->num, stream->serial);
}
return stream; return stream;
} }
...@@ -628,10 +639,28 @@ static void process_file(char *filename) { ...@@ -628,10 +639,28 @@ static void process_file(char *filename) {
} }
if(p->isillegal && !p->shownillegal) { if(p->isillegal && !p->shownillegal) {
char *constraint;
switch(p->constraint_violated) {
case CONSTRAINT_PAGE_AFTER_EOS:
constraint = _("Page found for stream after EOS flag");
break;
case CONSTRAINT_MUXING_VIOLATED:
constraint = _("Ogg muxing constraints violated, new "
"stream before EOS of all previous streams");
break;
default:
constraint = _("Error unknown.");
}
warn(_("Warning: illegally placed page(s) for logical stream %d\n" warn(_("Warning: illegally placed page(s) for logical stream %d\n"
"This indicates a corrupt ogg file.\n"), p->num); "This indicates a corrupt ogg file: %s.\n"),
p->num, constraint);
p->shownillegal = 1; p->shownillegal = 1;
continue; /* If it's a new stream, we want to continue processing this page
* anyway to suppress additional spurious errors
*/
if(!p->isnew)
continue;
} }
if(p->isnew) { if(p->isnew) {
...@@ -664,6 +693,7 @@ static void process_file(char *filename) { ...@@ -664,6 +693,7 @@ static void process_file(char *filename) {
p->process_end(p); p->process_end(p);
info(_("Logical stream %d ended\n"), p->num); info(_("Logical stream %d ended\n"), p->num);
p->isillegal = 1; p->isillegal = 1;
p->constraint_violated = CONSTRAINT_PAGE_AFTER_EOS;
} }
} }
} }
......
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