Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
a763b462
Commit
a763b462
authored
Oct 05, 2011
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libmodplug: support options (noise reduction, reverb, bass boost, ...)
parent
6638207b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
libmodplug.c
libavformat/libmodplug.c
+55
-1
No files found.
libavformat/libmodplug.c
View file @
a763b462
...
...
@@ -19,18 +19,48 @@
/**
* @file
* ModPlug demuxer
* @todo ModPlug options (noise reduction, reverb, bass boost, ...)
* @todo metadata
*/
#include <libmodplug/modplug.h>
#include "libavutil/opt.h"
#include "avformat.h"
typedef
struct
ModPlugContext
{
const
AVClass
*
class
;
ModPlugFile
*
f
;
uint8_t
buf
[
5
*
1
<<
20
];
///< input file content, 5M max
/* options */
int
noise_reduction
;
int
reverb_depth
;
int
reverb_delay
;
int
bass_amount
;
int
bass_range
;
int
surround_depth
;
int
surround_delay
;
}
ModPlugContext
;
#define OFFSET(x) offsetof(ModPlugContext, x)
#define D AV_OPT_FLAG_DECODING_PARAM
static
const
AVOption
options
[]
=
{
{
"noise_reduction"
,
"Enable noise reduction 0(off)-1(on)"
,
OFFSET
(
noise_reduction
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
1
,
D
},
{
"reverb_depth"
,
"Reverb level 0(quiet)-100(loud)"
,
OFFSET
(
reverb_depth
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
100
,
D
},
{
"reverb_delay"
,
"Reverb delay in ms, usually 40-200ms"
,
OFFSET
(
reverb_delay
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
INT_MAX
,
D
},
{
"bass_amount"
,
"XBass level 0(quiet)-100(loud)"
,
OFFSET
(
bass_amount
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
100
,
D
},
{
"bass_range"
,
"XBass cutoff in Hz 10-100"
,
OFFSET
(
bass_range
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
100
,
D
},
{
"surround_depth"
,
"Surround level 0(quiet)-100(heavy)"
,
OFFSET
(
surround_depth
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
100
,
D
},
{
"surround_delay"
,
"Surround delay in ms, usually 5-40ms"
,
OFFSET
(
surround_delay
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
INT_MAX
,
D
},
{
NULL
},
};
#define SET_OPT_IF_REQUESTED(libopt, opt, flag) do { \
if (modplug->opt) { \
settings.libopt = modplug->opt; \
settings.mFlags |= flag; \
} \
} while (0)
static
int
modplug_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
AVStream
*
st
;
...
...
@@ -46,6 +76,22 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap)
settings
.
mFrequency
=
44100
;
settings
.
mResamplingMode
=
MODPLUG_RESAMPLE_FIR
;
// best quality
settings
.
mLoopCount
=
0
;
// prevents looping forever
if
(
modplug
->
noise_reduction
)
settings
.
mFlags
|=
MODPLUG_ENABLE_NOISE_REDUCTION
;
SET_OPT_IF_REQUESTED
(
mReverbDepth
,
reverb_depth
,
MODPLUG_ENABLE_REVERB
);
SET_OPT_IF_REQUESTED
(
mReverbDelay
,
reverb_delay
,
MODPLUG_ENABLE_REVERB
);
SET_OPT_IF_REQUESTED
(
mBassAmount
,
bass_amount
,
MODPLUG_ENABLE_MEGABASS
);
SET_OPT_IF_REQUESTED
(
mBassRange
,
bass_range
,
MODPLUG_ENABLE_MEGABASS
);
SET_OPT_IF_REQUESTED
(
mSurroundDepth
,
surround_depth
,
MODPLUG_ENABLE_SURROUND
);
SET_OPT_IF_REQUESTED
(
mSurroundDelay
,
surround_delay
,
MODPLUG_ENABLE_SURROUND
);
if
(
modplug
->
reverb_depth
)
settings
.
mReverbDepth
=
modplug
->
reverb_depth
;
if
(
modplug
->
reverb_delay
)
settings
.
mReverbDelay
=
modplug
->
reverb_delay
;
if
(
modplug
->
bass_amount
)
settings
.
mBassAmount
=
modplug
->
bass_amount
;
if
(
modplug
->
bass_range
)
settings
.
mBassRange
=
modplug
->
bass_range
;
if
(
modplug
->
surround_depth
)
settings
.
mSurroundDepth
=
modplug
->
surround_depth
;
if
(
modplug
->
surround_delay
)
settings
.
mSurroundDelay
=
modplug
->
surround_delay
;
ModPlug_SetSettings
(
&
settings
);
modplug
->
f
=
ModPlug_Load
(
modplug
->
buf
,
sz
);
...
...
@@ -93,6 +139,13 @@ static int modplug_read_seek(AVFormatContext *s, int stream_idx, int64_t ts, int
return
0
;
}
static
const
AVClass
modplug_class
=
{
.
class_name
=
"ModPlug demuxer"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
AVInputFormat
ff_libmodplug_demuxer
=
{
.
name
=
"libmodplug"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ModPlug demuxer"
),
...
...
@@ -103,4 +156,5 @@ AVInputFormat ff_libmodplug_demuxer = {
.
read_seek
=
modplug_read_seek
,
.
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"
,
// compressed mods
.
priv_class
=
&
modplug_class
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment