[x264-devel] [PATCH 28/32] x264cli: Duplicate threaded input module

Vittorio Giovara vittorio.giovara at gmail.com
Fri Jan 20 15:20:53 CET 2017


Unfortunately this input module inherits a common.h dependency
(input/frame -> common/threadpool -> common/frame -> common/common)
which is extremely complicated to address.

Instead duplicate this module and select the correct one at run time.
---
 Makefile       | 2 +-
 input/input.h  | 3 ++-
 input/thread.c | 3 +++
 x264.c         | 1 +
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 07da1b4..1a74b86 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ SRCCLI += input/avs.c
 endif
 
 ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
-SRCCLI += input/thread.c
+SRCCLIBD += input/thread.c
 SRCS   += common/threadpool.c
 endif
 
diff --git a/input/input.h b/input/input.h
index 49b3f67..f06aba0 100644
--- a/input/input.h
+++ b/input/input.h
@@ -107,7 +107,8 @@ typedef struct
 extern const cli_input_t raw_input;
 extern const cli_input_t y4m_input;
 extern const cli_input_t avs_input;
-extern const cli_input_t thread_input;
+extern const cli_input_t thread_8_input;
+extern const cli_input_t thread_10_input;
 extern const cli_input_t lavf_input;
 extern const cli_input_t ffms_input;
 extern const cli_input_t timecode_input;
diff --git a/input/thread.c b/input/thread.c
index 79c93a4..379e978 100644
--- a/input/thread.c
+++ b/input/thread.c
@@ -25,9 +25,12 @@
  *****************************************************************************/
 
 #include "input.h"
+#include "common/bitdepth.h"
 #include "common/threadpool.h"
 #include "common/mathematics.h"
 
+#define thread_input x264_glue(thread_, BIT_DEPTH, _input)
+
 typedef struct
 {
     cli_input_t input;
diff --git a/x264.c b/x264.c
index 15c7efb..b0c312b 100644
--- a/x264.c
+++ b/x264.c
@@ -1635,6 +1635,7 @@ generic_option:
 
     /* init threaded input while the information about the input video is unaltered by filtering */
 #if HAVE_THREAD
+    cli_input_t thread_input = param->i_bitdepth == 8 ? thread_8_input : thread_10_input;
     if( info.thread_safe && (b_thread_input || param->i_threads > 1
         || (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1)) )
     {
-- 
2.10.0



More information about the x264-devel mailing list