[FFmpeg-devel] [PATCH 08/11] Make get_preset_file() look for files prefixed with program_name when all else fails.

Stefano Sabatini stefano.sabatini-lala
Fri Nov 12 19:31:46 CET 2010


---
 cmdutils.c |   12 ++++++++++++
 cmdutils.h |    3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index cdcea35..f4d0e54 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -776,6 +776,13 @@ FILE *get_preset_file(char *filename, size_t filename_size,
         av_strlcpy(filename, preset_name, filename_size);
         f = fopen(filename, "r");
     } else {
+        char program_name_lc[32];
+
+        for (i = 0; program_name[i] && i < sizeof(program_name_lc) -1; i++)
+            program_name_lc[i] = program_name[i] >= 'A' && program_name[i] <= 'Z' ?
+                program_name[i] + 'a' - 'A' : program_name[i];
+        program_name_lc[i] = 0;
+
         for (i = 0; i < 3 && !f; i++) {
             if (!base[i])
                 continue;
@@ -786,6 +793,11 @@ FILE *get_preset_file(char *filename, size_t filename_size,
                          "%s%s/%s-%s.ffpreset", base[i],  i != 1 ? "" : "/.ffmpeg", codec_name, preset_name);
                 f = fopen(filename, "r");
             }
+            if (!f) {
+                snprintf(filename, filename_size,
+                         "%s%s/%s-%s.ffpreset", base[i],  i != 1 ? "" : "/.ffmpeg", program_name_lc, preset_name);
+                f = fopen(filename, "r");
+            }
         }
     }
 
diff --git a/cmdutils.h b/cmdutils.h
index 69cfe2f..04189c8 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -273,6 +273,9 @@ int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts);
  * at configuration time, 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.
+ * If no such file is found is defined, then search for a file named
+ * program_name-preset_name.ffpreset in the above-mentioned
+ * directories.
  *
  * @param filename buffer where the name of the found filename is written
  * @param filename_size size in bytes of the filename buffer
-- 
1.7.1




More information about the ffmpeg-devel mailing list