decoder/_ogg_common: simplify the large "if" expression

This commit is contained in:
Max Kellermann 2012-09-04 11:22:05 +02:00
parent 2050e2f886
commit 0d24250aa7
1 changed files with 8 additions and 6 deletions

View File

@ -33,12 +33,14 @@ ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream)
size_t r;
r = decoder_read(NULL, inStream, buf, sizeof(buf));
if (r >= 32 && memcmp(buf, "OggS", 4) == 0 && (
(memcmp(buf+29, "FLAC", 4) == 0
&& memcmp(buf+37, "fLaC", 4) == 0)
|| (memcmp(buf+28, "FLAC", 4) == 0)
|| (memcmp(buf+28, "fLaC", 4) == 0))) {
if (r < 32 || memcmp(buf, "OggS", 4) != 0)
return VORBIS;
if ((memcmp(buf + 29, "FLAC", 4) == 0 &&
memcmp(buf + 37, "fLaC", 4) == 0) ||
memcmp(buf + 28, "FLAC", 4) == 0 ||
memcmp(buf + 28, "fLaC", 4) == 0)
return FLAC;
}
return VORBIS;
}