mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-21 19:12:39 -05:00
Initial opus codec support
Synchronised with opus repo on github (https://github.com/freqmod/rockbox-opus) Status: * Seeking ported from speex, but fails on some cases (e.g. seek to granule 0) * ReplayGain parsing needs to be reworked, we do vorbis-style replaygain now. http://wiki.xiph.org/OggOpus#Comment_Header explicitly forbids these in favour of R128_TRACK_GAIN tag. * No optimisation yet, source files still nearly identical to opus upstream * Multi-stream opus files may not be parsed correctly Change-Id: Ia66f1027dc1d288083e3c57b2816700078376f9a Reviewed-on: http://gerrit.rockbox.org/300 Reviewed-by: Bertrik Sikken <bertrik@sikken.nl> Tested-by: Bertrik Sikken <bertrik@sikken.nl>
This commit is contained in:
parent
72ebcbf73b
commit
1b8e3801b2
127 changed files with 28373 additions and 2 deletions
|
|
@ -233,6 +233,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
|
|||
/* KSS (MSX computer KSS Music File) */
|
||||
[AFMT_KSS] =
|
||||
AFMT_ENTRY("KSS", "kss", NULL, get_kss_metadata, "kss\0"),
|
||||
/* Opus */
|
||||
[AFMT_OPUS] =
|
||||
AFMT_ENTRY("Opus", "opus", NULL, get_ogg_metadata, "opus\0"),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ enum
|
|||
AFMT_SGC, /* SGC (Sega Master System, Game Gear, Coleco Vision Sound Format) */
|
||||
AFMT_VGM, /* VGM (Video Game Music Format) */
|
||||
AFMT_KSS, /* KSS (MSX computer KSS Music File) */
|
||||
AFMT_OPUS, /* Opus (see http://www.opus-codec.org ) */
|
||||
#endif
|
||||
|
||||
/* add new formats at any index above this line to have a sensible order -
|
||||
|
|
|
|||
|
|
@ -102,6 +102,20 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if (memcmp(&buf[28], "OpusHead", 8) == 0)
|
||||
{
|
||||
id3->codectype = AFMT_OPUS;
|
||||
id3->frequency = 48000;
|
||||
id3->vbr = true;
|
||||
|
||||
// FIXME handle an actual channel mapping table
|
||||
/* Comments are in second Ogg page (byte 108 onwards for Speex) */
|
||||
if (lseek(fd, 47, SEEK_SET) < 0)
|
||||
{
|
||||
DEBUGF("Couldnotseektoogg");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unsupported format, try to print the marker, catches Ogg/FLAC at least */
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ static bool file_init(struct file* file, int fd, int type, int remaining)
|
|||
memset(file, 0, sizeof(*file));
|
||||
file->fd = fd;
|
||||
|
||||
if (type == AFMT_OGG_VORBIS || type == AFMT_SPEEX)
|
||||
if (type == AFMT_OGG_VORBIS || type == AFMT_SPEEX || type == AFMT_OPUS)
|
||||
{
|
||||
if (!file_read_page_header(file))
|
||||
{
|
||||
|
|
@ -276,6 +276,22 @@ static bool file_init(struct file* file, int fd, int type, int remaining)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if (type == AFMT_OPUS)
|
||||
{
|
||||
char buffer[8];
|
||||
|
||||
/* Read comment header */
|
||||
if (file_read(file, buffer, sizeof(buffer)) < (ssize_t) sizeof(buffer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Should be equal to "OpusTags" */
|
||||
if (memcmp(buffer, "OpusTags", 8) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (type == AFMT_FLAC)
|
||||
{
|
||||
file->packet_remaining = remaining;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue