[vlc-commits] x262: add new x262 MPEG-2 encoding module based on x262
Ilkka Ollakka
git at videolan.org
Fri Sep 13 16:36:57 CEST 2013
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Jul 7 11:24:41 2013 +0300| [6310a57c607bc44a0cc9657dafc6628027461cc0] | committer: Ilkka Ollakka
x262: add new x262 MPEG-2 encoding module based on x262
This relies contrib version of x262 that gives x262.h and all. Otherwise
it seems to be pretty hard to have x264/x26410b/x262 in the same time.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6310a57c607bc44a0cc9657dafc6628027461cc0
---
configure.ac | 50 ++++++++++++++++++++++++++++++++++++++++++++--
modules/codec/Modules.am | 1 +
modules/codec/x264.c | 50 +++++++++++++++++++++++++++++++++++++---------
3 files changed, 90 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index a518f56..b52c322 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,7 +156,7 @@ case "${host_os}" in
LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names ${ARCH_flag}"
VLC_ADD_LIBS([motion rotate], [-Wl,-framework,IOKit,-framework,CoreFoundation])
VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup,-framework,AppKit])
- VLC_ADD_LIBS([avcodec access_avio swscale postproc i420_rgb_mmx x264 x26410b],[-Wl,-read_only_relocs,suppress])
+ VLC_ADD_LIBS([avcodec access_avio swscale postproc i420_rgb_mmx x262 x264 x26410b],[-Wl,-read_only_relocs,suppress])
VLC_ADD_CFLAGS([motion rotate],[-fconstant-cfstrings])
VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation,-framework,SystemConfiguration])
@@ -655,7 +655,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 rotate noise grain scene kate lua chorus_flanger freetype avcodec access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a audiobargraph_v speex opus mono colorthres extract ball access_imem hotkeys mosaic gaussianblur x26410b hqdn3d anaglyph oldrc ncurses oldmovie glspectrum],[-lm])
+ VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom rotate noise grain scene kate lua chorus_flanger freetype avcodec access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a audiobargraph_v speex opus mono colorthres extract ball access_imem hotkeys mosaic gaussianblur x262 x26410b hqdn3d anaglyph oldrc ncurses oldmovie glspectrum],[-lm])
LIBM="-lm"
], [
LIBM=""
@@ -2727,6 +2727,52 @@ AC_CHECK_HEADERS(png.h, [
])
dnl
+dnl H262 encoder plugin (lib262)
+dnl
+AC_ARG_ENABLE(x262,
+ [ --enable-x262 H262 encoding support with static libx262 (default disabled)])
+if test "${enable_x262}" != "no"; then
+AC_ARG_WITH(x262-tree,
+ [ --with-x262-tree=PATH H262 encoding module with libx262 (static linking)],[],[])
+ if test "${with_x262_tree}" != "no" -a -n "${with_x262_tree}"
+ then
+ real_x262_tree="̧`cd ${with_x262_tree} 2>/dev/null && pwd`"
+ if test -z "${real_x262_tree}"
+ then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([${with_x262_tree} directory does not exist])
+ fi
+ AC_MSG_CHECKING(for x262.h in ${real_x262_tree})
+ if test -f ${with_x262_tree}/x262_config.h
+ then
+ VLC_ADD_PLUGIN([x262])
+ VLC_ADD_CFLAGS([x262],[-I${with_x262_tree}])
+ VLC_ADD_LIBS([x262],[-L${with_x262_tree} -lm -lpthread -lx262])
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([${with_x262_tree} doesnt have x262_config.h])
+ fi
+ else
+ PKG_CHECK_MODULES(X262, x262, [
+ VLC_ADD_PLUGIN([x262])
+ VLC_ADD_LDFLAGS([x262],[${X262_LIBS}])
+ AS_IF([test "${ac_cv_ld_bsymbolic}" != "no"], [
+ VLC_ADD_LIBS([x262],[-Wl,-Bsymbolic])
+ ])
+ VLC_ADD_CFLAGS([x262],[${X262_CFLAGS}])
+ if echo ${X262_LIBS} |grep -q 'pthreadGC2'; then
+ VLC_ADD_CFLAGS([x262], [-DPTW32_STATIC_LIB])
+ fi
+ ], [
+ if test "${enable_x262}" = "yes"; then
+ AC_MSG_ERROR([x262 module doesn't work without staticly compiled libx262.a])
+ fi
+ ])
+ fi
+fi
+
+
+dnl
dnl H264 encoder plugin (10-bit lib264)
dnl
AC_ARG_ENABLE(x26410b,
diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am
index 0e46b7b..a0b330f 100644
--- a/modules/codec/Modules.am
+++ b/modules/codec/Modules.am
@@ -34,6 +34,7 @@ SOURCES_dvbsub = dvbsub.c
SOURCES_telx = telx.c
SOURCES_mash = mash.cpp
SOURCES_x264 = x264.c
+SOURCES_x262 = x264.c
SOURCES_x26410b = x264.c
SOURCES_twolame = twolame.c
SOURCES_dirac = dirac.c
diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index 09a9304..a5b7a32 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -40,13 +40,21 @@
#ifdef PTW32_STATIC_LIB
#include <pthread.h>
#endif
+#ifdef MODULE_NAME_IS_x262
+#include <x262.h>
+#else
#include <x264.h>
+#endif
#include <assert.h>
#ifdef MODULE_NAME_IS_x26410b
#define SOUT_CFG_PREFIX "sout-x26410b-"
-#else
+#endif
+#ifdef MODULE_NAME_IS_x262
+#define SOUT_CFG_PREFIX "sout-x262-"
+#endif
+#ifdef MODULE_NAME_IS_x264
#define SOUT_CFG_PREFIX "sout-x264-"
#endif
@@ -442,7 +450,12 @@ vlc_module_begin ()
#ifdef MODULE_NAME_IS_x26410b
set_description( N_("H.264/MPEG-4 Part 10/AVC encoder (x264 10-bit)"))
set_capability( "encoder", 0 )
-#else
+#endif
+#ifdef MODULE_NAME_IS_x262
+ set_description( N_("H.262/MPEG-2 encoder (x262)"))
+ set_capability( "encoder", 0 )
+#endif
+#ifdef MODULE_NAME_IS_x264
set_description( N_("H.264/MPEG-4 Part 10/AVC encoder (x264)"))
set_capability( "encoder", 200 )
#endif
@@ -799,18 +812,30 @@ static int Open ( vlc_object_t *p_this )
int i, i_nal;
bool fullrange = false;
+#ifdef MODULE_NAME_IS_x262
+ if( p_enc->fmt_out.i_codec != VLC_CODEC_MP2V &&
+#else
if( p_enc->fmt_out.i_codec != VLC_CODEC_H264 &&
+#endif
!p_enc->b_force )
{
return VLC_EGENERIC;
}
/* X264_POINTVER or X264_VERSION are not available */
+#ifdef MODULE_NAME_IS_x262
+ msg_Dbg ( p_enc, "version x262 0.%d.X", X264_BUILD );
+#else
msg_Dbg ( p_enc, "version x264 0.%d.X", X264_BUILD );
+#endif
config_ChainParse( p_enc, SOUT_CFG_PREFIX, ppsz_sout_options, p_enc->p_cfg );
p_enc->fmt_out.i_cat = VIDEO_ES;
+#ifdef MODULE_NAME_IS_x262
+ p_enc->fmt_out.i_codec = VLC_CODEC_MP2V;
+#else
p_enc->fmt_out.i_codec = VLC_CODEC_H264;
+#endif
p_enc->p_sys = p_sys = malloc( sizeof( encoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
@@ -824,13 +849,14 @@ static int Open ( vlc_object_t *p_this )
{
const int mask = x264_bit_depth > 8 ? X264_CSP_HIGH_DEPTH : 0;
-#ifdef MODULE_NAME_IS_x26410b
+
+# 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
+# endif
if( !strcmp( psz_profile, "high10" ) )
{
@@ -847,22 +873,22 @@ static int Open ( vlc_object_t *p_this )
p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I444_10L : fullrange ? VLC_CODEC_J444 : VLC_CODEC_I444;
p_sys->i_colorspace = X264_CSP_I444 | mask;
}
-#ifdef MODULE_NAME_IS_x26410b
+# ifdef MODULE_NAME_IS_x26410b
else
{
msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
return VLC_EGENERIC;
}
-#endif
+# endif
}
-#ifdef MODULE_NAME_IS_x26410b
+# ifdef MODULE_NAME_IS_x26410b
else
{
msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
return VLC_EGENERIC;
}
-#endif
+# endif
free( psz_profile );
#endif //X264_BUILD
@@ -873,7 +899,6 @@ static int Open ( vlc_object_t *p_this )
p_sys->i_sei_size = 0;
p_sys->p_sei = NULL;
- x264_param_default( &p_sys->param );
char *psz_preset = var_GetString( p_enc, SOUT_CFG_PREFIX "preset" );
char *psz_tune = var_GetString( p_enc, SOUT_CFG_PREFIX "tune" );
if( *psz_preset == '\0' )
@@ -881,7 +906,14 @@ static int Open ( vlc_object_t *p_this )
free(psz_preset);
psz_preset = NULL;
}
+#ifdef MODULE_NAME_IS_x262
+ p_sys->param.b_mpeg2 = true;
+ x264_param_default_mpeg2( &p_sys->param );
+ x264_param_default_preset_mpeg2( &p_sys->param, psz_preset, psz_tune );
+#else
+ x264_param_default( &p_sys->param );
x264_param_default_preset( &p_sys->param, psz_preset, psz_tune );
+#endif
free( psz_preset );
free( psz_tune );
p_sys->param.i_csp = p_sys->i_colorspace;
More information about the vlc-commits
mailing list