[x265] [PATCH] api: add exported strings which describe version and build info

Steve Borho steve at borho.org
Sun Oct 13 00:46:25 CEST 2013


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1381617963 18000
#      Sat Oct 12 17:46:03 2013 -0500
# Node ID 6d5df4858df64af6c7ae727a5455932d7e25dbe7
# Parent  c18a09b9d2d3c7b249701afedd4e09cf2933312d
api: add exported strings which describe version and build info

It seemed more useful for this data to be in the x265 library rather than the
CLI app

diff -r c18a09b9d2d3 -r 6d5df4858df6 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/CMakeLists.txt	Sat Oct 12 17:46:03 2013 -0500
@@ -151,6 +151,7 @@
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
                "${PROJECT_BINARY_DIR}/x265_config.h")
 
+include(version) # determine X265_VERSION and X265_LATEST_TAG
 include_directories(. Lib common encoder "${PROJECT_BINARY_DIR}")
 add_subdirectory(common)
 add_subdirectory(encoder)
@@ -174,7 +175,6 @@
 # MINGW builds static: libx265-static.a shared: libx265.dll + libx265.dll.a
 # *NIX  builds static: libx265.a        shared: libx265.so
 
-include(version) # determine X265_VERSION and X265_LATEST_TAG
 if(X265_LATEST_TAG)
     # shared library is not installed if a tag is not found
     set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG} SOVERSION ${X265_BUILD})
@@ -210,10 +210,9 @@
         set_source_files_properties(compat/msvc/getopt.c PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter")
     endif()
 
-    set_source_files_properties(x265.cpp PROPERTIES COMPILE_FLAGS -DX265_VERSION=${X265_VERSION})
     add_executable(cli ../COPYING ${InputFiles} ${OutputFiles}
-        x265.cpp x265opts.h x265.h
-        compat/msvc/getopt.c compat/msvc/getopt.h)
+                   x265.cpp x265opts.h x265.h
+                   compat/msvc/getopt.c compat/msvc/getopt.h)
     target_link_libraries(cli x265-static ${PLATFORM_LIBS})
     set_target_properties(cli PROPERTIES OUTPUT_NAME x265)
 
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/common/CMakeLists.txt
--- a/source/common/CMakeLists.txt	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/common/CMakeLists.txt	Sat Oct 12 17:46:03 2013 -0500
@@ -217,6 +217,7 @@
         set_source_files_properties(threadpool.cpp reference.cpp wavefront.cpp common.cpp PROPERTIES COMPILE_FLAGS -march=i686)
     endif()
 endif(GCC)
+set_source_files_properties(common.cpp PROPERTIES COMPILE_FLAGS -DX265_VERSION=${X265_VERSION})
 
 enable_language(ASM_YASM)
 add_library(common OBJECT
@@ -234,4 +235,3 @@
     common.cpp common.h
     lowres.cpp lowres.h
     piclist.cpp piclist.h)
-
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/common/common.cpp
--- a/source/common/common.cpp	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/common/common.cpp	Sat Oct 12 17:46:03 2013 -0500
@@ -74,7 +74,6 @@
 {
     if (ptr) free(ptr);
 }
-
 #endif // if _WIN32
 
 void x265_log(x265_param_t *param, int level, const char *fmt, ...)
@@ -423,3 +422,65 @@
     fprintf(stderr, "\n");
     fflush(stderr);
 }
+
+// ====================================================================================================================
+// Platform information
+// ====================================================================================================================
+
+#define XSTR(x) STR(x)
+#define STR(x) #x
+
+#if defined(__clang__)
+#define NVM_COMPILEDBY  "[clang " XSTR(__clang_major__) "." XSTR(__clang_minor__) "." XSTR(__clang_patchlevel__) "]"
+#ifdef __IA64__
+#define NVM_ONARCH    "[on 64-bit] "
+#else
+#define NVM_ONARCH    "[on 32-bit] "
+#endif
+#endif
+
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
+#define NVM_COMPILEDBY  "[GCC " XSTR(__GNUC__) "." XSTR(__GNUC_MINOR__) "." XSTR(__GNUC_PATCHLEVEL__) "]"
+#ifdef __IA64__
+#define NVM_ONARCH    "[on 64-bit] "
+#else
+#define NVM_ONARCH    "[on 32-bit] "
+#endif
+#endif
+
+#ifdef __INTEL_COMPILER
+#define NVM_COMPILEDBY  "[ICC " XSTR(__INTEL_COMPILER) "]"
+#elif  _MSC_VER
+#define NVM_COMPILEDBY  "[MSVC " XSTR(_MSC_VER) "]"
+#endif
+
+#ifndef NVM_COMPILEDBY
+#define NVM_COMPILEDBY "[Unk-CXX]"
+#endif
+
+#ifdef _WIN32
+#define NVM_ONOS        "[Windows]"
+#elif  __linux
+#define NVM_ONOS        "[Linux]"
+#elif  __CYGWIN__
+#define NVM_ONOS        "[Cygwin]"
+#elif __APPLE__
+#define NVM_ONOS        "[Mac OS X]"
+#else
+#define NVM_ONOS "[Unk-OS]"
+#endif
+
+#if X86_64
+#define NVM_BITS          "[64 bit] "
+#else
+#define NVM_BITS          "[32 bit] "
+#endif
+
+#if HIGH_BIT_DEPTH
+#define BITDEPTH "16bpp"
+#else
+#define BITDEPTH "8bpp"
+#endif
+
+const char *x265_version_str = XSTR(X265_VERSION);
+const char *x265_build_info_str = NVM_ONOS NVM_COMPILEDBY NVM_BITS BITDEPTH;
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/common/common.h
--- a/source/common/common.h	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/common/common.h	Sat Oct 12 17:46:03 2013 -0500
@@ -29,52 +29,6 @@
 
 #define CU_STAT_LOGFILE 0
 
