FFmpeg
Loading...
Searching...
No Matches
libmodplug.c File Reference

ModPlug demuxer. More...

#include <libmodplug/modplug.h>
#include "libavutil/avstring.h"
#include "libavutil/eval.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  ModPlugContext
 

Macros

#define MODPLUG_STATIC
 
#define FF_MODPLUG_MAX_FILE_SIZE   (100 * 1<<20)
 
#define FF_MODPLUG_DEF_FILE_SIZE   ( 5 * 1<<20)
 
#define OFFSET(x)
 
#define D   AV_OPT_FLAG_DECODING_PARAM
 
#define SET_OPT_IF_REQUESTED(libopt, opt, flag)
 
#define ADD_META_MULTIPLE_ENTRIES(entry_name, fname)
 
#define AUDIO_PKT_SIZE   512
 
#define PRINT_INFO(line, name, idvalue)
 

Enumerations

enum  var_name {
  VAR_X , VAR_Y , VAR_W , VAR_H ,
  VAR_TIME , VAR_SPEED , VAR_TEMPO , VAR_ORDER ,
  VAR_PATTERN , VAR_ROW , VAR_VARS_NB
}
 

Functions

static int modplug_read_close (AVFormatContext *s)
 
static int modplug_load_metadata (AVFormatContext *s)
 
static int modplug_read_header (AVFormatContext *s)
 
static void write_text (uint8_t *dst, const char *s, int linesize, int x, int y)
 
static int modplug_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int modplug_read_seek (AVFormatContext *s, int stream_idx, int64_t ts, int flags)
 
static int modplug_probe (const AVProbeData *p)
 

Variables

static const char *const var_names []
 
static const AVOption options []
 
static const char modplug_extensions [] = "669,abc,amf,ams,dbm,dmf,dsm,far,it,mdl,med,mid,mod,mt2,mtm,okt,psm,ptm,s3m,stm,ult,umx,xm,itgz,itr,itz,mdgz,mdr,mdz,s3gz,s3r,s3z,xmgz,xmr,xmz"
 
static const AVClass modplug_class
 
const FFInputFormat ff_libmodplug_demuxer
 

Detailed Description

ModPlug demuxer.

Todo
better probing than extensions matching

Definition in file libmodplug.c.

Macro Definition Documentation

◆ MODPLUG_STATIC

#define MODPLUG_STATIC

Definition at line 25 of file libmodplug.c.

◆ FF_MODPLUG_MAX_FILE_SIZE

#define FF_MODPLUG_MAX_FILE_SIZE   (100 * 1<<20)

Definition at line 81 of file libmodplug.c.

◆ FF_MODPLUG_DEF_FILE_SIZE

#define FF_MODPLUG_DEF_FILE_SIZE   ( 5 * 1<<20)

Definition at line 82 of file libmodplug.c.

Referenced by modplug_read_header().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 84 of file libmodplug.c.

◆ D

Definition at line 85 of file libmodplug.c.

◆ SET_OPT_IF_REQUESTED

#define SET_OPT_IF_REQUESTED ( libopt,
opt,
flag )
Value:
do { \
if (modplug->opt) { \
settings.libopt = modplug->opt; \
settings.mFlags |= flag; \
} \
} while (0)
#define flag(name)
Definition cbs_h264.c:60

Definition at line 112 of file libmodplug.c.

Referenced by modplug_read_header().

◆ ADD_META_MULTIPLE_ENTRIES

