Go to the documentation of this file.
22 #include <libopenmpt/libopenmpt.h>
23 #include <libopenmpt/libopenmpt_stream_callbacks_file.h>
24 #include <libopenmpt/libopenmpt_version.h>
26 #if !defined(OPENMPT_API_VERSION_MAKE)
27 #define OPENMPT_API_VERSION_MAKE(major, minor, patch) (((major)<<24)|((minor)<<16)|((patch)<<0))
29 #if !defined(OPENMPT_API_VERSION_AT_LEAST)
30 #define OPENMPT_API_VERSION_AT_LEAST(major, minor, patch) (OPENMPT_API_VERSION >= OPENMPT_API_VERSION_MAKE((major), (minor), (patch)))
51 #define OFFSET(x) offsetof(OpenMPTContext, x)
52 #define A AV_OPT_FLAG_AUDIO_PARAM
53 #define D AV_OPT_FLAG_DECODING_PARAM
57 {
"subsong",
"set subsong",
OFFSET(subsong),
AV_OPT_TYPE_INT, { .i64 = -2 }, -2, INT_MAX,
A |
D, .unit =
"subsong"},
72 #define add_meta(s, name, meta) \
74 const char *value = meta; \
75 if (value && value[0]) \
76 av_dict_set(&s->metadata, name, value, 0); \
77 openmpt_free_string(value); \
86 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0)
104 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0)
105 error = OPENMPT_ERROR_OK;
109 if (
error == OPENMPT_ERROR_OUT_OF_MEMORY)
111 else if (
error >= OPENMPT_ERROR_GENERAL)
123 if (openmpt->
subsong >= openmpt_module_get_num_subsongs(openmpt->
module)) {
139 openmpt->
duration = openmpt_module_get_duration_seconds(openmpt->
module);
141 add_meta(
s,
"artist", openmpt_module_get_metadata(openmpt->
module,
"artist"));
142 add_meta(
s,
"title", openmpt_module_get_metadata(openmpt->
module,
"title"));
143 add_meta(
s,
"encoder", openmpt_module_get_metadata(openmpt->
module,
"tracker"));
144 add_meta(
s,
"comment", openmpt_module_get_metadata(openmpt->
module,
"message"));
145 add_meta(
s,
"date", openmpt_module_get_metadata(openmpt->
module,
"date"));
163 #define AUDIO_PKT_SIZE 2048
177 n_samples, (
float *)
pkt->
data);
181 n_samples, (
float *)
pkt->
data);
185 n_samples, (
float *)
pkt->
data);
206 openmpt_module_destroy(openmpt->
module);
224 if (ext && strlen(ext + 1) > 0) {
226 if (openmpt_is_extension_supported(ext) == 1)
235 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0)
238 probe_result = openmpt_probe_file_header_without_filesize(
239 OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT,
242 if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS) {
248 }
else if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA) {
252 if (p->
buf_size >= openmpt_probe_file_header_get_recommended_size()) {
266 }
else if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE) {
283 .
p.
name =
"libopenmpt",
286 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0)
287 .p.extensions =
"669,amf,ams,dbm,digi,dmf,dsm,dtm,far,gdm,ice,imf,it,j2b,m15,mdl,med,mmcmp,mms,mo3,mod,mptm,mt2,mtm,nst,okt,plm,ppm,psm,pt36,ptm,s3m,sfx,sfx2,st26,stk,stm,stp,ult,umx,wow,xm,xpk",
289 .p.extensions =
"669,amf,ams,dbm,digi,dmf,dsm,far,gdm,ice,imf,it,j2b,m15,mdl,med,mmcmp,mms,mo3,mod,mptm,mt2,mtm,nst,okt,plm,ppm,psm,pt36,ptm,s3m,sfx,sfx2,st26,stk,stm,ult,umx,wow,xm,xpk",
static void error(const char *err)
static void openmpt_logfunc(const char *message, void *userdata)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static int read_probe_openmpt(const AVProbeData *p)
int buf_size
Size of buf except extra allocated bytes.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int nb_channels
Number of channels in this layout.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_cold int read_close(AVFormatContext *ctx)
int64_t duration
Decoding: duration of the stream, in stream time base.
static int read_packet_openmpt(AVFormatContext *s, AVPacket *pkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
AVChannelLayout ch_layout
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
This structure contains the data a format has to probe a file.
static int read_header_openmpt(AVFormatContext *s)
static int probe_openmpt_extension(const AVProbeData *p)
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
const FFInputFormat ff_libopenmpt_demuxer
#define AV_LOG_INFO
Standard information.
static int read_close_openmpt(AVFormatContext *s)
#define AV_TIME_BASE
Internal time base represented as integer.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static const AVClass class_openmpt
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
static int read_probe(const AVProbeData *p)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static int read_seek_openmpt(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const AVOption options[]
#define add_meta(s, name, meta)