22 #include <libopenmpt/libopenmpt.h>
23 #include <libopenmpt/libopenmpt_stream_callbacks_file.h>
42 #define OFFSET(x) offsetof(OpenMPTContext, x)
43 #define A AV_OPT_FLAG_AUDIO_PARAM
44 #define D AV_OPT_FLAG_DECODING_PARAM
57 if (strstr(message,
"ERROR") !=
NULL) {
60 av_log(userdata, level,
"%s\n", message);
63 #define add_meta(s, name, meta) \
65 const char *value = meta; \
66 if (value && value[0]) \
67 av_dict_set(&s->metadata, name, value, 0); \
68 openmpt_free_string(value); \
97 openmpt->
duration = openmpt_module_get_duration_seconds(openmpt->
module);
99 add_meta(s,
"artist", openmpt_module_get_metadata(openmpt->
module,
"artist"));
100 add_meta(s,
"title", openmpt_module_get_metadata(openmpt->
module,
"title"));
101 add_meta(s,
"encoder", openmpt_module_get_metadata(openmpt->
module,
"tracker"));
102 add_meta(s,
"comment", openmpt_module_get_metadata(openmpt->
module,
"message"));
103 add_meta(s,
"date", openmpt_module_get_metadata(openmpt->
module,
"date"));
105 if (openmpt->
subsong >= openmpt_module_get_num_subsongs(openmpt->
module)) {
106 openmpt_module_destroy(openmpt->
module);
115 ret = openmpt_module_select_subsong(openmpt->
module, openmpt->
subsong);
117 openmpt_module_destroy(openmpt->
module);
125 openmpt_module_destroy(openmpt->
module);
140 #define AUDIO_PKT_SIZE 2048
154 n_samples, (
float *)pkt->
data);
157 ret = openmpt_module_read_interleaved_float_stereo(openmpt->
module, openmpt->
sample_rate,
158 n_samples, (
float *)pkt->
data);
161 ret = openmpt_module_read_interleaved_float_quad(openmpt->
module, openmpt->
sample_rate,
162 n_samples, (
float *)pkt->
data);
182 openmpt_module_destroy(openmpt->
module);
202 .
name =
"libopenmpt",
209 .priv_class = &class_openmpt,
210 .extensions =
"669,amf,ams,dbm,digi,dmf,dsm,far,gdm,imf,it,j2b,m15,mdl,med,mmcmp,mms,mo3,mod,mptm,mt2,mtm,nst,okt,plm,ppm,psm,pt36,ptm,s3m,sfx,sfx2,stk,stm,ult,umx,wow,xm,xpk",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
#define LIBAVUTIL_VERSION_INT
static int read_packet_openmpt(AVFormatContext *s, AVPacket *pkt)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static int read_header_openmpt(AVFormatContext *s)
#define AV_CH_LAYOUT_STEREO
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
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 int read_close_openmpt(AVFormatContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static const AVClass class_openmpt
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVMediaType codec_type
General type of the encoded data.
static const AVOption options[]
#define AV_TIME_BASE
Internal time base represented as integer.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_INFO
Standard information.
AVIOContext * pb
I/O context.
AVInputFormat ff_libopenmpt_demuxer
Describe the class of an AVClass context structure.
int64_t duration
Decoding: duration of the stream, in stream time base.
#define add_meta(s, name, meta)
int sample_rate
Audio only.
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...
void * priv_data
Format private data.
AVCodecParameters * codecpar
static int read_seek_openmpt(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
This structure stores compressed data.
static void openmpt_logfunc(const char *message, void *userdata)