diff options
author | Frederik M J Vestre <freqmod@gmail.com> | 2012-07-26 14:38:32 +0200 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2012-09-20 20:47:44 +0200 |
commit | 1b8e3801b2444f6e466e1b7c09cfc51605e80fb3 (patch) | |
tree | bd1d6fe08452d388d0d160ec02e03963f3f9525d /lib/rbcodec/metadata | |
parent | 72ebcbf73b4db911d517a66c820fdceccb8ec798 (diff) | |
download | rockbox-1b8e3801b2444f6e466e1b7c09cfc51605e80fb3.tar.gz rockbox-1b8e3801b2444f6e466e1b7c09cfc51605e80fb3.zip |
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>
Diffstat (limited to 'lib/rbcodec/metadata')
-rw-r--r-- | lib/rbcodec/metadata/metadata.c | 3 | ||||
-rw-r--r-- | lib/rbcodec/metadata/metadata.h | 1 | ||||
-rw-r--r-- | lib/rbcodec/metadata/ogg.c | 14 | ||||
-rw-r--r-- | lib/rbcodec/metadata/vorbis.c | 18 |
4 files changed, 35 insertions, 1 deletions
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c index 668ece97cf..5caf933b55 100644 --- a/lib/rbcodec/metadata/metadata.c +++ b/lib/rbcodec/metadata/metadata.c | |||
@@ -233,6 +233,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
233 | /* KSS (MSX computer KSS Music File) */ | 233 | /* KSS (MSX computer KSS Music File) */ |
234 | [AFMT_KSS] = | 234 | [AFMT_KSS] = |
235 | AFMT_ENTRY("KSS", "kss", NULL, get_kss_metadata, "kss\0"), | 235 | AFMT_ENTRY("KSS", "kss", NULL, get_kss_metadata, "kss\0"), |
236 | /* Opus */ | ||
237 | [AFMT_OPUS] = | ||
238 | AFMT_ENTRY("Opus", "opus", NULL, get_ogg_metadata, "opus\0"), | ||
236 | #endif | 239 | #endif |
237 | }; | 240 | }; |
238 | 241 | ||
diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h index 4b4a8337fb..18cfce7523 100644 --- a/lib/rbcodec/metadata/metadata.h +++ b/lib/rbcodec/metadata/metadata.h | |||
@@ -89,6 +89,7 @@ enum | |||
89 | AFMT_SGC, /* SGC (Sega Master System, Game Gear, Coleco Vision Sound Format) */ | 89 | AFMT_SGC, /* SGC (Sega Master System, Game Gear, Coleco Vision Sound Format) */ |
90 | AFMT_VGM, /* VGM (Video Game Music Format) */ | 90 | AFMT_VGM, /* VGM (Video Game Music Format) */ |
91 | AFMT_KSS, /* KSS (MSX computer KSS Music File) */ | 91 | AFMT_KSS, /* KSS (MSX computer KSS Music File) */ |
92 | AFMT_OPUS, /* Opus (see http://www.opus-codec.org ) */ | ||
92 | #endif | 93 | #endif |
93 | 94 | ||
94 | /* add new formats at any index above this line to have a sensible order - | 95 | /* add new formats at any index above this line to have a sensible order - |
diff --git a/lib/rbcodec/metadata/ogg.c b/lib/rbcodec/metadata/ogg.c index f3231c6f8a..5d302442ed 100644 --- a/lib/rbcodec/metadata/ogg.c +++ b/lib/rbcodec/metadata/ogg.c | |||
@@ -102,6 +102,20 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3) | |||
102 | return false; | 102 | return false; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | else if (memcmp(&buf[28], "OpusHead", 8) == 0) | ||
106 | { | ||
107 | id3->codectype = AFMT_OPUS; | ||
108 | id3->frequency = 48000; | ||
109 | id3->vbr = true; | ||
110 | |||
111 | // FIXME handle an actual channel mapping table | ||
112 | /* Comments are in second Ogg page (byte 108 onwards for Speex) */ | ||
113 | if (lseek(fd, 47, SEEK_SET) < 0) | ||
114 | { | ||
115 | DEBUGF("Couldnotseektoogg"); | ||
116 | return false; | ||
117 | } | ||
118 | } | ||
105 | else | 119 | else |
106 | { | 120 | { |
107 | /* Unsupported format, try to print the marker, catches Ogg/FLAC at least */ | 121 | /* Unsupported format, try to print the marker, catches Ogg/FLAC at least */ |
diff --git a/lib/rbcodec/metadata/vorbis.c b/lib/rbcodec/metadata/vorbis.c index d020808c56..66aa85022f 100644 --- a/lib/rbcodec/metadata/vorbis.c +++ b/lib/rbcodec/metadata/vorbis.c | |||
@@ -250,7 +250,7 @@ static bool file_init(struct file* file, int fd, int type, int remaining) | |||
250 | memset(file, 0, sizeof(*file)); | 250 | memset(file, 0, sizeof(*file)); |
251 | file->fd = fd; | 251 | file->fd = fd; |
252 | 252 | ||
253 | if (type == AFMT_OGG_VORBIS || type == AFMT_SPEEX) | 253 | if (type == AFMT_OGG_VORBIS || type == AFMT_SPEEX || type == AFMT_OPUS) |
254 | { | 254 | { |
255 | if (!file_read_page_header(file)) | 255 | if (!file_read_page_header(file)) |
256 | { | 256 | { |
@@ -276,6 +276,22 @@ static bool file_init(struct file* file, int fd, int type, int remaining) | |||
276 | return false; | 276 | return false; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else if (type == AFMT_OPUS) | ||
280 | { | ||
281 | char buffer[8]; | ||
282 | |||
283 | /* Read comment header */ | ||
284 | if (file_read(file, buffer, sizeof(buffer)) < (ssize_t) sizeof(buffer)) | ||
285 | { | ||
286 | return false; | ||
287 | } | ||
288 | |||
289 | /* Should be equal to "OpusTags" */ | ||
290 | if (memcmp(buffer, "OpusTags", 8) != 0) | ||
291 | { | ||
292 | return false; | ||
293 | } | ||
294 | } | ||
279 | else if (type == AFMT_FLAC) | 295 | else if (type == AFMT_FLAC) |
280 | { | 296 | { |
281 | file->packet_remaining = remaining; | 297 | file->packet_remaining = remaining; |