Commit 23a3b08d authored by Anatoliy Anischovich's avatar Anatoliy Anischovich Committed by 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 14d3718f
...@@ -39,42 +39,6 @@ ...@@ -39,42 +39,6 @@
#include <string.h> #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) * Seek point: (generalisation of chapters)
*****************************************************************************/ *****************************************************************************/
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_codec.h> #include <vlc_codec.h>
#include <vlc_charset.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_sout.h> #include <vlc_sout.h>
...@@ -583,7 +584,7 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -583,7 +584,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain; audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true; 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" ) || else if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_PEAK" ) ||
!strcasecmp( psz_name, "RG_PEAK" ) ) !strcasecmp( psz_name, "RG_PEAK" ) )
...@@ -591,7 +592,7 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -591,7 +592,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain; audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true; 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" ) || else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_GAIN" ) ||
!strcasecmp( psz_name, "RG_AUDIOPHILE" ) ) !strcasecmp( psz_name, "RG_AUDIOPHILE" ) )
...@@ -599,14 +600,14 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -599,14 +600,14 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain; audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true; 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" ) ) else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_PEAK" ) )
{ {
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain; audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true; 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" ) ) else if( !strcasecmp( psz_name, "METADATA_BLOCK_PICTURE" ) )
{ /* Do nothing, for now */ } { /* Do nothing, for now */ }
......
...@@ -72,7 +72,6 @@ struct demux_sys_t ...@@ -72,7 +72,6 @@ struct demux_sys_t
decoder_t *p_packetizer; decoder_t *p_packetizer;
vlc_meta_t *p_meta; vlc_meta_t *p_meta;
audio_replay_gain_t replay_gain;
int64_t i_time_offset; int64_t i_time_offset;
int64_t i_pts; int64_t i_pts;
...@@ -128,7 +127,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -128,7 +127,6 @@ static int Open( vlc_object_t * p_this )
p_demux->p_sys = p_sys; p_demux->p_sys = p_sys;
p_sys->b_start = true; p_sys->b_start = true;
p_sys->p_meta = NULL; p_sys->p_meta = NULL;
memset( &p_sys->replay_gain, 0, sizeof(p_sys->replay_gain) );
p_sys->i_length = 0; p_sys->i_length = 0;
p_sys->i_time_offset = 0; p_sys->i_time_offset = 0;
p_sys->i_pts = 0; p_sys->i_pts = 0;
...@@ -169,7 +167,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -169,7 +167,6 @@ static int Open( vlc_object_t * p_this )
p_sys->attachments[p_sys->i_cover_idx]->psz_name ); p_sys->attachments[p_sys->i_cover_idx]->psz_name );
vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url ); 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; return VLC_SUCCESS;
} }
...@@ -224,7 +221,6 @@ static int Demux( demux_t *p_demux ) ...@@ -224,7 +221,6 @@ static int Demux( demux_t *p_demux )
if( p_sys->p_es == NULL ) if( p_sys->p_es == NULL )
{ {
p_sys->p_packetizer->fmt_out.b_packetized = true; 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); p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_out);
} }
......
...@@ -253,4 +253,8 @@ int subtitles_Filter( const char *); ...@@ -253,4 +253,8 @@ int subtitles_Filter( const char *);
void input_SplitMRL( const char **, const char **, const char **, void input_SplitMRL( const char **, const char **, const char **,
const char **, 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 #endif
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_arrays.h> #include <vlc_arrays.h>
#include <vlc_modules.h> #include <vlc_modules.h>
#include <vlc_charset.h>
#include "input_internal.h" #include "input_internal.h"
#include "../playlist/art.h" #include "../playlist/art.h"
...@@ -291,3 +292,39 @@ error: ...@@ -291,3 +292,39 @@ error:
vlc_object_release( p_export ); vlc_object_release( p_export );
return VLC_EGENERIC; 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 );
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment