[x264-devel] [PATCH 28/29] Restore bitdepth selection at configure time
Vittorio Giovara
vittorio.giovara at gmail.com
Thu Feb 2 10:05:40 CET 2017
X264_BIT_DEPTH symbol is dropped as it is not needed any more.
---
Makefile | 16 ++++++++++++++++
common/api.c | 9 +++++++++
configure | 18 ++++++++++++------
filters/video/video.c | 4 ++++
x264.c | 24 ++++++++++++++++++++----
5 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 961954b..48eecc7 100644
--- a/Makefile
+++ b/Makefile
@@ -106,8 +106,12 @@ ifdef ARCH_X86
SRCS += common/x86/mc-c.c common/x86/predict-c.c
OBJASM += $(ASMSRCCOMMON:%.asm=%.o)
+ifneq ($(findstring HAVE_BITDEPTH8, $(CONFIG)),)
OBJASM += $(ASMSRC:%.asm=8bit/%.o) $(ASMSRC8:%.asm=8bit/%.o)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10, $(CONFIG)),)
OBJASM += $(ASMSRC:%.asm=10bit/%.o) $(ASMSRC10:%.asm=10bit/%.o)
+endif
$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
OBJCHK += tools/checkasm-a.o
@@ -131,8 +135,12 @@ ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
common/arm/predict-a.S common/arm/bitstream-a.S
SRCS += common/arm/mc-c.c common/arm/predict-c.c
+ifneq ($(findstring HAVE_BITDEPTH8, $(CONFIG)),)
OBJASM += $(ASMSRC:%.S=8bit/%.o)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10, $(CONFIG)),)
OBJASM += $(ASMSRC:%.S=10bit/%.o)
+endif
OBJCHK += tools/checkasm-arm.o
endif
@@ -153,8 +161,12 @@ SRCS += common/aarch64/asm-offsets.c \
common/aarch64/mc-c.c \
common/aarch64/predict-c.c
+ifneq ($(findstring HAVE_BITDEPTH8, $(CONFIG)),)
OBJASM += $(ASMSRC:%.S=8bit/%.o)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10, $(CONFIG)),)
OBJASM += $(ASMSRC:%.S=10bit/%.o)
+endif
OBJCHK += tools/checkasm-aarch64.o
endif
@@ -192,10 +204,14 @@ OBJS += $(SRCSCOMMON:%.c=%.o)
OBJCLI += $(SRCCLI:%.c=%.o)
OBJSO += $(SRCSO:%.c=%.o)
+ifneq ($(findstring HAVE_BITDEPTH8, $(CONFIG)),)
OBJS += $(SRCS:%.c=8bit/%.o) $(SRCSOCL:%.c=8bit/%.o)
OBJCLI += $(SRCCLIBD:%.c=8bit/%.o)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10, $(CONFIG)),)
OBJS += $(SRCS:%.c=10bit/%.o)
OBJCLI += $(SRCCLIBD:%.c=10bit/%.o)
+endif
.PHONY: all default fprofiled clean distclean install install-* uninstall cli lib-* etags
diff --git a/common/api.c b/common/api.c
index e461850..b98c063 100644
--- a/common/api.c
+++ b/common/api.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "x264.h"
+#include "config.h"
/****************************************************************************
* global symbols
@@ -85,6 +86,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
return NULL;
if( param->i_bitdepth == 0 || param->i_bitdepth == 8 ) {
+#if HAVE_BITDEPTH8
api->x264_encoder_reconfig = x264_8_encoder_reconfig;
api->x264_encoder_parameters = x264_8_encoder_parameters;
api->x264_encoder_headers = x264_8_encoder_headers;
@@ -96,7 +98,11 @@ x264_t *x264_encoder_open( x264_param_t *param )
api->x264_encoder_invalidate_reference = x264_8_encoder_invalidate_reference;
api->x264 = x264_8_encoder_open( param );
+#else
+ x264_log_internal( NULL, "Not compiled with 8 bit support\n" );
+#endif
} else if( param->i_bitdepth == 10 ) {
+#if HAVE_BITDEPTH10
api->x264_encoder_reconfig = x264_10_encoder_reconfig;
api->x264_encoder_parameters = x264_10_encoder_parameters;
api->x264_encoder_headers = x264_10_encoder_headers;
@@ -108,6 +114,9 @@ x264_t *x264_encoder_open( x264_param_t *param )
api->x264_encoder_invalidate_reference = x264_10_encoder_invalidate_reference;
api->x264 = x264_10_encoder_open( param );
+#else
+ x264_log_internal( NULL, "Not compiled with 10 bit support\n");
+#endif
}
if( !api->x264 ) {
diff --git a/configure b/configure
index 592b7e2..8ff5d67 100755
--- a/configure
+++ b/configure
@@ -30,7 +30,7 @@ Configuration options:
--disable-thread disable multithreaded encoding
--disable-win32thread disable win32threads (windows only)
--disable-interlaced disable interlaced encoding support
- --bit-depth=BIT_DEPTH set output bit depth (8-10) [8]
+ --bit-depth=BIT_DEPTH set output bit depth (8 or 10) [auto]
--chroma-format=FORMAT output chroma format (420, 422, 444, all) [all]
Advanced options:
@@ -351,7 +351,7 @@ debug="no"
gprof="no"
strip="no"
pic="no"
-bit_depth="8"
+bit_depth=0
chroma_format="all"
compiler="GNU"
compiler_style="GNU"
@@ -489,8 +489,8 @@ for opt do
;;
--bit-depth=*)
bit_depth="$optarg"
- if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
- echo "Supplied bit depth must be in range [8,10]."
+ if [ "$bit_depth" -ne "0" -a "$bit_depth" -ne "8" -a "$bit_depth" -ne "10" ]; then
+ echo "Supplied bit depth must be 8 or 10."
exit 1
fi
bit_depth=`expr $bit_depth + 0`
@@ -1244,7 +1244,14 @@ if [ $compiler = ICC -o $compiler = ICL ] ; then
fi
fi
-if [ "$bit_depth" -gt "8" ]; then
+if [ "$bit_depth" -eq "0" ]; then
+ define HAVE_BITDEPTH8
+ define HAVE_BITDEPTH10
+ bit_depth="8 and 10"
+elif [ "$bit_depth" -eq "8" ]; then
+ define HAVE_BITDEPTH8
+elif [ "$bit_depth" -eq "10" ]; then
+ define HAVE_BITDEPTH10
opencl="no"
fi
@@ -1281,7 +1288,6 @@ done
config_chroma_format="X264_CSP_I$chroma_format"
[ "$config_chroma_format" == "X264_CSP_Iall" ] && config_chroma_format="0"
cat > x264_config.h << EOF
-#define X264_BIT_DEPTH $bit_depth
#define X264_GPL $x264_gpl
#define X264_INTERLACED $x264_interlaced
#define X264_CHROMA_FORMAT $config_chroma_format
diff --git a/filters/video/video.c b/filters/video/video.c
index 9e45b75..ace4814 100644
--- a/filters/video/video.c
+++ b/filters/video/video.c
@@ -46,10 +46,14 @@ void x264_register_vid_filters( void )
{
extern cli_vid_filter_t source_filter;
first_filter = &source_filter;
+#if HAVE_BITDEPTH8
REGISTER_VFILTER( cache_8 );
REGISTER_VFILTER( depth_8 );
+#endif
+#if HAVE_BITDEPTH10
REGISTER_VFILTER( cache_10 );
REGISTER_VFILTER( depth_10 );
+#endif
REGISTER_VFILTER( crop );
REGISTER_VFILTER( fix_vfr_pts );
REGISTER_VFILTER( resize );
diff --git a/x264.c b/x264.c
index 3bb8e1f..1d5e1e8 100644
--- a/x264.c
+++ b/x264.c
@@ -339,7 +339,7 @@ static void print_version_info( void )
#else
printf( "using an unknown compiler\n" );
#endif
- printf( "x264 configuration: --bit-depth=%d --chroma-format=%s\n", X264_BIT_DEPTH, chroma_format_names[X264_CHROMA_FORMAT] );
+ printf( "x264 configuration: --chroma-format=%s\n", chroma_format_names[X264_CHROMA_FORMAT] );
printf( "libx264 configuration: --chroma-format=%s\n", chroma_format_names[x264_chroma_format] );
printf( "x264 license: " );
#if HAVE_GPL
@@ -488,7 +488,7 @@ static void help( x264_param_t *defaults, int longhelp )
" .mkv -> Matroska\n"
" .flv -> Flash Video\n"
" .mp4 -> MP4 if compiled with GPAC or L-SMASH support (%s)\n"
- "Output bit depth: %d (configured at compile time)\n"
+ "Output bit depth: %s%s%s\n"
"\n"
"Options:\n"
"\n"
@@ -519,7 +519,13 @@ static void help( x264_param_t *defaults, int longhelp )
#else
"no",
#endif
- X264_BIT_DEPTH
+#if HAVE_BITDEPTH8
+ "8 ",
+#endif
+#if HAVE_BITDEPTH10
+ "10",
+#endif
+ "."
);
H0( "Example usage:\n" );
H0( "\n" );
@@ -1634,7 +1640,17 @@ 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;
+ cli_input_t thread_input;
+ if (param->i_bitdepth == 8) {
+#if HAVE_BITDEPTH8
+ thread_input = thread_8_input;
+#endif
+ } else {
+#if HAVE_BITDEPTH10
+ thread_input = thread_10_input;
+#endif
+ }
+
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