[FFmpeg-cvslog] af_volume: implement replaygain pre-amplification

Alessandro Ghedini git at videolan.org
Sat Apr 5 00:22:30 CEST 2014


ffmpeg | branch: master | Alessandro Ghedini <alessandro at ghedini.me> | Fri Apr  4 18:42:09 2014 +0200| [a49aa440c939e221194f8d95bf98673f8cf38a06] | committer: Anton Khirnov

af_volume: implement replaygain pre-amplification

This adds a new "replaygain_preamp" option to the filter, and simply adds its
value to the replaygain gain value.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a49aa440c939e221194f8d95bf98673f8cf38a06
---

 doc/filters.texi        |    6 ++++++
 libavfilter/af_volume.c |    4 +++-
 libavfilter/af_volume.h |    1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 93625c6..f986623 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -633,6 +633,12 @@ Prefer track gain, if present.
 @item album
 Prefer album gain, if present.
 @end table
+
+ at item replaygain_preamp
+Pre-amplification gain in dB to apply to the selected replaygain gain.
+
+Default value for @var{replaygain_preamp} is 0.0.
+
 @end table
 
 @subsection Examples
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 165624e..823fa15 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -59,6 +59,8 @@ static const AVOption options[] = {
         { "ignore", "replaygain side data is ignored", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_IGNORE }, 0, 0, A, "replaygain" },
         { "track",  "track gain is preferred",         0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_TRACK  }, 0, 0, A, "replaygain" },
         { "album",  "album gain is preferred",         0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_ALBUM  }, 0, 0, A, "replaygain" },
+    { "replaygain_preamp", "Apply replaygain pre-amplification",
+            OFFSET(replaygain_preamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, -15.0, 15.0, A },
     { NULL },
 };
 
@@ -262,7 +264,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
             av_log(inlink->dst, AV_LOG_VERBOSE,
                    "Using gain %f dB from replaygain side data.\n", g);
 
-            vol->volume   = pow(10, g / 20);
+            vol->volume   = pow(10, (g + vol->replaygain_preamp) / 20);
             vol->volume_i = (int)(vol->volume * 256 + 0.5);
 
             volume_init(vol);
diff --git a/libavfilter/af_volume.h b/libavfilter/af_volume.h
index ec13e80..d831ec4 100644
--- a/libavfilter/af_volume.h
+++ b/libavfilter/af_volume.h
@@ -47,6 +47,7 @@ typedef struct VolumeContext {
     AVFloatDSPContext fdsp;
     enum PrecisionType precision;
     enum ReplayGainType replaygain;
+    double replaygain_preamp;
     double volume;
     int    volume_i;
     int    channels;



More information about the ffmpeg-cvslog mailing list