1 #define PERL_NO_GET_CONTEXT
8 /* op_free is both Perl_op_free and a function in opusfile */
10 #include <opus/opusfile.h>
12 #include "const-c.inc"
14 typedef OggOpusFile* Audio__Opusfile;
15 typedef const OpusHead* Audio__Opusfile__Head;
16 typedef const OpusTags* Audio__Opusfile__Tags;
17 typedef const OpusPictureTag* Audio__Opusfile__PictureTag;
19 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile PREFIX = op_
33 croak("op_open_file returned error %d\n", err);
36 op_open_memory(const char *data, size_t length(data))
40 data, XSauto_length_of_data, &err
43 croak("op_open_memory returned error %d\n", err);
46 op_test(const char *data, size_t length(data))
51 ret = op_test (NULL, data, XSauto_length_of_data);
52 if(ret < 0 && ret != OP_ENOTFORMAT && ret != OP_EBADHEADER)
53 croak("op_test returned error %d\n", RETVAL);
74 op_serialno(of, li = -1)
78 # op_channel_count is not exported; it can be obtained via op_head
81 op_raw_total(of, li = -1)
86 croak("op_current_link returned error %ld\n", RETVAL);
89 op_pcm_total(of, li = -1)
94 croak("op_current_link returned error %ld\n", RETVAL);
101 Audio::Opusfile::Tags
111 croak("op_current_link returned error %ld\n", RETVAL);
114 op_bitrate(of, li = -1)
119 croak("op_bitrate returned error %ld\n", RETVAL);
122 op_bitrate_instant(of)
126 croak("op_bitrate_instant returned error %ld\n", RETVAL);
133 croak("op_raw_tell returned error %ld\n", RETVAL);
140 croak("op_pcm_tell returned error %ld\n", RETVAL);
143 op_raw_seek(of, offset)
148 croak("op_raw_seek returned error %d\n", RETVAL);
151 op_pcm_seek(of, offset)
156 croak("op_pcm_seek returned error %d\n", RETVAL);
159 op_set_gain_offset(of, gain_type, gain_offset_q8)
165 croak("op_set_gain_offset returned error %d\n", RETVAL);
168 op_set_dither_enabled(of, enabled)
174 op_read(of, bufsize = 1024 * 1024)
179 int li, ret, chans, i;
181 Newx(buf, bufsize, opus_int16);
182 ret = op_read(of, buf, bufsize, &li);
184 croak("op_read returned error %d\n", ret);
185 chans = op_channel_count(of, li);
186 EXTEND(SP, chans * ret + 1);
187 PUSHs(sv_2mortal(newSViv(li)));
188 for(i = 0 ; i < chans * ret ; i++)
189 PUSHs(sv_2mortal(newSViv(buf[i])));
192 op_read_float(of, bufsize = 1024 * 1024)
197 int li, ret, chans, i;
199 Newx(buf, bufsize, float);
200 ret = op_read_float(of, buf, bufsize, &li);
202 croak("op_read_float returned error %d\n", ret);
203 chans = op_channel_count(of, li);
204 EXTEND(SP, chans * ret + 1);
205 PUSHs(sv_2mortal(newSViv(li)));
206 for(i = 0 ; i < chans * ret ; i++)
207 PUSHs(sv_2mortal(newSVnv(buf[i])));
210 op_read_stereo(of, bufsize = 1024 * 1024)
217 Newx(buf, bufsize, opus_int16);
218 ret = op_read_stereo(of, buf, bufsize);
220 croak("op_read_stereo returned error %d\n", ret);
222 for(i = 0 ; i < 2 * ret ; i++)
223 PUSHs(sv_2mortal(newSViv(buf[i])));
226 op_read_float_stereo(of, bufsize = 1024 * 1024)
233 Newx(buf, bufsize, float);
234 ret = op_read_float_stereo(of, buf, bufsize);
236 croak("op_read_float_stereo returned error %d\n", ret);
238 for(i = 0 ; i < 2 * ret ; i++)
239 PUSHs(sv_2mortal(newSVnv(buf[i])));
243 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_
246 opus_tags_query_count(tags, tag)
247 Audio::Opusfile::Tags tags;
251 opus_tags_query(tags, tag, count = 0)
252 Audio::Opusfile::Tags tags;
256 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
258 Audio::Opusfile::PictureTag
259 opus_picture_tag_parse(tag)
265 Newx(pic, 1, OpusPictureTag);
266 if(err = opus_picture_tag_parse(pic, tag))
267 croak("opus_picture_tag_parse returned error %d\n", err);
274 Audio::Opusfile::PictureTag pic
280 Audio::Opusfile::PictureTag pic;
288 Audio::Opusfile::PictureTag pic;
290 RETVAL = pic->mime_type;
296 Audio::Opusfile::PictureTag pic;
298 RETVAL = pic->description;
304 Audio::Opusfile::PictureTag pic;
312 Audio::Opusfile::PictureTag pic;
314 RETVAL = pic->height;
320 Audio::Opusfile::PictureTag pic;
328 Audio::Opusfile::PictureTag pic;
330 RETVAL = pic->colors;
336 Audio::Opusfile::PictureTag pic;
338 RETVAL = pic->data_length;
344 Audio::Opusfile::PictureTag pic;
346 RETVAL = newSVpvn(pic->data, pic->data_length);
352 Audio::Opusfile::PictureTag pic;
354 RETVAL = pic->format;
358 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head
362 Audio::Opusfile::Head head;
364 RETVAL = head->version;
370 Audio::Opusfile::Head head;
372 RETVAL = head->channel_count;
378 Audio::Opusfile::Head head;
380 RETVAL = head->pre_skip;
385 input_sample_rate(head)
386 Audio::Opusfile::Head head;
388 RETVAL = head->input_sample_rate;
394 Audio::Opusfile::Head head;
396 RETVAL = head->output_gain;
402 Audio::Opusfile::Head head;
404 RETVAL = head->mapping_family;
410 Audio::Opusfile::Head head;
412 RETVAL = head->stream_count;
418 Audio::Opusfile::Head head;
420 RETVAL = head->coupled_count;
426 Audio::Opusfile::Head head;
429 if(k >= OPUS_CHANNEL_COUNT_MAX)
430 croak("k must be less than %d\n", (int)OPUS_CHANNEL_COUNT_MAX);
431 RETVAL = (int) head->mapping[k];