Skip to content

Commit c0223fc

Browse files
authored
Merge pull request #5 from philippe44/OggFlac
Ogg flac
2 parents e69b12f + 95a617a commit c0223fc

File tree

11 files changed

+841
-32
lines changed

11 files changed

+841
-32
lines changed

README

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ METHODS
4545
MP3: mp3, mp2
4646
MP4: mp4, m4a, m4b, m4p, m4v, m4r, k3g, skm, 3gp, 3g2, mov
4747
AAC (ADTS): aac
48-
Ogg: ogg, oga
49-
FLAC: flc, flac, fla
48+
Ogg: ogg, oga, ogf
49+
FLAC: flc, flac, fla, ogf
5050
ASF: wma, wmv, asf
5151
Musepack: mpc, mpp, mp+
5252
Monkey's Audio: ape, apl
@@ -95,15 +95,16 @@ METHODS
9595
WAV, AIFF, Musepack, Monkey's Audio, WavPack
9696
Not yet supported by find_frame.
9797

98-
find_frame_return_info( $mp4_path, $timestamp_in_ms )
99-
The header of an MP4 file contains various metadata that refers to the
98+
find_frame_return_info( $path, $timestamp_in_ms )
99+
The header of an MP4 or OggFlac file contains various metadata that refers to the
100100
structure of the audio data, making seeking more difficult to perform.
101101
This method will return the usual $info hash with 2 additional keys:
102102

103103
seek_offset - The seek offset in bytes
104-
seek_header - A rewritten MP4 header that can be prepended to the audio data
105-
found at seek_offset to construct a valid bitstream. Specifically,
106-
the following boxes are rewritten: stts, stsc, stsz, stco
104+
seek_header - A rewritten MP4/OggFlac header that can be prepended to the audio data
105+
found at seek_offset to construct a valid bitstream. Specifically, for MP4
106+
the following boxes are rewritten: stts, stsc, stsz, stco. For FLAC, the
107+
number of samples and md5 in STREAMINFO are zero'd
107108

108109
For example, to seek 30 seconds into a file and write out a new MP4 file
109110
seeked to this point:
@@ -332,13 +333,14 @@ OGG VORBIS
332333
TAGS
333334
Raw Vorbis comments are returned. All comment keys are capitalized.
334335

335-
FLAC
336+
FLAC or OggFLAC
336337
INFO
337338
The following metadata about a file is returned:
338339

339340
channels
340341
samplerate (in kHz)
341342
bitrate (in bps)
343+
bitrage_ogg (in bps, calculate from ogg frames)
342344
file_size
343345
audio_offset (byte offset to first audio frame)
344346
audio_size

Scan.xs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "mp4.c"
3030
#include "mpc.c"
3131
#include "ogg.c"
32+
#include "ogf.c"
3233
#include "opus.c"
3334
#include "wav.c"
3435
#include "flac.c"
@@ -64,6 +65,7 @@ struct _types audio_types[] = {
6465
{"aac", {"aac", "adts", 0}},
6566
{"mp3", {"mp3", "mp2", 0}},
6667
{"ogg", {"ogg", "oga", 0}},
68+
{"ogf", {"ogf", 0}},
6769
{"opus", {"opus", 0}},
6870
{"mpc", {"mpc", "mp+", "mpp", 0}},
6971
{"ape", {"ape", "apl", 0}},
@@ -81,6 +83,7 @@ static taghandler taghandlers[] = {
8183
{ "aac", get_aacinfo, 0, 0, 0 },
8284
{ "mp3", get_mp3tags, get_mp3fileinfo, mp3_find_frame, 0 },
8385
{ "ogg", get_ogg_metadata, 0, ogg_find_frame, 0 },
86+
{ "ogf", get_ogf_metadata, 0, ogf_find_frame, ogf_find_frame_return_info },
8487
{ "opus", get_opus_metadata, 0, opus_find_frame, 0 },
8588
{ "mpc", get_ape_metadata, get_mpcfileinfo, 0, 0 },
8689
{ "ape", get_ape_metadata, get_macfileinfo, 0, 0 },

include/flac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1515
*/
1616

17+
#pragma once
18+
1719
#define FLAC_BLOCK_SIZE 4096
1820
#define FLAC_FRAME_MAX_HEADER 22
1921

include/ogf.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation; either version 2 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program; if not, write to the Free Software
14+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15+
*/
16+
17+
int get_ogf_metadata(PerlIO *infile, char *file, HV *info, HV *tags);
18+
int ogf_find_frame_return_info(PerlIO *infile, char *file, int offset, HV *info);
19+
int ogf_find_frame(PerlIO *infile, char *file, int offset);
20+
21+
static int _ogf_parse(PerlIO *infile, char *file, HV *info, HV *tags, uint8_t seeking);
22+
static int _ogf_find_frame(PerlIO *infile, char *file, int offset, HV *info, HV *tags);

lib/Audio/Scan.pm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package Audio::Scan;
22

33
use strict;
44

5-
our $VERSION = '1.09';
5+
our $VERSION = '1.10';
66

77
require XSLoader;
88
XSLoader::load('Audio::Scan', $VERSION);
@@ -268,16 +268,17 @@ Not yet supported by find_frame.
268268
269269
=back
270270
271-
=head2 find_frame_return_info( $mp4_path, $timestamp_in_ms )
271+
=head2 find_frame_return_info( $path, $timestamp_in_ms )
272272
273-
The header of an MP4 file contains various metadata that refers to the structure of
273+
The header of an MP4/OggFlac file contains various metadata that refers to the structure of
274274
the audio data, making seeking more difficult to perform. This method will return
275275
the usual $info hash with 2 additional keys:
276276
277277
seek_offset - The seek offset in bytes
278-
seek_header - A rewritten MP4 header that can be prepended to the audio data
279-
found at seek_offset to construct a valid bitstream. Specifically,
280-
the following boxes are rewritten: stts, stsc, stsz, stco
278+
seek_header - A rewritten MP4/OggFlac header that can be prepended to the audio data
279+
found at seek_offset to construct a valid bitstream. Specifically, for MP4
280+
the following boxes are rewritten: stts, stsc, stsz, stco. For FLAC, the
281+
number of samples and md5 in STREAMINFO are zero'd
281282
282283
For example, to seek 30 seconds into a file and write out a new MP4 file seeked to
283284
this point:

0 commit comments

Comments
 (0)