[FFmpeg-cvslog] preset dir for win32

Gianluigi Tiesi git at videolan.org
Sat May 21 03:44:36 CEST 2011


ffmpeg | branch: master | Gianluigi Tiesi <mplayer at netfarm.it> | Sat May 21 03:36:26 2011 +0200| [1b30e4f5865260323da5232174fc68d6cc283f45] | committer: Michael Niedermayer

preset dir for win32

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b30e4f5865260323da5232174fc68d6cc283f45
---

 cmdutils.c      |   17 +++++++++++++++++
 cmdutils.h      |    3 ++-
 doc/ffmpeg.texi |    1 +
 3 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 5a0c8f3..8265fbc 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -849,6 +849,23 @@ FILE *get_preset_file(char *filename, size_t filename_size,
         av_strlcpy(filename, preset_name, filename_size);
         f = fopen(filename, "r");
     } else {
+#ifdef _WIN32
+        char datadir[MAX_PATH], *ls;
+        base[2] = NULL;
+
+        if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
+        {
+            for (ls = datadir; ls < datadir + strlen(datadir); ls++)
+                if (*ls == '\\') *ls = '/';
+
+            if (ls = strrchr(datadir, '/'))
+            {
+                *ls = 0;
+                strncat(datadir, "/ffpresets",  sizeof(datadir) - 1 - strlen(datadir));
+                base[2] = datadir;
+            }
+        }
+#endif
         for (i = 0; i < 3 && !f; i++) {
             if (!base[i])
                 continue;
diff --git a/cmdutils.h b/cmdutils.h
index 5a93146..9e5827f 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -243,7 +243,8 @@ int read_file(const char *filename, char **bufptr, size_t *size);
  * If is_path is non-zero, look for the file in the path preset_name.
  * Otherwise search for a file named arg.ffpreset in the directories
  * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
- * at configuration time, in that order. If no such file is found and
+ * at configuration time or in a "ffpresets" folder along the executable
+ * on win32, in that order. If no such file is found and
  * codec_name is defined, then search for a file named
  * codec_name-preset_name.ffpreset in the above-mentioned directories.
  *
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 77fde18..fe9e9a9 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -816,6 +816,7 @@ following rules:
 First ffmpeg searches for a file named @var{arg}.ffpreset in the
 directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
 the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
+or in a @file{ffpresets} folder along the executable on win32,
 in that order. For example, if the argument is @code{libx264-max}, it will
 search for the file @file{libx264-max.ffpreset}.
 



More information about the ffmpeg-cvslog mailing list