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))) 50 #define OFFSET(x) offsetof(OpenMPTContext, x) 51 #define A AV_OPT_FLAG_AUDIO_PARAM 52 #define D AV_OPT_FLAG_DECODING_PARAM 65 if (strstr(message,
"ERROR") !=
NULL) {
68 av_log(userdata, level,
"%s\n", message);
71 #define add_meta(s, name, meta) \ 73 const char *value = meta; \ 74 if (value && value[0]) \ 75 av_dict_set(&s->metadata, name, value, 0); \ 76 openmpt_free_string(value); \ 85 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0) 103 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0) 104 error = OPENMPT_ERROR_OK;
108 if (error == OPENMPT_ERROR_OUT_OF_MEMORY)
110 else if (error >= OPENMPT_ERROR_GENERAL)
124 if (openmpt->
subsong >= openmpt_module_get_num_subsongs(openmpt->
module)) {
125 openmpt_module_destroy(openmpt->
module);
134 ret = openmpt_module_select_subsong(openmpt->
module, openmpt->
subsong);
136 openmpt_module_destroy(openmpt->
module);
142 openmpt->
duration = openmpt_module_get_duration_seconds(openmpt->
module);
144 add_meta(s,
"artist", openmpt_module_get_metadata(openmpt->
module,
"artist"));
145 add_meta(s,
"title", openmpt_module_get_metadata(openmpt->
module,
"title"));
146 add_meta(s,
"encoder", openmpt_module_get_metadata(openmpt->
module,
"tracker"));
147 add_meta(s,
"comment", openmpt_module_get_metadata(openmpt->
module,
"message"));
148 add_meta(s,
"date", openmpt_module_get_metadata(openmpt->
module,
"date"));
152 openmpt_module_destroy(openmpt->
module);
167 #define AUDIO_PKT_SIZE 2048 181 n_samples, (
float *)pkt->
data);
184 ret = openmpt_module_read_interleaved_float_stereo(openmpt->
module, openmpt->
sample_rate,
185 n_samples, (
float *)pkt->
data);
188 ret = openmpt_module_read_interleaved_float_quad(openmpt->
module, openmpt->
sample_rate,
189 n_samples, (
float *)pkt->
data);
209 openmpt_module_destroy(openmpt->
module);
226 if (ext && strlen(ext + 1) > 0) {
228 if (openmpt_is_extension_supported(ext) == 1)
237 #if OPENMPT_API_VERSION_AT_LEAST(0,3,0) 240 probe_result = openmpt_probe_file_header_without_filesize(
241 OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT,
244 if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS) {
250 }
else if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA) {
254 if (p->
buf_size >= openmpt_probe_file_header_get_recommended_size()) {
268 }
else if (probe_result == OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE) {
285 .
name =
"libopenmpt",
293 .priv_class = &class_openmpt,
295 .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",
297 .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",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int probe_openmpt_extension(AVProbeData *p)
#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).
const char * av_default_item_name(void *ptr)
Return the context name.
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
#define OPENMPT_API_VERSION_AT_LEAST(major, minor, patch)
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[]
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define AV_TIME_BASE
Internal time base represented as integer.
static void error(const char *err)
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.
static int read_probe_openmpt(AVProbeData *p)
AVInputFormat ff_libopenmpt_demuxer
Describe the class of an AVClass context structure.
This structure contains the data a format has to probe a file.
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...
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
void * priv_data
Format private data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
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)