Commit 525c7aa4 authored by Anatoliy Anischovich's avatar Anatoliy Anischovich Committed by Jean-Baptiste Kempf

demux: mpc: fix replaygain calculation (fixes #13176)

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit d5d3b2551d640efe27d5d70084b7235b3932cdfb)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 3d0ef0db
...@@ -192,21 +192,33 @@ static int Open( vlc_object_t * p_this ) ...@@ -192,21 +192,33 @@ static int Open( vlc_object_t * p_this )
fmt.audio.i_bitspersample = 32; fmt.audio.i_bitspersample = 32;
fmt.i_bitrate = fmt.i_bitrate * fmt.audio.i_channels * fmt.i_bitrate = fmt.i_bitrate * fmt.audio.i_channels *
fmt.audio.i_bitspersample; fmt.audio.i_bitspersample;
#ifdef HAVE_MPC_MPCDEC_H
# define CONVERT_PEAK( mpc_peak ) (pow( 10, (mpc_peak) / 256.0 / 20.0 ) / 32767.0)
# define CONVERT_GAIN( mpc_gain ) (MPC_OLD_GAIN_REF - (mpc_gain) / 256.0)
#else
# define CONVERT_PEAK( mpc_peak ) ((mpc_peak) / 32767.0)
# define CONVERT_GAIN( mpc_gain ) ((mpc_gain) / 100.0)
#endif
if( p_sys->info.peak_title > 0 ) if( p_sys->info.peak_title > 0 )
{ {
fmt.audio_replay_gain.pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true; fmt.audio_replay_gain.pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
fmt.audio_replay_gain.pf_peak[AUDIO_REPLAY_GAIN_TRACK] = (float)p_sys->info.peak_title / 32767.0; fmt.audio_replay_gain.pf_peak[AUDIO_REPLAY_GAIN_TRACK] = (float) CONVERT_PEAK( p_sys->info.peak_title );
fmt.audio_replay_gain.pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true; fmt.audio_replay_gain.pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
fmt.audio_replay_gain.pf_gain[AUDIO_REPLAY_GAIN_TRACK] = (float)p_sys->info.gain_title / 100.0; fmt.audio_replay_gain.pf_gain[AUDIO_REPLAY_GAIN_TRACK] = (float) CONVERT_GAIN( p_sys->info.gain_title );
} }
if( p_sys->info.peak_album > 0 ) if( p_sys->info.peak_album > 0 )
{ {
fmt.audio_replay_gain.pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true; fmt.audio_replay_gain.pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
fmt.audio_replay_gain.pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = (float)p_sys->info.peak_album / 32767.0; fmt.audio_replay_gain.pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = (float) CONVERT_PEAK( p_sys->info.peak_album );
fmt.audio_replay_gain.pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true; fmt.audio_replay_gain.pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
fmt.audio_replay_gain.pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = (float)p_sys->info.gain_album / 100.0; fmt.audio_replay_gain.pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = (float) CONVERT_GAIN( p_sys->info.gain_album );
} }
#undef CONVERT_GAIN
#undef CONVERT_PEAK
p_sys->p_es = es_out_Add( p_demux->out, &fmt ); p_sys->p_es = es_out_Add( p_demux->out, &fmt );
if( !p_sys->p_es ) if( !p_sys->p_es )
goto error; goto error;
......
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