picodrive/platform/common/mp3.c
notaz cff531af94 clarify PicoDrive's license
- PicoDrive was originally released by fDave with simple
  "free for non-commercial use / For commercial use, separate licencing
  terms must be obtained" license and I kept it in my releases.
- in 2011, fDave re-released his code (same that I used as base
  many years ago) dual licensed with GPLv2 and MAME licenses:
    https://code.google.com/p/cyclone68000/

Based on the above I now proclaim that the whole source code is licensed
under the MAME license as more elaborate form of "for non-commercial use".
If that raises any doubt, I announce that all my modifications (which
is the vast majority of code by now) is licensed under the MAME license,
as it reads in COPYING file in this commit.

This does not affect ym2612.c/sn76496.c that were MAME licensed already
from the beginning.
2013-06-26 03:07:07 +03:00

36 lines
747 B
C

/*
* PicoDrive
* (C) notaz, 2010
*
* This work is licensed under the terms of MAME license.
* See COPYING file in the top-level directory.
*/
#include "mp3.h"
int mp3_find_sync_word(const unsigned char *buf, int size)
{
const unsigned char *p, *pe;
/* find byte-aligned syncword - need 12 (MPEG 1,2) or 11 (MPEG 2.5) matching bits */
for (p = buf, pe = buf + size - 3; p <= pe; p++)
{
int pn;
if (p[0] != 0xff)
continue;
pn = p[1];
if ((pn & 0xf8) != 0xf8 || // currently must be MPEG1
(pn & 6) == 0) { // invalid layer
p++; continue;
}
pn = p[2];
if ((pn & 0xf0) < 0x20 || (pn & 0xf0) == 0xf0 || // bitrates
(pn & 0x0c) != 0) { // not 44kHz
continue;
}
return p - buf;
}
return -1;
}