FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
libmodplug.c File Reference

ModPlug demuxer. More...

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

Go to the source code of this file.

Data Structures

struct  ModPlugContext
 

Macros

#define FF_MODPLUG_MAX_FILE_SIZE   (100 * 1<<20)
 
#define FF_MODPLUG_DEF_FILE_SIZE   ( 5 * 1<<20)
 
#define OFFSET(x)   offsetof(ModPlugContext, 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_B1, VAR_B2, VAR_S1, VAR_S2,
  VAR_T1, VAR_T2, VAR_NB, VAR_N,
  VAR_T, VAR_S, VAR_VARS_NB, VAR_TB,
  VAR_PTS, VAR_START_PTS, VAR_PREV_PTS, VAR_PREV_SELECTED_PTS,
  VAR_T, VAR_START_T, VAR_PREV_T, VAR_PREV_SELECTED_T,
  VAR_PICT_TYPE, VAR_PICT_TYPE_I, VAR_PICT_TYPE_P, VAR_PICT_TYPE_B,
  VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI, VAR_PICT_TYPE_SP, VAR_PICT_TYPE_BI,
  VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P, VAR_INTERLACE_TYPE_T, VAR_INTERLACE_TYPE_B,
  VAR_CONSUMED_SAMPLES_N, VAR_SAMPLES_N, VAR_SAMPLE_RATE, VAR_N,
  VAR_SELECTED_N, VAR_PREV_SELECTED_N, VAR_KEY, VAR_POS,
  VAR_SCENE, VAR_VARS_NB, VAR_FRAME_RATE, VAR_INTERLACED,
  VAR_N, VAR_NB_CONSUMED_SAMPLES, VAR_NB_SAMPLES, VAR_POS,
  VAR_PREV_INPTS, VAR_PREV_INT, VAR_PREV_OUTPTS, VAR_PREV_OUTT,
  VAR_PTS, VAR_SAMPLE_RATE, VAR_STARTPTS, VAR_STARTT,
  VAR_T, VAR_TB, VAR_RTCTIME, VAR_RTCSTART,
  VAR_VARS_NB, VAR_AVTB, VAR_INTB, VAR_SR,
  VAR_VARS_NB, VAR_W, VAR_H, VAR_CW,
  VAR_CH, VAR_HSUB, VAR_VSUB, VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VAR_X, VAR_Y, VAR_N,
  VAR_POS, VAR_T, VAR_VARS_NB, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_LINE_H, VAR_LH,
  VAR_MAIN_H, VAR_h, VAR_H, VAR_MAIN_W,
  VAR_w, VAR_W, VAR_MAX_GLYPH_A, VAR_ASCENT,
  VAR_MAX_GLYPH_D, VAR_DESCENT, VAR_MAX_GLYPH_H, VAR_MAX_GLYPH_W,
  VAR_N, VAR_SAR, VAR_T, VAR_TEXT_H,
  VAR_TH, VAR_TEXT_W, VAR_TW, VAR_X,
  VAR_Y, VAR_VARS_NB, VAR_N, VAR_PTS,
  VAR_R, VAR_T, VAR_TB, VAR_NB,
  VAR_W, VAR_H, VAR_VAL, VAR_MAXVAL,
  VAR_MINVAL, VAR_NEGVAL, VAR_CLIPVAL, VAR_VARS_NB,
  VAR_MAIN_W, VAR_MW, VAR_MAIN_H, VAR_MH,
  VAR_OVERLAY_W, VAR_OW, VAR_OVERLAY_H, VAR_OH,
  VAR_VARS_NB, VAR_IN_W, VAR_IW, VAR_IN_H,
  VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H,
  VAR_OH, VAR_X, VAR_Y, VAR_A,
  VAR_SAR, VAR_DAR, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_IN_W, VAR_IW, VAR_IN_H,
  VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H,
  VAR_OH, VAR_A, VAR_SAR, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VARS_NB, 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_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_close (AVFormatContext *s)
 
static int modplug_read_seek (AVFormatContext *s, int stream_idx, int64_t ts, int flags)
 

