[FFmpeg-devel] [PATCH] Fixes for ffmpeg and editorial typos

Matteo Naccari matteo.naccari at bbc.co.uk
Thu Dec 1 13:54:58 EET 2016


- The libturing.pc file is added in CMAKE_INSTALL_PREFIX/lib/pkgconfig
  and contains some CMAKE variables which get expanded during
  installation
- Fixed some editorial typos and trailing space
- Fixed version numbering in the std output
- Added function to check for binary option as passed when calling the
  codec from FFmpeg
- Modified boost program options so that an option can be repeated
  multiple times and only the last value is used
---
 boost/libs/program_options/src/value_semantic.cpp |  4 +-
 turing/CMakeLists.txt                             | 57 ++++++++++++----------
 turing/GetGitRevisionDescription.cmake            |  1 +
 turing/encode.cpp                                 | 59 ++++++++++++++++++++++-
 turing/libturing.pc.in                            | 11 +++++
 turing/turing.h                                   |  2 +
 6 files changed, 106 insertions(+), 28 deletions(-)
 create mode 100644 turing/libturing.pc.in

diff --git a/boost/libs/program_options/src/value_semantic.cpp b/boost/libs/program_options/src/value_semantic.cpp
index d35d17d..fe129c2 100644
--- a/boost/libs/program_options/src/value_semantic.cpp
+++ b/boost/libs/program_options/src/value_semantic.cpp
@@ -11,6 +11,7 @@
 #include <set>
 
 #include <cctype>
+#include <iostream>
 
 namespace boost { namespace program_options {
 
@@ -204,8 +205,7 @@ namespace boost { namespace program_options {
         void check_first_occurrence(const boost::any& value)
         {
             if (!value.empty())
-                boost::throw_exception(
-                    multiple_occurrences());
+                cerr<<"Warning: multiple values submitted for command line option: "<<endl;
         }
     }
 
diff --git a/turing/CMakeLists.txt b/turing/CMakeLists.txt
index 2d4da04..d8f0c3f 100644
--- a/turing/CMakeLists.txt
+++ b/turing/CMakeLists.txt
@@ -9,11 +9,11 @@ else()
 endif()
 
 configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.h.in 
+    ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.h.in
     ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.h)
 
 include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR} 
+    ${CMAKE_CURRENT_SOURCE_DIR}
     "${CMAKE_CURRENT_SOURCE_DIR}/..")
 
 if (USE_SYSTEM_BOOST)
