[PATCH 1/2] libmodplug: support options (noise reduction, reverb, bass boost, ...)
--- libavformat/libmodplug.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-) diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index b4978b9..2f7c4fa 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -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, {.i64 = 0}, 0, 1, D}, + {"reverb_depth", "Reverb level 0(quiet)-100(loud)", OFFSET(reverb_depth), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, + {"reverb_delay", "Reverb delay in ms, usually 40-200ms", OFFSET(reverb_delay), FF_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, D}, + {"bass_amount", "XBass level 0(quiet)-100(loud)", OFFSET(bass_amount), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, + {"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, + {"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, + {"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), FF_OPT_TYPE_INT, {.i64 = 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, }; -- 1.7.7
--- libavformat/libmodplug.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index 2f7c4fa..a9aa5a6 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -29,7 +29,7 @@ typedef struct ModPlugContext { const AVClass *class; ModPlugFile *f; - uint8_t buf[5 * 1<<20]; ///< input file content, 5M max + uint8_t *buf; ///< input file content /* options */ int noise_reduction; @@ -39,8 +39,12 @@ typedef struct ModPlugContext { int bass_range; int surround_depth; int surround_delay; + + int max_size; ///< max file size to allocate } ModPlugContext; +#define FF_MODPLUG_MAX_FILE_SIZE (100 * 1<<20) // 100M + #define OFFSET(x) offsetof(ModPlugContext, x) #define D AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { @@ -51,6 +55,8 @@ static const AVOption options[] = { {"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, {"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, {"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), FF_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)", + OFFSET(max_size), FF_OPT_TYPE_INT, {.i64 = 5 * 1<<20}, 0, FF_MODPLUG_MAX_FILE_SIZE, D}, {NULL}, }; @@ -67,8 +73,22 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int r, sz = 0; - int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + for (;;) { + uint8_t *p = av_realloc(modplug->buf, sz + 1024); + if (!p) { + av_freep(&modplug->buf); + return AVERROR(ENOMEM); + } + modplug->buf = p; + r = avio_read(pb, modplug->buf + sz, 1024); + if (r == AVERROR_EOF) + break; + sz += r; + if (modplug->max_size && sz >= modplug->max_size) + break; + } ModPlug_GetSettings(&settings); settings.mChannels = 2; -- 1.7.7
On Wed, Oct 05, 2011 at 10:49:44PM +0200, Clément Bœsch wrote:
--- libavformat/libmodplug.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-)
Mmh, please forget this one, better one incoming. -- Clément B.
On Wed, Oct 05, 2011 at 11:05:52PM +0200, Clément Bœsch wrote:
On Wed, Oct 05, 2011 at 10:49:44PM +0200, Clément Bœsch wrote:
--- libavformat/libmodplug.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-)
Mmh, please forget this one, better one incoming.
New patch attached, sorry for the noise. -- Clément B.
On Wed, Oct 05, 2011 at 11:38:06PM +0200, Clément Bœsch wrote:
On Wed, Oct 05, 2011 at 11:05:52PM +0200, Clément Bœsch wrote:
On Wed, Oct 05, 2011 at 10:49:44PM +0200, Clément Bœsch wrote:
--- libavformat/libmodplug.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-)
Mmh, please forget this one, better one incoming.
New patch attached, sorry for the noise.
-- Clément B.
libmodplug.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 9c6e2b41e7108469661940bc280e32aef64e1aea 0002-libmodplug-add-an-option-to-enlarge-the-max-supporte.patch From 0fe4a532f0643e494436b5678189b558aa2639c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux@gmail.com> Date: Wed, 5 Oct 2011 22:47:46 +0200 Subject: [PATCH 2/2] libmodplug: add an option to enlarge the max supported file size.
--- libavformat/libmodplug.c | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index 2f7c4fa..e70fbae 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -29,7 +29,7 @@ typedef struct ModPlugContext { const AVClass *class; ModPlugFile *f; - uint8_t buf[5 * 1<<20]; ///< input file content, 5M max + uint8_t *buf; ///< input file content
/* options */ int noise_reduction; @@ -39,8 +39,13 @@ typedef struct ModPlugContext { int bass_range; int surround_depth; int surround_delay; + + int max_size; ///< max file size to allocate } ModPlugContext;
+#define FF_MODPLUG_MAX_FILE_SIZE (100 * 1<<20) // 100M +#define FF_MODPLUG_DEF_FILE_SIZE ( 5 * 1<<20) // 5M + #define OFFSET(x) offsetof(ModPlugContext, x) #define D AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { @@ -51,6 +56,8 @@ static const AVOption options[] = { {"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, {"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 100, D}, {"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), FF_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)", + OFFSET(max_size), FF_OPT_TYPE_INT, {.i64 = FF_MODPLUG_DEF_FILE_SIZE}, 0, FF_MODPLUG_MAX_FILE_SIZE, D}, {NULL}, };
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ? i would have thought many mod file formats are sensitiv to being truncated [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
On Thu, Oct 06, 2011 at 12:22:34AM +0200, Michael Niedermayer wrote: [...]
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
Indeed…
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ?
No it's likely to fail every time unfortunately.
i would have thought many mod file formats are sensitiv to being truncated
Yes, it was the case with all the samples I tested (it's the reason the message mentions the -max_size option to workaround the issue), but I believe at least one will be OK, so it doesn't fail immediately. Maybe you would prefer an extra warning saying it will likely fail? -- Clément B.
On Thu, Oct 06, 2011 at 12:30:53AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:22:34AM +0200, Michael Niedermayer wrote: [...]
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
Indeed…
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ?
No it's likely to fail every time unfortunately.
i would have thought many mod file formats are sensitiv to being truncated
Yes, it was the case with all the samples I tested (it's the reason the message mentions the -max_size option to workaround the issue), but I believe at least one will be OK, so it doesn't fail immediately.
Maybe you would prefer an extra warning saying it will likely fail?
yes [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire
On Thu, Oct 06, 2011 at 12:35:38AM +0200, Michael Niedermayer wrote:
On Thu, Oct 06, 2011 at 12:30:53AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:22:34AM +0200, Michael Niedermayer wrote: [...]
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
Indeed…
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ?
No it's likely to fail every time unfortunately.
i would have thought many mod file formats are sensitiv to being truncated
Yes, it was the case with all the samples I tested (it's the reason the message mentions the -max_size option to workaround the issue), but I believe at least one will be OK, so it doesn't fail immediately.
Maybe you would prefer an extra warning saying it will likely fail?
yes
Added "but demuxing is likely to fail due to incomplete buffer". [...] -- Clément B.
On Thu, Oct 06, 2011 at 01:24:21AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:35:38AM +0200, Michael Niedermayer wrote:
On Thu, Oct 06, 2011 at 12:30:53AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:22:34AM +0200, Michael Niedermayer wrote: [...]
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
Indeed…
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ?
No it's likely to fail every time unfortunately.
i would have thought many mod file formats are sensitiv to being truncated
Yes, it was the case with all the samples I tested (it's the reason the message mentions the -max_size option to workaround the issue), but I believe at least one will be OK, so it doesn't fail immediately.
Maybe you would prefer an extra warning saying it will likely fail?
yes
Added "but demuxing is likely to fail due to incomplete buffer".
[...]
And with the other changes too… -- Clément B.
On Thu, Oct 06, 2011 at 01:36:32AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 01:24:21AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:35:38AM +0200, Michael Niedermayer wrote:
On Thu, Oct 06, 2011 at 12:30:53AM +0200, Clément Bœsch wrote:
On Thu, Oct 06, 2011 at 12:22:34AM +0200, Michael Niedermayer wrote: [...]
@@ -67,8 +74,23 @@ static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIOContext *pb = s->pb; ModPlug_Settings settings; ModPlugContext *modplug = s->priv_data; + int sz = avio_size(pb);
- int sz = avio_read(pb, modplug->buf, sizeof(modplug->buf)); + if (sz < 0) { + av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
+ if (modplug->max_size != FF_MODPLUG_DEF_FILE_SIZE) + sz = modplug->max_size; + else + sz = FF_MODPLUG_DEF_FILE_SIZE;
sz = modplug->max_size;
Indeed…
+ } else if (modplug->max_size && sz > modplug->max_size) { + sz = modplug->max_size; + av_log(s, AV_LOG_WARNING, "Max file size reach%s, allocating %dB\n", + sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); + }
does this work for any file ?
No it's likely to fail every time unfortunately.
i would have thought many mod file formats are sensitiv to being truncated
Yes, it was the case with all the samples I tested (it's the reason the message mentions the -max_size option to workaround the issue), but I believe at least one will be OK, so it doesn't fail immediately.
Maybe you would prefer an extra warning saying it will likely fail?
yes
Added "but demuxing is likely to fail due to incomplete buffer".
[...]
And with the other changes too…
-- Clément B.
libmodplug.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) e55b879b4e667f27d1be6f1c57e2d62d6652039e 0002-libmodplug-add-an-option-to-enlarge-the-max-supporte.patch From a3978f80d5e43480491f2bfb7b0c143025819fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux@gmail.com> Date: Wed, 5 Oct 2011 22:47:46 +0200 Subject: [PATCH 2/3] libmodplug: add an option to enlarge the max supported file size.
LGTM [..] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong.
On Thu, Oct 06, 2011 at 02:44:13AM +0200, Michael Niedermayer wrote: [...]
libmodplug.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) e55b879b4e667f27d1be6f1c57e2d62d6652039e 0002-libmodplug-add-an-option-to-enlarge-the-max-supporte.patch From a3978f80d5e43480491f2bfb7b0c143025819fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux@gmail.com> Date: Wed, 5 Oct 2011 22:47:46 +0200 Subject: [PATCH 2/3] libmodplug: add an option to enlarge the max supported file size.
LGTM
Pushed. -- Clément B.
On Wed, Oct 05, 2011 at 10:49:43PM +0200, Clément Bœsch wrote:
--- libavformat/libmodplug.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index b4978b9..2f7c4fa 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -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, {.i64 = 0}, 0, 1, D},
FF_OPT_TYPE_INT uses dbl not i64 otherwise LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them.
On Thu, Oct 06, 2011 at 12:13:43AM +0200, Michael Niedermayer wrote:
On Wed, Oct 05, 2011 at 10:49:43PM +0200, Clément Bœsch wrote:
--- libavformat/libmodplug.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index b4978b9..2f7c4fa 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -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, {.i64 = 0}, 0, 1, D},
FF_OPT_TYPE_INT uses dbl not i64
otherwise LGTM
Pushed with that change. -- Clément B.
participants (2)
-
Clément Bœsch -
Michael Niedermayer