X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fmpc.c;h=d6d4ed3ea4378a28be242009694cd1cb0b7044e4;hb=fe4423ddd4038e314d5cf07e75c3da4f42f43bdc;hp=a518fad2deb81d60b20b98f8ab06fd28bfda6864;hpb=499cb6f593cb0c3254aac3f9ebc271ba3a4c965d;p=vlc diff --git a/modules/demux/mpc.c b/modules/demux/mpc.c index a518fad2de..d6d4ed3ea4 100644 --- a/modules/demux/mpc.c +++ b/modules/demux/mpc.c @@ -2,7 +2,7 @@ * mpc.c : MPC stream input module for vlc ***************************************************************************** * Copyright (C) 2001 the VideoLAN team - * $Id: a52.c 11699 2005-07-11 08:52:14Z sam $ + * $Id$ * * Authors: Laurent Aimar * @@ -18,14 +18,20 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include #include #include @@ -43,25 +49,14 @@ /***************************************************************************** * Module descriptor *****************************************************************************/ -#define REPLAYGAIN_TYPE_TEXT N_("Replay Gain type" ) -#define REPLAYGAIN_TYPE_LONGTEXT N_( "Replay Gain type" ) - static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -static int pi_replaygain_type[] = { 0, 1, 2 }; -static char *ppsz_replaygain_type[] = { N_("None"), N_("Title"), N_("Album") }; - vlc_module_begin(); - set_shortname( "MPC" ); - set_description( _("MPC demuxer") ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_DEMUX ); - set_capability( "demux2", 145 ); - - add_integer( "mpc-replaygain-type", 2, NULL, - REPLAYGAIN_TYPE_TEXT, REPLAYGAIN_TYPE_LONGTEXT, VLC_FALSE ); - change_integer_list( pi_replaygain_type, ppsz_replaygain_type, 0 ); + set_description( N_("MusePack demuxer") ); + set_capability( "demux", 145 ); set_callbacks( Open, Close ); add_shortcut( "mpc" ); @@ -84,7 +79,6 @@ struct demux_sys_t mpc_streaminfo info; /* */ - vlc_meta_t *p_meta; int64_t i_position; }; @@ -101,34 +95,26 @@ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; - char psz_info[4096]; es_format_t fmt; - uint8_t *p_peek; - module_t *p_id3; + const uint8_t *p_peek; if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( memcmp( p_peek, "MP+", 3 ) ) { - /* for v4..6 we check extention file */ + /* for v4..6 we check extension file */ const int i_version = (GetDWLE( p_peek ) >> 11)&0x3ff; if( i_version < 4 || i_version > 6 ) return VLC_EGENERIC; - if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, "mpc" ) ) + if( !p_demux->b_force ) { /* Check file name extension */ - int i_len; - if( !p_demux->psz_path ) - return VLC_EGENERIC; - - i_len = strlen( p_demux->psz_path ); - if( i_len < 4 || - ( strcasecmp( &p_demux->psz_path[i_len-4], ".mpc" ) && - strcasecmp( &p_demux->psz_path[i_len-4], ".mp+" ) && - strcasecmp( &p_demux->psz_path[i_len-4], ".mpp" ) ) ) + if( !demux_IsPathExtension( p_demux, ".mpc" ) && + !demux_IsPathExtension( p_demux, ".mp+" ) && + !demux_IsPathExtension( p_demux, ".mpp" ) ) return VLC_EGENERIC; } } @@ -164,41 +150,6 @@ static int Open( vlc_object_t * p_this ) return VLC_EGENERIC; } - /* Handle reaply gain */ - if( p_sys->info.peak_title != 32767 ) - { - int i_type = var_CreateGetInteger( p_demux, "mpc-replaygain-type" ); - int gain; - int peak; - - if( i_type == 2 ) // album - { - gain = p_sys->info.gain_album; - peak = p_sys->info.peak_album; - } - else if( i_type == 1 ) // title - { - gain = p_sys->info.gain_title; - peak = p_sys->info.peak_title; - } - else - { - gain = 0; - peak = 0; - } - - if( gain ) - { - double g = pow( 10, (double)gain / 2000.0 ); - double gmax = (double)32767.0 / (peak+1); - if( g > gmax ) - g = gmax; - - msg_Dbg( p_demux, "Using reaply gain factor %f", g ); - mpc_decoder_scale_output( &p_sys->decoder, g ); - } - } - /* Fill p_demux fields */ p_demux->pf_demux = Demux; p_demux->pf_control = Control; @@ -220,22 +171,22 @@ static int Open( vlc_object_t * p_this ) fmt.audio.i_bitspersample = 32; fmt.i_bitrate = fmt.i_bitrate * fmt.audio.i_channels * fmt.audio.i_bitspersample; - p_sys->p_es = es_out_Add( p_demux->out, &fmt ); - - - /* Parse possible id3 header */ - if( ( p_id3 = module_Need( p_demux, "id3", NULL, 0 ) ) ) + if( p_sys->info.peak_title > 0 ) { - p_sys->p_meta = (vlc_meta_t *)p_demux->p_private; - p_demux->p_private = NULL; - module_Unneed( p_demux, p_id3 ); + 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.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; + } + if( p_sys->info.peak_album > 0 ) + { + 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.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; } - if( !p_sys->p_meta ) - p_sys->p_meta = vlc_meta_New(); - - sprintf( psz_info, "Musepack v%d", p_sys->info.stream_version ); - vlc_meta_Add( p_sys->p_meta, VLC_META_CODEC_NAME, psz_info ); + p_sys->p_es = es_out_Add( p_demux->out, &fmt ); return VLC_SUCCESS; } @@ -276,7 +227,7 @@ static int Demux( demux_t *p_demux ) /* */ p_data->i_buffer = i_ret * sizeof(MPC_SAMPLE_FORMAT) * p_sys->info.channels; p_data->i_dts = p_data->i_pts = - 1 + I64C(1000000) * p_sys->i_position / p_sys->info.sample_freq; + 1 + INT64_C(1000000) * p_sys->i_position / p_sys->info.sample_freq; es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_data->i_dts ); @@ -294,24 +245,20 @@ static int Demux( demux_t *p_demux ) static int Control( demux_t *p_demux, int i_query, va_list args ) { demux_sys_t *p_sys = p_demux->p_sys; - int i; double f, *pf; int64_t i64, *pi64; - vlc_meta_t **pp_meta; + bool *pb_bool; switch( i_query ) { - case DEMUX_GET_META: - pp_meta = (vlc_meta_t **)va_arg( args, vlc_meta_t** ); - if( p_sys->p_meta ) - *pp_meta = vlc_meta_Duplicate( p_sys->p_meta ); - else - *pp_meta = NULL; + case DEMUX_HAS_UNSUPPORTED_META: + pb_bool = (bool*)va_arg( args, bool* ); + *pb_bool = true; return VLC_SUCCESS; case DEMUX_GET_LENGTH: pi64 = (int64_t*)va_arg( args, int64_t * ); - *pi64 = I64C(1000000) * p_sys->info.pcm_samples / + *pi64 = INT64_C(1000000) * p_sys->info.pcm_samples / p_sys->info.sample_freq; return VLC_SUCCESS; @@ -326,7 +273,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_GET_TIME: pi64 = (int64_t*)va_arg( args, int64_t * ); - *pi64 = I64C(1000000) * p_sys->i_position / + *pi64 = INT64_C(1000000) * p_sys->i_position / p_sys->info.sample_freq; return VLC_SUCCESS; @@ -381,7 +328,7 @@ mpc_int32_t ReaderGetSize( void *p_private ) mpc_bool_t ReaderCanSeek( void *p_private ) { demux_t *p_demux = (demux_t*)p_private; - vlc_bool_t b_canseek; + bool b_canseek; stream_Control( p_demux->s, STREAM_CAN_SEEK, &b_canseek ); return b_canseek;