]> git.sesse.net Git - vlc/commitdiff
audio input core: fix wrong parsing of replaygain tags (fix #8174)
authorAnatoliy Anischovich <lin.aaa.lin@gmail.com>
Sat, 9 Mar 2013 19:29:19 +0000 (21:29 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 10 Mar 2013 16:19:08 +0000 (17:19 +0100)
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@videolan.org>
include/vlc_input.h
modules/codec/vorbis.c
modules/demux/flac.c
src/input/input_internal.h
src/input/meta.c

index cbd6aab7f73bf5a31ce0cd083a46bb16147e0194..7c200046a3afe162d1495861e225f4b5422a330d 100644 (file)
 
 #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)
  *****************************************************************************/
index 7cc2ec9a2cf1826dd43009d87c0b76e23656f242..9f3bd4766205356a5894e215a52ecdd9acbb8f09 100644 (file)
@@ -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 */ }
index a0607f1c5f5040cafdd1e5c925b3a987549a5255..c18b5a9dbe29672cd04a6e7b41494000730828b5 100644 (file)
@@ -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);
             }
 
index b3ad9e7463481e92b929ed999f764289636f05ff..220f6147b647c1bd56e5de56b83d059d45c0199f 100644 (file)
@@ -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
index c5efa9cb0f92761bf95518e6ae84cd38ddb8f746..aeda5d40e5a8f877399fc28ef9c62b62dfebfccb 100644 (file)
@@ -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 );
+    }
+}