From 60bb3e298549d83fa62a7d140e0fce2856048811 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 31 Aug 2018 22:13:45 +0200 Subject: [PATCH] Support x264 >= 153. Newer versions of x264 support multiple bit depths in one library, so we don't need to load dynamically anymore. (On the other hand, there's a new parameter we need to set.) Keep the old code around for the time being, though, since we'd like to keep supporting stretch for now. --- x264_dynamic.cpp | 9 ++++++++- x264_encoder.cpp | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/x264_dynamic.cpp b/x264_dynamic.cpp index 6aa649e..f8b63ce 100644 --- a/x264_dynamic.cpp +++ b/x264_dynamic.cpp @@ -14,7 +14,14 @@ using namespace std; X264Dynamic load_x264_for_bit_depth(unsigned depth) { X264Dynamic dyn; - if (unsigned(x264_bit_depth) >= depth) { +#if defined(X264_BIT_DEPTH) && X264_BIT_DEPTH == 0 + bool suitable = true; // x264 compiled to support all bit depths. +#elif defined(X264_BIT_DEPTH) + bool suitable = X264_BIT_DEPTH >= depth; +#else + bool suitable = unsigned(x264_bit_depth) >= depth; +#endif + if (suitable) { // Just use the one we are linked to. dyn.handle = nullptr; dyn.x264_encoder_close = x264_encoder_close; diff --git a/x264_encoder.cpp b/x264_encoder.cpp index 66c0634..8463d1b 100644 --- a/x264_encoder.cpp +++ b/x264_encoder.cpp @@ -150,6 +150,9 @@ void X264Encoder::init_x264() if (global_flags.x264_speedcontrol) { param.i_frame_reference = 16; // Because speedcontrol is never allowed to change this above what we set at start. } +#if X264_BUILD >= 153 + param.i_bitdepth = global_flags.x264_bit_depth; +#endif // NOTE: These should be in sync with the ones in quicksync_encoder.cpp (sps_rbsp()). param.vui.i_vidformat = 5; // Unspecified. -- 2.39.2