-// ====================================================================================================================
-// Platform information
-// ====================================================================================================================
-
-#if defined(__clang__)
-#define NVM_COMPILEDBY  "[clang %d.%d.%d]", __clang_major__, __clang_minor__, __clang_patchlevel__
-#ifdef __IA64__
-#define NVM_ONARCH    "[on 64-bit] "
-#else
-#define NVM_ONARCH    "[on 32-bit] "
-#endif
-#endif
-
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
-#define NVM_COMPILEDBY  "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
-#ifdef __IA64__
-#define NVM_ONARCH    "[on 64-bit] "
-#else
-#define NVM_ONARCH    "[on 32-bit] "
-#endif
-#endif
-
-#ifdef __INTEL_COMPILER
-#define NVM_COMPILEDBY  "[ICC %d]", __INTEL_COMPILER
-#elif  _MSC_VER
-#define NVM_COMPILEDBY  "[VS %d]", _MSC_VER
-#endif
-
-#ifndef NVM_COMPILEDBY
-#define NVM_COMPILEDBY "[Unk-CXX]"
-#endif
-
-#ifdef _WIN32
-#define NVM_ONOS        "[Windows]"
-#elif  __linux
-#define NVM_ONOS        "[Linux]"
-#elif  __CYGWIN__
-#define NVM_ONOS        "[Cygwin]"
-#elif __APPLE__
-#define NVM_ONOS        "[Mac OS X]"
-#else
-#define NVM_ONOS "[Unk-OS]"
-#endif
-
-#define NVM_BITS          "[%d bit] ", (sizeof(void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S
-
 #define X265_MIN(a, b) ((a) < (b) ? (a) : (b))
 #define X265_MAX(a, b) ((a) > (b) ? (a) : (b))
 #define COPY1_IF_LT(x, y) if ((y) < (x)) (x) = (y);
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/x265.cpp
--- a/source/x265.cpp	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/x265.cpp	Sat Oct 12 17:46:03 2013 -0500
@@ -255,19 +255,8 @@
 
     void print_version(x265_param_t *param)
     {
-#define XSTR(x) STR(x)
-#define STR(x) #x
-        fprintf(stderr, "x265 [info]: HEVC encoder version %s\n", XSTR(X265_VERSION));
-        fprintf(stderr, "x265 [info]: build info ");
-        fprintf(stderr, NVM_ONOS);
-        fprintf(stderr, NVM_COMPILEDBY);
-        fprintf(stderr, NVM_BITS);
-#if HIGH_BIT_DEPTH
-        fprintf(stderr, "16bpp");
-#else
-        fprintf(stderr, "8bpp");
-#endif
-        fprintf(stderr, "\n");
+        fprintf(stderr, "x265 [info]: HEVC encoder version %s\n", x265_version_str);
+        fprintf(stderr, "x265 [info]: build info %s\n", x265_build_info_str);
         x265_setup_primitives(param, 0);
     }
 
@@ -626,7 +615,7 @@
         char buffer[128];
         strftime(buffer, 128, "%c", timeinfo);
         fprintf(cliopt.csvfp, ", %s, %.2f, %.2f, %.2f, %.2f, %s\n",
-            buffer, elapsed, outFrameCount / elapsed, bitrate, stats.globalPsnr, XSTR(X265_VERSION));
+            buffer, elapsed, outFrameCount / elapsed, bitrate, stats.globalPsnr, x265_version_str);
     }
 
     cliopt.destroy();
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/x265.def.in
--- a/source/x265.def.in	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/x265.def.in	Sat Oct 12 17:46:03 2013 -0500
@@ -5,6 +5,8 @@
 x265_picture_init
 x265_param_apply_profile
 x265_max_bit_depth
+x265_version_str
+x265_build_info_str
 x265_encoder_headers
 x265_encoder_encode
 x265_encoder_get_stats
diff -r c18a09b9d2d3 -r 6d5df4858df6 source/x265.h
--- a/source/x265.h	Sat Oct 12 16:30:00 2013 -0500
+++ b/source/x265.h	Sat Oct 12 17:46:03 2013 -0500
@@ -341,6 +341,14 @@
  *      for all encoders allocated in the same process. */
 extern const int x265_max_bit_depth;
 
+/* x265_version_str:
+ *      A static string containing the version of this compiled x265 library */
+extern const char *x265_version_str;
+
+/* x265_build_info:
+ *      A static string describing the compiler and target architecture */
+extern const char *x265_build_info_str;
+
 /* Force a link error in the case of linking against an incompatible API version.
  * Glue #defines exist to force correct macro expansion; the final output of the macro
  * is x265_encoder_open_##X264_BUILD (for purposes of dlopen). */


More information about the x265-devel mailing list