[x265] CLI: allow Unicode filenames (Windows) for 'scaling-list', 'lambda-file' and 'analysis-file'

Mateusz Brzostek mateusz at msystem.waw.pl
Sat Feb 11 16:44:17 CET 2017


# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1486827593 -3600
#      Sat Feb 11 16:39:53 2017 +0100
# Node ID b0942b7ef3b4c6085e70aa1cc8ab3686118ed297
# Parent  fe2f2dd96f8cf9fb88a720a96aab4ff5b21768df
CLI: allow Unicode filenames (Windows) for 'scaling-list', 'lambda-file' and 'analysis-file'

diff -r fe2f2dd96f8c -r b0942b7ef3b4 source/common/param.cpp
--- a/source/common/param.cpp    Fri Feb 10 14:23:32 2017 +0530
+++ b/source/common/param.cpp    Sat Feb 11 16:39:53 2017 +0100
@@ -1657,10 +1657,10 @@
     if (!param->rc.lambdaFileName)
         return false;
 
-    FILE *lfn = fopen(param->rc.lambdaFileName, "r");
+    FILE *lfn = x265_fopen(param->rc.lambdaFileName, "r");
     if (!lfn)
     {
-        x265_log(param, X265_LOG_ERROR, "unable to read lambda file <%s>\n", param->rc.lambdaFileName);
+        x265_log_file(param, X265_LOG_ERROR, "unable to read lambda file <%s>\n", param->rc.lambdaFileName);
         return true;
     }
 
diff -r fe2f2dd96f8c -r b0942b7ef3b4 source/common/scalinglist.cpp
--- a/source/common/scalinglist.cpp    Fri Feb 10 14:23:32 2017 +0530
+++ b/source/common/scalinglist.cpp    Sat Feb 11 16:39:53 2017 +0100
@@ -245,10 +245,10 @@
 
 bool ScalingList::parseScalingList(const char* filename)
 {
-    FILE *fp = fopen(filename, "r");
+    FILE *fp = x265_fopen(filename, "r");
     if (!fp)
     {
-        x265_log(NULL, X265_LOG_ERROR, "can't open scaling list file %s\n", filename);
+        x265_log_file(NULL, X265_LOG_ERROR, "can't open scaling list file %s\n", filename);
         return true;
     }
 
@@ -268,7 +268,7 @@
                 char *ret = fgets(line, 1024, fp);
                 if (!ret || (!strstr(line, MatrixType[sizeIdc][listIdc]) && feof(fp)))
                 {
-                    x265_log(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
+                    x265_log_file(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
                     return true;
                 }
             }
@@ -279,7 +279,7 @@
                 int data;
                 if (fscanf(fp, "%d,", &data) != 1)
                 {
-                    x265_log(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
+                    x265_log_file(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
                     return true;
                 }
                 src[i] = data;
@@ -295,7 +295,7 @@
                     char *ret = fgets(line, 1024, fp);
                     if (!ret || (!strstr(line, MatrixType_DC[sizeIdc][listIdc]) && feof(fp)))
                     {
-                        x265_log(NULL, X265_LOG_ERROR, "can't read DC from %s\n", filename);
+                        x265_log_file(NULL, X265_LOG_ERROR, "can't read DC from %s\n", filename);
                         return true;
                     }
                 }
@@ -304,7 +304,7 @@
                 int data;
                 if (fscanf(fp, "%d,", &data) != 1)
                 {
-                    x265_log(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
+                    x265_log_file(NULL, X265_LOG_ERROR, "can't read matrix from %s\n", filename);
                     return true;
                 }
 
diff -r fe2f2dd96f8c -r b0942b7ef3b4 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp    Fri Feb 10 14:23:32 2017 +0530
+++ b/source/encoder/encoder.cpp    Sat Feb 11 16:39:53 2017 +0100
@@ -345,10 +345,10 @@
         if (!name)
             name = defaultAnalysisFileName;
         const char* mode = m_param->analysisMode == X265_ANALYSIS_LOAD ? "rb" : "wb";
-        m_analysisFile = fopen(name, mode);
+        m_analysisFile = x265_fopen(name, mode);
         if (!m_analysisFile)
         {
-            x265_log(NULL, X265_LOG_ERROR, "Analysis load/save: failed to open file %s\n", name);
+            x265_log_file(NULL, X265_LOG_ERROR, "Analysis load/save: failed to open file %s\n", name);
             m_aborted = true;
         }
     }
@@ -365,21 +365,21 @@
                 m_aborted = true;
             else
             {
-                m_analysisFileOut = fopen(temp, "wb");
+                m_analysisFileOut = x265_fopen(temp, "wb");
                 X265_FREE(temp);
             }
             if (!m_analysisFileOut)
             {
-                x265_log(NULL, X265_LOG_ERROR, "Analysis 2 pass: failed to open file %s\n", temp);
+                x265_log_file(NULL, X265_LOG_ERROR, "Analysis 2 pass: failed to open file %s.temp\n", name);
                 m_aborted = true;
             }
         }
         if (m_param->rc.bStatRead)
         {
-            m_analysisFileIn = fopen(name, "rb");
+            m_analysisFileIn = x265_fopen(name, "rb");
             if (!m_analysisFileIn)
             {
-                x265_log(NULL, X265_LOG_ERROR, "Analysis 2 pass: failed to open file %s\n", name);
+                x265_log_file(NULL, X265_LOG_ERROR, "Analysis 2 pass: failed to open file %s\n", name);
                 m_aborted = true;
             }
         }
@@ -486,7 +486,7 @@
         }
         if (bError)
         {
-            x265_log(m_param, X265_LOG_ERROR, "failed to rename analysis stats file to \"%s\"\n", name);
+            x265_log_file(m_param, X265_LOG_ERROR, "failed to rename analysis stats file to \"%s\"\n", name);
         }
         X265_FREE(temp);
      }



More information about the x265-devel mailing list