@@ -93,30 +93,30 @@ set(SEI_HEADERS
     sei/user_data_unregistered.h)
 
 add_library(turing
-    Cabac.cpp 
-    encode.cpp 
-    psnr.cpp 
-    TaskEncodeInput.cpp 
+    Cabac.cpp
+    encode.cpp
+    psnr.cpp
+    TaskEncodeInput.cpp
     decode.cpp
-    Encoder.cpp 
-    Rdoq.cpp 
-    TaskEncodeOutput.cpp 
-    DecodeCtu.cpp 
-    InputQueue.cpp 
-    Reconstruct.cpp 
-    TaskEncodeSubstream.cpp 
-    DecodeRbsp.cpp 
-    ThreadPool.cpp 
+    Encoder.cpp
+    Rdoq.cpp
+    TaskEncodeOutput.cpp
+    DecodeCtu.cpp
+    InputQueue.cpp
+    Reconstruct.cpp
+    TaskEncodeSubstream.cpp
+    DecodeRbsp.cpp
+    ThreadPool.cpp
     md5.c
-    ScalingMatrices.cpp 
-    Picture.cpp 
-    Search.cpp 
-    sao.cpp 
+    ScalingMatrices.cpp
+    Picture.cpp
+    Search.cpp
+    sao.cpp
     signature.cpp
-    ProgressReporter.cpp 
-    TaskDeblock.cpp 
-    testdecode.cpp 
-	TaskSao.cpp 
+    ProgressReporter.cpp
+    TaskDeblock.cpp
+    testdecode.cpp
+    TaskSao.cpp
     Aps.h
     Binarization.h
     BitField.h
@@ -133,7 +133,7 @@ add_library(turing
     DecodedPicture.h
     Dsp.h
     Encoder.h
-	EncSao.h
+    EncSao.h
     EstimateRate.h
     EstimateIntraComplexity.h
     FixedPoint.h
@@ -191,7 +191,7 @@ add_library(turing
     SyntaxRbsp.hpp
     SyntaxSei.h
     TaskDeblock.h
-	TaskSao.h
+    TaskSao.h
     TaskEncodeInput.h
     TaskEncodeOutput.h
     TaskEncodeSubstream.h
@@ -210,6 +210,13 @@ add_executable (turing-exe main.cpp)
 set_target_properties(turing-exe PROPERTIES OUTPUT_NAME turing)
 
 target_link_libraries (turing-exe LINK_PUBLIC turing ${LINK_LIBRARIES})
+if(UNIX)
+	include(FindPkgConfig QUIET)
+	if(PKG_CONFIG_FOUND)
+		configure_file("libturing.pc.in" "libturing.pc" @ONLY)
+		install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libturing.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+	endif()
+endif()
 
 install(TARGETS turing LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
 install(FILES turing.h DESTINATION include)
diff --git a/turing/GetGitRevisionDescription.cmake b/turing/GetGitRevisionDescription.cmake
index 85eae15..a6eae7f 100644
--- a/turing/GetGitRevisionDescription.cmake
+++ b/turing/GetGitRevisionDescription.cmake
@@ -102,6 +102,7 @@ function(git_describe _var)
 	#	message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
 	#endif()
 
+	set(ARGN --always)
 	#message(STATUS "Arguments to execute_process: ${ARGN}")
 
 	execute_process(COMMAND
diff --git a/turing/encode.cpp b/turing/encode.cpp
index d56a6d1..69142a0 100644
--- a/turing/encode.cpp
+++ b/turing/encode.cpp
@@ -35,6 +35,7 @@ For more information, contact us at info @ turingcodec.org.
 #include <fstream>
 #include <memory>
 #include <cstring>
+#include <map>
 
 
 #pragma optimize ("", off)
@@ -241,6 +242,62 @@ const char *gitDescribe()
     return (s[0] >= '0' && s[0] <= '9') ? s : "<unknown>";
 }
 
+int turing_check_binary_option(const char *option)
+{
+    map<string, bool> supportedBinaryOptions; // option name and default value
+
+    supportedBinaryOptions["aq"] = false;
+    supportedBinaryOptions["shot-change"] = false;
+    supportedBinaryOptions["field-coding"] = false;
+    supportedBinaryOptions["wpp"] = true;
+    supportedBinaryOptions["repeat-headers"] = true;
+    supportedBinaryOptions["deblock"] = true;
+    supportedBinaryOptions["sao"] = false;
+    supportedBinaryOptions["strong-intra-smoothing"] = true;
+    supportedBinaryOptions["rqt"] = true;
+    supportedBinaryOptions["amp"] = true;
+    supportedBinaryOptions["smp"] = false;
+    supportedBinaryOptions["rdoq"] = true;
+    supportedBinaryOptions["sdh"] = true;
+    supportedBinaryOptions["tskip"] = true;
+    supportedBinaryOptions["fdm"] = true;
+    supportedBinaryOptions["fdam"] = true;
+    supportedBinaryOptions["ecu"] = true;
+    supportedBinaryOptions["esd"] = true;
+    supportedBinaryOptions["cfm"] = true;
+    supportedBinaryOptions["met"] = true;
+    supportedBinaryOptions["aps"] = true;
+    supportedBinaryOptions["rcudepth"] = true;
+    supportedBinaryOptions["sao-slow-mode"] = false;
+    supportedBinaryOptions["no-parallel-processing"] = true;
+
+    string currentOption(option);
+    int isBinaryOption = 0;
+
+    if(currentOption == "no-parallel-processing")
+    {
+        isBinaryOption = 1;
+    }
+    else
+    {
+        // Strip out any no- prefix for disabling-like options
+        const int idx = currentOption.find("no-", 0);
+        if(idx != string::npos)
+        {
+            const int length = currentOption.length() - 3;
+            currentOption = currentOption.substr(idx+3, length);
+        }
+
+        auto optionPresent = supportedBinaryOptions.find(currentOption);
+        if(optionPresent != supportedBinaryOptions.end())
+        {
+            isBinaryOption = 1;
+        }
+    }
+
+    return isBinaryOption;
+}
+
 
 // Review - no need for Encoder and turing_encoder - merge these two?
 struct turing_encoder
@@ -442,7 +499,7 @@ struct turing_encoder
 
 const char *turing_version()
 {
-    return "1.01";
+    return "1.1";
 }
 
 
diff --git a/turing/libturing.pc.in b/turing/libturing.pc.in
new file mode 100644
index 0000000..83d6de7
--- /dev/null
+++ b/turing/libturing.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: @CMAKE_PROJECT_NAME@
+Description: Turing codec library
+Version: @GIT_DESCRIBE@
+Libs: -L${libdir}  -lturing -lhavoc
+Libs.private: -lstdc++ -L at PROJECT_BINARY_DIR@/boost/libs/program_options/src -L at PROJECT_BINARY_DIR@/boost/libs/chrono/src -L at PROJECT_BINARY_DIR@/boost/libs/timer/src -L at PROJECT_BINARY_DIR@/boost/libs/system/src -L at PROJECT_BINARY_DIR@/boost/libs/filesystem/src -lboost_program_options -lboost_timer -lboost_system -lboost_filesystem -lboost_chrono
+Cflags: -I${includedir}
diff --git a/turing/turing.h b/turing/turing.h
index 13c4e6b..e839412 100644
--- a/turing/turing.h
+++ b/turing/turing.h
@@ -82,6 +82,8 @@ turing_encoder_output const* turing_encode_picture(turing_encoder *encoder, turi
 
 void turing_destroy_encoder(turing_encoder *encoder);
 
+int turing_check_binary_option(const char *option);
+
 
 #ifdef __cplusplus
 }
-- 
1.9.1



More information about the ffmpeg-devel mailing list