/*****************************************************************************
* mod.c: MOD file demuxer (using libmodplug)
*****************************************************************************
- * Copyright (C) 2004-2009 the VideoLAN team
+ * Copyright (C) 2004-2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Konstanty Bialkowski <konstanty@ieee.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
add_bool( "mod-reverb", false, N_("Reverb"),
REVERB_LONGTEXT, false )
- add_integer_with_range( "mod-reverb-level", 0, 0, 100, NULL,
+ add_integer_with_range( "mod-reverb-level", 0, 0, 100,
N_("Reverberation level"), REVERB_LEVEL_LONGTEXT, true )
- add_integer_with_range( "mod-reverb-delay", 40, 0, 1000, NULL,
+ add_integer_with_range( "mod-reverb-delay", 40, 0, 1000,
N_("Reverberation delay"), REVERB_DELAY_LONGTEXT, true )
add_bool( "mod-megabass", false, N_("Mega bass"),
MEGABASS_LONGTEXT, false )
- add_integer_with_range( "mod-megabass-level", 0, 0, 100, NULL,
+ add_integer_with_range( "mod-megabass-level", 0, 0, 100,
N_("Mega bass level"), MEGABASS_LEVEL_LONGTEXT, true )
- add_integer_with_range( "mod-megabass-range", 10, 10, 100, NULL,
+ add_integer_with_range( "mod-megabass-range", 10, 10, 100,
N_("Mega bass cutoff"), MEGABASS_RANGE_LONGTEXT, true )
add_bool( "mod-surround", false, N_("Surround"), N_("Surround"),
false )
- add_integer_with_range( "mod-surround-level", 0, 0, 100, NULL,
+ add_integer_with_range( "mod-surround-level", 0, 0, 100,
N_("Surround level"), SURROUND_LEVEL_LONGTEXT, true )
- add_integer_with_range( "mod-surround-delay", 5, 0, 1000, NULL,
+ add_integer_with_range( "mod-surround-delay", 5, 0, 1000,
N_("Surround delay (ms)"), SURROUND_DELAY_LONGTEXT, true )
set_callbacks( Open, Close )
static int Validate( demux_t *p_demux, const char *psz_ext );
-static const char *ppsz_mod_ext[] =
-{
- "mod", "s3m", "xm", "it", "669", "amf", "ams", "dbm", "dmf", "dsm",
- "far", "mdl", "med", "mtm", "okt", "ptm", "stm", "ult", "umx", "mt2",
- "psm", "abc", NULL
-};
-
-
/* We load the complete file in memory, put a higher bound
* of 500 Mo (which is really big anyway) */
#define MOD_MAX_FILE_SIZE (500*1000*1000)
/* We accept file based on extension match */
if( !p_demux->b_force )
{
- if( !p_demux->psz_file )
- return VLC_EGENERIC;
- const char *psz_ext = strrchr( p_demux->psz_file, '.' );
- int i;
+ const char *psz_ext = p_demux->psz_file ? strrchr( p_demux->psz_file, '.' )
+ : NULL;
+ if( psz_ext )
+ psz_ext++;
- if( !psz_ext )
- return VLC_EGENERIC;
-
- psz_ext++; /* skip . */
- for( i = 0; ppsz_mod_ext[i] != NULL; i++ )
- {
- if( !strcasecmp( psz_ext, ppsz_mod_ext[i] ) )
- break;
- }
- if( ppsz_mod_ext[i] == NULL )
- return VLC_EGENERIC;
- if( Validate( p_demux, ppsz_mod_ext[i] ) )
+ if( Validate( p_demux, psz_ext ) )
{
- msg_Warn( p_demux, "MOD validation failed (ext=%s)", ppsz_mod_ext[i]);
+ msg_Dbg( p_demux, "MOD validation failed (ext=%s)", psz_ext ? psz_ext : "");
return VLC_EGENERIC;
}
- msg_Dbg( p_demux, "running MOD demuxer (ext=%s)", ppsz_mod_ext[i] );
}
const int64_t i_size = stream_Size( p_demux->s );
settings.mFrequency = 44100;
settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
- if( var_CreateGetBool( p_demux, "mod-noisereduction" ) )
+ if( var_InheritBool( p_demux, "mod-noisereduction" ) )
settings.mFlags |= MODPLUG_ENABLE_NOISE_REDUCTION;
- if( var_CreateGetBool( p_demux, "mod-reverb" ) )
+ if( var_InheritBool( p_demux, "mod-reverb" ) )
settings.mFlags |= MODPLUG_ENABLE_REVERB;
- settings.mReverbDepth = var_CreateGetInteger( p_demux, "mod-reverb-level" );
- settings.mReverbDelay = var_CreateGetInteger( p_demux, "mod-reverb-delay" );
+ settings.mReverbDepth = var_InheritInteger( p_demux, "mod-reverb-level" );
+ settings.mReverbDelay = var_InheritInteger( p_demux, "mod-reverb-delay" );
- if( var_CreateGetBool( p_demux, "mod-megabass" ) )
+ if( var_InheritBool( p_demux, "mod-megabass" ) )
settings.mFlags |= MODPLUG_ENABLE_MEGABASS;
- settings.mBassAmount = var_CreateGetInteger( p_demux, "mod-megabass-level" );
- settings.mBassRange = var_CreateGetInteger( p_demux, "mod-megabass-range" );
+ settings.mBassAmount = var_InheritInteger( p_demux, "mod-megabass-level" );
+ settings.mBassRange = var_InheritInteger( p_demux, "mod-megabass-range" );
- if( var_CreateGetBool( p_demux, "mod-surround" ) )
+ if( var_InheritBool( p_demux, "mod-surround" ) )
settings.mFlags |= MODPLUG_ENABLE_SURROUND;
- settings.mSurroundDepth = var_CreateGetInteger( p_demux, "mod-surround-level" );
- settings.mSurroundDelay = var_CreateGetInteger( p_demux, "mod-surround-delay" );
+ settings.mSurroundDepth = var_InheritInteger( p_demux, "mod-surround-level" );
+ settings.mSurroundDelay = var_InheritInteger( p_demux, "mod-surround-delay" );
ModPlug_SetSettings( &settings );
{ 0, "Extended Module" }, /* XM */
{ 44, "SCRM" }, /* S3M */
{ 0, "IMPM" }, /* IT */
- { 0, "MThd" }, /* MID */
{ 0, "GF1PATCH110" }, /* PAT */
{ 20, "!SCREAM!" }, /* STM */
{ 20, "!Scream!" }, /* STM */
{ 1080, "OKTA" },
{ 1080, "16CN" },
{ 1080, "32CN" },
+ { 1080, "FLT4" },
+ { 1080, "FLT8" },
+ { 1080, "6CHN" },
+ { 1080, "8CHN" },
{ 1080, "FLT" },
{ 1080, "TDZ" },
{ 1081, "CHN" },
{ -1, NULL }
};
+ static const char *ppsz_mod_ext[] =
+ {
+ "mod", "s3m", "xm", "it", "669", "amf", "ams", "dbm", "dmf", "dsm",
+ "far", "mdl", "med", "mtm", "okt", "ptm", "stm", "ult", "umx", "mt2",
+ "psm", "abc", NULL
+ };
+ bool has_valid_extension = false;
+ if( psz_ext )
+ {
+ for( int i = 0; ppsz_mod_ext[i] != NULL; i++ )
+ {
+ has_valid_extension |= !strcasecmp( psz_ext, ppsz_mod_ext[i] );
+ if( has_valid_extension )
+ break;
+ }
+ }
const uint8_t *p_peek;
const int i_peek = stream_Peek( p_demux->s, &p_peek, 2048 );
continue;
if( !memcmp( &p_peek[i_offset], psz_marker, i_size ) )
- return VLC_SUCCESS;
+ {
+ if( i_size >= 4 || has_valid_extension )
+ return VLC_SUCCESS;
+ }
}
/* The only two format left untested are ABC and MOD(old version)
/* Check for ABC
* TODO i_peek = 2048 is too big for such files */
- if( !strcasecmp( psz_ext, "abc" ) )
+ if( psz_ext && !strcasecmp( psz_ext, "abc" ) )
{
bool b_k = false;
bool b_tx = false;
}
/* Check for MOD */
- if( !strcasecmp( psz_ext, "mod" ) && i_peek >= 20 + 15 * 30 )
+ if( psz_ext && !strcasecmp( psz_ext, "mod" ) && i_peek >= 20 + 15 * 30 )
{
/* Check that the name is correctly null padded */
const uint8_t *p = memchr( p_peek, '\0', 20 );