Variables

static const char * var_names []
 
static const AVOption options []
 
static const AVClass modplug_class
 
AVInputFormat ff_libmodplug_demuxer
 

Detailed Description

ModPlug demuxer.

Todo:
better probing than extensions matching

Definition in file libmodplug.c.

Macro Definition Documentation

#define FF_MODPLUG_MAX_FILE_SIZE   (100 * 1<<20)

Definition at line 78 of file libmodplug.c.

#define FF_MODPLUG_DEF_FILE_SIZE   ( 5 * 1<<20)

Definition at line 79 of file libmodplug.c.

Referenced by modplug_read_header().

#define OFFSET (   x)    offsetof(ModPlugContext, x)

Definition at line 81 of file libmodplug.c.

Definition at line 82 of file libmodplug.c.

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

Definition at line 101 of file libmodplug.c.

Referenced by modplug_read_header().

#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)

Definition at line 108 of file libmodplug.c.

Referenced by modplug_load_metadata().

#define AUDIO_PKT_SIZE   512

Definition at line 161 of file libmodplug.c.

Referenced by modplug_read_header(), and modplug_read_packet().

#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)

Definition at line 262 of file libmodplug.c.

Referenced by modplug_read_packet().

Enumeration Type Documentation

enum var_name
Enumerator:
VAR_B1 
VAR_B2 
VAR_S1 
VAR_S2 
VAR_T1 
VAR_T2 
VAR_NB 
VAR_N 
VAR_T 
VAR_S 
VAR_VARS_NB 
VAR_TB 
VAR_PTS 
VAR_START_PTS 
VAR_PREV_PTS 
VAR_PREV_SELECTED_PTS 
VAR_T 
VAR_START_T 
VAR_PREV_T 
VAR_PREV_SELECTED_T 
VAR_PICT_TYPE 
VAR_PICT_TYPE_I 
VAR_PICT_TYPE_P 
VAR_PICT_TYPE_B 
VAR_PICT_TYPE_S 
VAR_PICT_TYPE_SI 
VAR_PICT_TYPE_SP 
VAR_PICT_TYPE_BI 
VAR_INTERLACE_TYPE 
VAR_INTERLACE_TYPE_P 
VAR_INTERLACE_TYPE_T 
VAR_INTERLACE_TYPE_B 
VAR_CONSUMED_SAMPLES_N 
VAR_SAMPLES_N 
VAR_SAMPLE_RATE 
VAR_N 
VAR_SELECTED_N 
VAR_PREV_SELECTED_N 
VAR_KEY 
VAR_POS 
VAR_SCENE 
VAR_VARS_NB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R_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_X 
VAR_Y 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
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 70 of file libmodplug.c.

Function Documentation

static int modplug_load_metadata ( AVFormatContext s)
static

Definition at line 132 of file libmodplug.c.

Referenced by modplug_read_header().

static int modplug_read_header ( AVFormatContext s)
static

Definition at line 163 of file libmodplug.c.

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

Definition at line 251 of file libmodplug.c.

static int modplug_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 268 of file libmodplug.c.

static int modplug_read_close ( AVFormatContext s)
static

Definition at line 333 of file libmodplug.c.

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

Definition at line 341 of file libmodplug.c.

Variable Documentation

const char* var_names[]
static
Initial value:
= {
"x", "y",
"w", "h",
"t",
"speed", "tempo", "order", "pattern", "row",
}

Definition at line 62 of file libmodplug.c.

Referenced by modplug_read_header().

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},
}

Definition at line 83 of file libmodplug.c.

const AVClass modplug_class
static
Initial value:
= {
.class_name = "ModPlug demuxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 350 of file libmodplug.c.

AVInputFormat ff_libmodplug_demuxer
Initial value:
= {
.name = "libmodplug",
.long_name = NULL_IF_CONFIG_SMALL("ModPlug demuxer"),
.priv_data_size = sizeof(ModPlugContext),
.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",
.priv_class = &modplug_class,
}

Definition at line 357 of file libmodplug.c.