[vlc-commits] audio input core: fix wrong parsing of replaygain tags (fix #8174)

Anatoliy Anischovich git at videolan.org
Sun Mar 10 17:19:30 CET 2013


vlc | branch: master | Anatoliy Anischovich <lin.aaa.lin at gmail.com> | Sat Mar  9 21:29:19 2013 +0200| [23a3b08de9177fe2c0b2d2865afe674c3841325d] | committer: Jean-Baptiste Kempf

audio input core: fix wrong parsing of replaygain tags (fix #8174)

Before dictionaries there was a loop, so if-else way was ok, but not now. Also, locale-dependent atof().
Remove unnecessary replaygain stuff from flac demuxer.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23a3b08de9177fe2c0b2d2865afe674c3841325d
---

 include/vlc_input.h        |   36 ------------------------------------
 modules/codec/vorbis.c     |    9 +++++----
 modules/demux/flac.c       |    4 ----
 src/input/input_internal.h |    4 ++++
 src/input/meta.c           |   37 +++++++++++++++++++++++++++++++++++++
 5 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index cbd6aab..7c20004 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -40,42 +40,6 @@
 #include <string.h>
 
 /*****************************************************************************
- * Meta data helpers
- *****************************************************************************/
-static inline void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
-                                                        const vlc_meta_t *p_meta )
-{
-    const char * psz_value;
-
-    if( !p_meta )
-        return;
-
-    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_GAIN")) ||
-        (psz_value = vlc_meta_GetExtra(p_meta, "RG_RADIO")) )
-    {
-        p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
-        p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
-    }
-    else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
-             (psz_value = vlc_meta_GetExtra(p_meta, "RG_PEAK" )) )
-    {
-        p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
-        p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
-    }
-    else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
-             (psz_value = vlc_meta_GetExtra(p_meta, "RG_AUDIOPHILE" )) )
-    {
-        p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
-        p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
-    }
-    else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_PEAK" )) )
-    {
-        p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
-        p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
-    }
-}
-
-/*****************************************************************************
  * Seek point: (generalisation of chapters)
  *****************************************************************************/
 struct seekpoint_t
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index 7cc2ec9..9f3bd47 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -34,6 +34,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
+#include <vlc_charset.h>
 #include <vlc_aout.h>
 #include <vlc_input.h>
 #include <vlc_sout.h>
@@ -583,7 +584,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
-                r->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
+                r->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
             }
             else if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_PEAK" ) ||
                      !strcasecmp( psz_name, "RG_PEAK" ) )
@@ -591,7 +592,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
-                r->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
+                r->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
             }
             else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_GAIN" ) ||
                      !strcasecmp( psz_name, "RG_AUDIOPHILE" ) )
@@ -599,14 +600,14 @@ static void ParseVorbisComments( decoder_t *p_dec )
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
-                r->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
+                r->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
             }
             else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_PEAK" ) )
             {
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
-                r->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
+                r->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
             }
             else if( !strcasecmp( psz_name, "METADATA_BLOCK_PICTURE" ) )
             { /* Do nothing, for now */ }
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index a0607f1..c18b5a9 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -72,7 +72,6 @@ struct demux_sys_t
     decoder_t *p_packetizer;
 
     vlc_meta_t *p_meta;
-    audio_replay_gain_t replay_gain;
 
     int64_t i_time_offset;
     int64_t i_pts;
@@ -128,7 +127,6 @@ static int Open( vlc_object_t * p_this )
     p_demux->p_sys      = p_sys;
     p_sys->b_start = true;
     p_sys->p_meta = NULL;
-    memset( &p_sys->replay_gain, 0, sizeof(p_sys->replay_gain) );
     p_sys->i_length = 0;
     p_sys->i_time_offset = 0;
     p_sys->i_pts = 0;
@@ -169,7 +167,6 @@ static int Open( vlc_object_t * p_this )
                   p_sys->attachments[p_sys->i_cover_idx]->psz_name );
         vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url );
     }
-    vlc_audio_replay_gain_MergeFromMeta( &p_sys->replay_gain, p_sys->p_meta );
     return VLC_SUCCESS;
 }
 
@@ -224,7 +221,6 @@ static int Demux( demux_t *p_demux )
             if( p_sys->p_es == NULL )
             {
                 p_sys->p_packetizer->fmt_out.b_packetized = true;
-                p_sys->p_packetizer->fmt_out.audio_replay_gain = p_sys->replay_gain;
                 p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_out);
             }
 
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b3ad9e7..220f614 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -253,4 +253,8 @@ int subtitles_Filter( const char *);
 void input_SplitMRL( const char **, const char **, const char **,
                      const char **, char * );
 
+/* meta.c */
+void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
+                                          const vlc_meta_t *p_meta );
+
 #endif
diff --git a/src/input/meta.c b/src/input/meta.c
index c5efa9c..aeda5d4 100644
--- a/src/input/meta.c
+++ b/src/input/meta.c
@@ -33,6 +33,7 @@
 #include <vlc_url.h>
 #include <vlc_arrays.h>
 #include <vlc_modules.h>
+#include <vlc_charset.h>
 
 #include "input_internal.h"
 #include "../playlist/art.h"
@@ -291,3 +292,39 @@ error:
     vlc_object_release( p_export );
     return VLC_EGENERIC;
 }
+
+void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
+                                          const vlc_meta_t *p_meta )
+{
+    const char * psz_value;
+
+    if( !p_meta )
+        return;
+
+    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_GAIN")) ||
+        (psz_value = vlc_meta_GetExtra(p_meta, "RG_RADIO")) )
+    {
+        p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
+        p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+    }
+
+    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
+             (psz_value = vlc_meta_GetExtra(p_meta, "RG_PEAK" )) )
+    {
+        p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
+        p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+    }
+
+    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
+             (psz_value = vlc_meta_GetExtra(p_meta, "RG_AUDIOPHILE" )) )
+    {
+        p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
+        p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+    }
+
+    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_PEAK" )) )
+    {
+        p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
+        p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+    }
+}



More information about the vlc-commits mailing list