[vlc-devel] [PATCH 1/2] x264.c: add x26410b-module for 10-bit encoding alongside normal 8-bit, supports only static linking

Ilkka Ollakka ileoo at videolan.org
Tue Feb 21 11:43:10 CET 2012


---
 configure.ac             |   56 ++++++++++++++++++++++++++++++++++++++++++++-
 modules/codec/Modules.am |    1 +
 modules/codec/x264.c     |   37 ++++++++++++++++++++++++++++-
 3 files changed, 90 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1c8223a..b83bf63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,7 +152,7 @@ case "${host_os}" in
     LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names ${ARCH_flag}"
     VLC_ADD_LIBS([mkv mp4 motion], [-Wl,-framework,IOKit,-framework,CoreFoundation])
     VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup])
-    VLC_ADD_LIBS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264],[-Wl,-read_only_relocs,suppress])
+    VLC_ADD_LIBS([avcodec avformat access_avio swscale postproc i420_rgb_mmx x264 x26410b],[-Wl,-read_only_relocs,suppress])
     VLC_ADD_CFLAGS([motion],[-fconstant-cfstrings])
     VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation])
 
@@ -618,7 +618,7 @@ AC_CHECK_FUNC(getopt_long,, [
 AC_SUBST(GNUGETOPT_LIBS)
 
 AC_CHECK_LIB(m,cos,[
-  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mod mpc dmo mp4 quicktime realvideo qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x264 hqdn3d anaglyph],[-lm])
+  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mod mpc dmo mp4 quicktime realvideo qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph],[-lm])
   LIBM="-lm"
 ], [
   LIBM=""
@@ -2769,6 +2769,58 @@ fi
 AM_CONDITIONAL(BUILD_OSDMENU, [test "${enable_png}" != "no"])
 
 dnl
+dnl H264 encoder plugin (10-bit lib264)
+dnl
+AC_ARG_ENABLE(x26410b,
+  [  --enable-x26410b           H264 10-bit encoding support with static libx264 (default disabled)])
+if test "${enable_x26410b}" != "no"; then
+AC_ARG_WITH(x26410b-tree,
+  [ --with-x26410b-tree=PATH      H264 10-bit encoding module with libx264 (static linking)],[],[])
+  if test "${with_x26410b_tree}" != "no" -a -n "${with_x26410b_tree}"
+  then
+    real_x26410b_tree="̧`cd ${with_x26410b_tree} 2>/dev/null && pwd`"
+    if test -z "${real_x26410b_tree}"
+    then
+      AC_MSG_RESULT(no)
+      AC_MSG_ERROR([${with_x26410b_tree} directory does not exist])
+    fi
+    AC_MSG_CHECKING(for x264.h in ${real_x26410b_tree})
+    if test -f ${with_x26410b_tree}/x264_config.h
+    then
+      AC_MSG_RESULT(yes)
+      AC_MSG_CHECKING(for 10-bit build of x264)
+      if grep -q "BIT_DEPTH.*10"  ${with_x26410b_tree}/x264_config.h ;then
+        AC_MSG_RESULT(yes)
+        VLC_ADD_PLUGIN([x26410b])
+        VLC_ADD_CFLAGS([x26410b],[-I${with_x26410b_tree}])
+        VLC_ADD_LIBS([x26410b],[-L${with_x26410b_tree} -lm -lpthread -lx264])
+      else
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR([${with_x26410b_tree} isnt build 10-bit])
+      fi
+    else
+      AC_MSG_RESULT(no)
+      AC_MSG_ERROR([${with_x26410b_tree} doesnt have x264_config.h])
+    fi
+  else
+    PKG_CHECK_MODULES(X26410B, x26410b, [
+        VLC_ADD_PLUGIN([x26410b])
+        VLC_ADD_LDFLAGS([x26410b],[${X26410B_LIBS}])
+        AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
+          VLC_ADD_LIBS([x26410b],[-Wl,-Bsymbolic])
+        ])
+        VLC_ADD_CFLAGS([x26410b],[${X26410B_CFLAGS}])
+        if echo ${X26410B_LIBS} |grep -q 'pthreadGC2'; then
+          VLC_ADD_CFLAGS([x26410b], [-DPTW32_STATIC_LIB])
+        fi
+    ], [
+        AC_MSG_ERROR([x26410b module doesn't work without staticly compiled libx264.a])
+    ])
+  fi
+fi
+
+
+dnl
 dnl H264 encoder plugin (using libx264)
 dnl
 AC_ARG_ENABLE(x264,
diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am
index c428079..bb6008a 100644
--- a/modules/codec/Modules.am
+++ b/modules/codec/Modules.am
@@ -18,6 +18,7 @@ SOURCES_dvbsub = dvbsub.c
 SOURCES_telx = telx.c
 SOURCES_mash = mash.cpp
 SOURCES_x264 = x264.c
+SOURCES_x26410b = x264.c
 SOURCES_twolame = twolame.c
 SOURCES_dirac = dirac.c
 SOURCES_png = png.c
diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index 006c9d1..4a0097a 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -44,7 +44,11 @@
 
 #include <assert.h>
 
+#ifdef MODULE_NAME_IS_x26410b
+#define SOUT_CFG_PREFIX "sout-x26410b-"
+#else
 #define SOUT_CFG_PREFIX "sout-x264-"
+#endif
 
 /*****************************************************************************
  * Module descriptor
@@ -428,8 +432,13 @@ static const char *const direct_pred_list_text[] =
   { N_("none"), N_("spatial"), N_("temporal"), N_("auto") };
 
 vlc_module_begin ()
+#ifdef MODULE_NAME_IS_x26410b
+    set_description( N_("H.264/MPEG4 AVC encoder (x264 10-bit)"))
+    set_capability( "encoder", 0 )
+#else
     set_description( N_("H.264/MPEG4 AVC encoder (x264)"))
     set_capability( "encoder", 200 )
+#endif
     set_callbacks( Open, Close )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_VCODEC )
@@ -787,22 +796,46 @@ static int  Open ( vlc_object_t *p_this )
     if( psz_profile )
     {
         const int mask = x264_bit_depth > 8 ? X264_CSP_HIGH_DEPTH : 0;
+
+#ifdef MODULE_NAME_IS_x26410b
+        if( mask == 0)
+        {
+            msg_Err( p_enc, "Only high bith depth encoding supported, bit depth:%d", x264_bit_depth);
+            return VLC_EGENERIC;
+        }
+#endif
+
         if( !strcmp( psz_profile, "high10" ) )
         {
             p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I420_10L : VLC_CODEC_I420;
             p_sys->i_colorspace = X264_CSP_I420 | mask;
         }
-        if( !strcmp( psz_profile, "high422" ) )
+        else if( !strcmp( psz_profile, "high422" ) )
         {
             p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I422_10L : VLC_CODEC_I422;
             p_sys->i_colorspace = X264_CSP_I422 | mask;
         }
-        if( !strcmp( psz_profile, "high444" ) )
+        else if( !strcmp( psz_profile, "high444" ) )
         {
             p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I444_10L : VLC_CODEC_I444;
             p_sys->i_colorspace = X264_CSP_I444 | mask;
         }
+#ifdef MODULE_NAME_IS_x26410b
+        else
+        {
+            msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
+            return VLC_EGENERIC;
+        }
+
+#endif
     }
+#ifdef MODULE_NAME_IS_x26410b
+    else
+    {
+            msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
+            return VLC_EGENERIC;
+    }
+#endif
     free( psz_profile );
 #endif //X264_BUILD
 
-- 
1.7.9




More information about the vlc-devel mailing list