Skip to content

Commit

Permalink
Added Opus codec support (Jeff Muizelaar)
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrundman committed Jul 10, 2018
1 parent a18500a commit 01ecd45
Show file tree
Hide file tree
Showing 14 changed files with 573 additions and 2 deletions.
12 changes: 11 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include/mp3.h
include/mp4.h
include/mpc.h
include/ogg.h
include/opus.h
include/pinttypes.h
include/ppport.h
include/pstdint.h
Expand Down Expand Up @@ -47,6 +48,7 @@ src/mp3.c
src/mp4.c
src/mpc.c
src/ogg.c
src/opus.c
src/wav.c
src/wavpack.c
t/01use.t
Expand Down Expand Up @@ -164,8 +166,8 @@ t/mp3/v2.3-no-audio-frames.mp3
t/mp3/v2.3-null-bytes.mp3
t/mp3/v2.3-rgad.mp3
t/mp3/v2.3-sylt.mp3
t/mp3/v2.3-unsync.mp3
t/mp3/v2.3-unsync-apic-bad-offset.mp3
t/mp3/v2.3-unsync.mp3
t/mp3/v2.3-utf16any.mp3
t/mp3/v2.3-utf16be.mp3
t/mp3/v2.3-utf16le.mp3
Expand Down Expand Up @@ -235,6 +237,14 @@ t/ogg/old1.ogg
t/ogg/old2.ogg
t/ogg/tachos_melody.ogg
t/ogg/test.ogg
t/opus.t
t/opus/broken.phobosstream.opus
t/opus/broken.testvector01.bit.opus
t/opus/failure-end_gp_before_last_packet1.opus
t/opus/test-1-mono.opus
t/opus/test-2-stereo.opus
t/opus/test-8-7.1.opus
t/opus/tron.6ch.tinypkts.opus
t/util.t
t/wav.t
t/wav/8kmp38.wav
Expand Down
3 changes: 3 additions & 0 deletions Scan.xs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "mp4.c"
#include "mpc.c"
#include "ogg.c"
#include "opus.c"
#include "wav.c"
#include "flac.c"
#include "wavpack.c"
Expand Down Expand Up @@ -63,6 +64,7 @@ struct _types audio_types[] = {
{"aac", {"aac", "adts", 0}},
{"mp3", {"mp3", "mp2", 0}},
{"ogg", {"ogg", "oga", 0}},
{"opus", {"opus", 0}},
{"mpc", {"mpc", "mp+", "mpp", 0}},
{"ape", {"ape", "apl", 0}},
{"flc", {"flc", "flac", "fla", 0}},
Expand All @@ -79,6 +81,7 @@ static taghandler taghandlers[] = {
{ "aac", get_aacinfo, 0, 0, 0 },
{ "mp3", get_mp3tags, get_mp3fileinfo, mp3_find_frame, 0 },
{ "ogg", get_ogg_metadata, 0, ogg_find_frame, 0 },
{ "opus", get_opus_metadata, 0, opus_find_frame, 0 },
{ "mpc", get_ape_metadata, get_mpcfileinfo, 0, 0 },
{ "ape", get_ape_metadata, get_macfileinfo, 0, 0 },
{ "flc", get_flac_metadata, 0, flac_find_frame, 0 },
Expand Down
3 changes: 3 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ typedef struct _GUID {

#define CONVERT_INT32LE(b) \
(i = (b[3] << 24) | (b[2] << 16) | b[1] << 8 | b[0], i)

#define CONVERT_INT16LE(b) \
(i = (b[1] << 8) | b[0], i)

int _check_buf(PerlIO *infile, Buffer *buf, int size, int min_size);
void _split_vorbis_comment(char* comment, HV* tags);
Expand Down
23 changes: 23 additions & 0 deletions include/opus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#define OGG_BLOCK_SIZE 4500

int get_opus_metadata(PerlIO *infile, char *file, HV *info, HV *tags);
int _opus_parse(PerlIO *infile, char *file, HV *info, HV *tags, uint8_t seeking);
static int opus_find_frame(PerlIO *infile, char *file, int offset);
void _parse_vorbis_comments(PerlIO *infile, Buffer *vorbis_buf, HV *tags, int has_framing);
int _opus_binary_search_sample(PerlIO *infile, char *file, HV *info, uint64_t target_sample);
Loading

0 comments on commit 01ecd45

Please sign in to comment.