Index: get_path.c =================================================================== --- get_path.c (revision 30850) +++ get_path.c (working copy) @@ -193,3 +192,54 @@ mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!"); } #endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ + +#if CONFIG_SET_CODEC_PATH +extern void SetCodecPath(const char *); // in loader/drv.c + +void set_codec_path(void) +{ + char *codecs_dir; + char path[260]; + + codecs_dir = getenv("MPLAYER_CODECS_DIR"); + if (!codecs_dir) + codecs_dir = WIN32_PATH; + + // Absolute path ? + if ((codecs_dir[0] && codecs_dir[1] == ':') || + (codecs_dir[0] == '/' || codecs_dir[0] == '\\')) { + path[0] = 0; + + // Root path ? + if (codecs_dir[0] == '/' || codecs_dir[0] == '\\') { + // Add drive letter + char *unixroot; + + unixroot = getenv("UNIXROOT"); + if (unixroot) + strcpy(path, unixroot); + } + + strcat(path, codecs_dir); + } else { + // Convert to absolute path based on directory where MPlayer exist + + PPIB ppib; + + // Get process info blocks + DosGetInfoBlocks(NULL, &ppib); + + // Get full path of the executable + DosQueryModuleName(ppib->pib_hmte, sizeof(path), path); + + // Replace name part with codecs_dir + strcpy(strrchr(path, '\\') + 1, codecs_dir); + } + + // Convert backslash to slash + _fnslashify(path); + + // Set default codec path + SetCodecPath(path); +} +#endif Index: configure =================================================================== --- configure (revision 30850) +++ configure (working copy) @@ -764,6 +764,7 @@ def_stream_cache="#define CONFIG_STREAM_CACHE 1" def_priority="#undef CONFIG_PRIORITY" def_pthread_cache="#undef PTHREAD_CACHE" +def_set_codec_path="#define CONFIG_SET_CODEC_PATH 0" _need_shmem=yes for ac_option do case "$ac_option" in @@ -7068,6 +7069,7 @@ if ! win32 ; then def_win32_loader='#define WIN32_LOADER 1' _win32_emulation=yes + os2 && def_set_codec_path='#define CONFIG_SET_CODEC_PATH 1' else extra_ldflags="$extra_ldflags -ladvapi32 -lole32" _res_comment="using native windows" @@ -8990,6 +8992,7 @@ $def_qtx_win32 $def_real $def_real_path +$def_set_codec_path $def_win32_loader $def_win32dll #define WIN32_PATH "$_win32codecsdir" Index: get_path.h =================================================================== --- get_path.h (revision 30850) +++ get_path.h (working copy) @@ -24,4 +24,8 @@ char *get_path(const char *filename); void set_path_env(void); +#if CONFIG_SET_CODEC_PATH +void set_codec_path(void); +#endif + #endif /* MPLAYER_GET_PATH_H */ Index: mplayer.c =================================================================== --- mplayer.c (revision 30850) +++ mplayer.c (working copy) @@ -2624,6 +2624,10 @@ set_path_env(); #endif +#if CONFIG_SET_CODEC_PATH + set_codec_path(); +#endif + #ifdef CONFIG_TV stream_tv_defaults.immediate = 1; #endif Index: mencoder.c =================================================================== --- mencoder.c (revision 30850) +++ mencoder.c (working copy) @@ -474,6 +474,10 @@ set_path_env(); #endif +#if CONFIG_SET_CODEC_PATH + set_codec_path(); +#endif + InitTimer(); // check codec.conf