#define ADD_META_MULTIPLE_ENTRIES ( entry_name,
fname )
Value:
do { \
if (n_## entry_name ##s) { \
unsigned i, n = 0; \
\
for (i = 0; i < n_## entry_name ##s; i++) { \
char item_name[64] = {0}; \
fname(f, i, item_name); \
if (!*item_name) \
continue; \
if (n) \
av_dict_set(&s->metadata, #entry_name, "\n", AV_DICT_APPEND); \
av_dict_set(&s->metadata, #entry_name, item_name, AV_DICT_APPEND); \
n++; \
} \
\
extra = av_asprintf(", %u/%u " #entry_name "%s", \
n, n_## entry_name ##s, n > 1 ? "s" : ""); \
if (!extra) \
return AVERROR(ENOMEM); \
av_dict_set(&s->metadata, "extra info", extra, AV_DICT_APPEND); \
av_free(extra); \
} \
} while (0)
char * av_asprintf(const char *fmt,...)
Definition avstring.c:115
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define AV_DICT_APPEND
If the entry already exists, append to it.
Definition dict.h:82
#define AVERROR(e)
Definition error.h:45
item_name
Definition libkvazaar.c:311

Definition at line 119 of file libmodplug.c.

Referenced by modplug_load_metadata().

◆ AUDIO_PKT_SIZE

#define AUDIO_PKT_SIZE   512

Definition at line 172 of file libmodplug.c.

◆ PRINT_INFO

#define PRINT_INFO ( line,
name,
idvalue )
Value:
do { \
snprintf(intbuf, sizeof(intbuf), "%.0f", var_values[idvalue]); \
write_text(pkt->data, name ":", modplug->linesize, 0+1, line+1); \
write_text(pkt->data, intbuf, modplug->linesize, 10+1, line+1); \
} while (0)
static AVPacket * pkt
const char * name
Definition qsvenc.c:142

Definition at line 285 of file libmodplug.c.

Referenced by modplug_read_packet().

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_TIME 
VAR_SPEED 
VAR_TEMPO 
VAR_ORDER 
VAR_PATTERN 
VAR_ROW 
VAR_VARS_NB 

Definition at line 73 of file libmodplug.c.

Function Documentation

◆ modplug_read_close()

static int modplug_read_close ( AVFormatContext * s)
static

Definition at line 104 of file libmodplug.c.

Referenced by modplug_read_header().

◆ modplug_load_metadata()

static int modplug_load_metadata ( AVFormatContext * s)
static

Definition at line 143 of file libmodplug.c.

Referenced by modplug_read_header().

◆ modplug_read_header()

static int modplug_read_header ( AVFormatContext * s)
static

Definition at line 174 of file libmodplug.c.

◆ write_text()

static void write_text ( uint8_t * dst,
const char * s,
int linesize,
int x,
int y )
static

Definition at line 274 of file libmodplug.c.

◆ modplug_read_packet()

static int modplug_read_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 291 of file libmodplug.c.

◆ modplug_read_seek()

static int modplug_read_seek ( AVFormatContext * s,
int stream_idx,
int64_t ts,
int flags )
static

Definition at line 356 of file libmodplug.c.

◆ modplug_probe()

static int modplug_probe ( const AVProbeData * p)
static

Definition at line 367 of file libmodplug.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"x", "y",
"w", "h",
"t",
"speed", "tempo", "order", "pattern", "row",
}
#define NULL
Definition coverity.c:32

Definition at line 65 of file libmodplug.c.

◆ options

const AVOption options[]
static
Initial value:
= {
{"noise_reduction", "Enable noise reduction 0(off)-1(on)", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D},
{"reverb_depth", "Reverb level 0(quiet)-100(loud)", OFFSET(reverb_depth), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D},
{"reverb_delay", "Reverb delay in ms, usually 40-200ms", OFFSET(reverb_delay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, D},
{"bass_amount", "XBass level 0(quiet)-100(loud)", OFFSET(bass_amount), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D},
{"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D},
{"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D},
{"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, D},
{"max_size", "Max file size supported (in bytes). Default is 5MB. Set to 0 for no limit (not recommended)",
{"video_stream_expr", "Color formula", OFFSET(color_eval), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D},
{"video_stream", "Make demuxer output a video stream", OFFSET(video_stream), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D},
{"video_stream_w", "Video stream width in char (one char = 8x8px)", OFFSET(w), AV_OPT_TYPE_INT, {.i64 = 30}, 20, 512, D},
{"video_stream_h", "Video stream height in char (one char = 8x8px)", OFFSET(h), AV_OPT_TYPE_INT, {.i64 = 30}, 20, 512, D},
{"video_stream_ptxt", "Print speed, tempo, order, ... in video stream", OFFSET(print_textinfo), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
{NULL},
}
#define D
Definition avdct.c:35
static AVStream * video_stream
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define FF_MODPLUG_MAX_FILE_SIZE
Definition libmodplug.c:81
#define FF_MODPLUG_DEF_FILE_SIZE
Definition libmodplug.c:82
uint8_t w
Definition llvidencdsp.c:39

Definition at line 86 of file libmodplug.c.

◆ modplug_extensions

const char modplug_extensions[] = "669,abc,amf,ams,dbm,dmf,dsm,far,it,mdl,med,mid,mod,mt2,mtm,okt,psm,ptm,s3m,stm,ult,umx,xm,itgz,itr,itz,mdgz,mdr,mdz,s3gz,s3r,s3z,xmgz,xmr,xmz"
static

Definition at line 365 of file libmodplug.c.

Referenced by modplug_probe().

◆ modplug_class

const AVClass modplug_class
static
Initial value:
= {
.class_name = "ModPlug demuxer",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 378 of file libmodplug.c.

◆ ff_libmodplug_demuxer

const FFInputFormat ff_libmodplug_demuxer
Initial value:
= {
.p.name = "libmodplug",
.p.long_name = NULL_IF_CONFIG_SMALL("ModPlug demuxer"),
.p.extensions = modplug_extensions,
.p.priv_class = &modplug_class,
.priv_data_size = sizeof(ModPlugContext),
}
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
static int modplug_read_header(AVFormatContext *s)
Definition libmodplug.c:174
static const char modplug_extensions[]
Definition libmodplug.c:365
static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition libmodplug.c:291
static int modplug_read_close(AVFormatContext *s)
Definition libmodplug.c:104
static int modplug_read_seek(AVFormatContext *s, int stream_idx, int64_t ts, int flags)
Definition libmodplug.c:356
static const AVClass modplug_class
Definition libmodplug.c:378
static int modplug_probe(const AVProbeData *p)
Definition libmodplug.c:367

Definition at line 385 of file libmodplug.c.