[x264-devel] [PATCH 18/29] Move global symbols to the implementation file

Vittorio Giovara vittorio.giovara at gmail.com
Thu Feb 2 10:05:30 CET 2017


This is so that it is not declared multiple times.

Also deprecate x264_bit_depth since bitdepth is set at runtime now.
For backward compatibility always initialize it to 8.
---
 common/api.c    |  6 ++++++
 common/common.c |  4 ----
 common/common.h |  2 --
 x264.c          |  6 +++---
 x264.h          | 18 +++++++++++-------
 5 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/common/api.c b/common/api.c
index 4a08d1e..394a3e8 100644
--- a/common/api.c
+++ b/common/api.c
@@ -29,6 +29,12 @@
 
 #include "x264.h"
 
+/****************************************************************************
+ * global symbols
+ ****************************************************************************/
+const int x264_bit_depth = 8;
+const int x264_chroma_format = X264_CHROMA_FORMAT;
+
 x264_t *x264_8_encoder_open( x264_param_t * );
 void x264_8_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
 int  x264_8_encoder_reconfig( x264_t *, x264_param_t * );
diff --git a/common/common.c b/common/common.c
index 6fd8dc9..87a6844 100644
--- a/common/common.c
+++ b/common/common.c
@@ -26,10 +26,6 @@
 
 #include "common.h"
 
-const int x264_bit_depth = BIT_DEPTH;
-
-const int x264_chroma_format = X264_CHROMA_FORMAT;
-
 /****************************************************************************
  * x264_log:
  ****************************************************************************/
diff --git a/common/common.h b/common/common.h
index dd9f136..370dba8 100644
--- a/common/common.h
+++ b/common/common.h
@@ -192,8 +192,6 @@ typedef union { x264_uint128_t i; uint64_t a[2]; uint32_t b[4]; uint16_t c[8]; u
 #   define MPIXEL_X4(src) M32(src)
 #endif
 
-#define BIT_DEPTH X264_BIT_DEPTH
-
 #define CPPIXEL_X4(dst,src) MPIXEL_X4(dst) = MPIXEL_X4(src)
 
 #define X264_SCAN8_LUMA_SIZE (5*8)
diff --git a/x264.c b/x264.c
index 15f0020..82b6a4f 100644
--- a/x264.c
+++ b/x264.c
@@ -340,7 +340,7 @@ static void print_version_info( void )
     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( "libx264 configuration: --bit-depth=%d --chroma-format=%s\n", x264_bit_depth, 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
     printf( "GPL version 2 or later\n" );
@@ -519,7 +519,7 @@ static void help( x264_param_t *defaults, int longhelp )
 #else
         "no",
 #endif
-        x264_bit_depth
+        X264_BIT_DEPTH
       );
     H0( "Example usage:\n" );
     H0( "\n" );
@@ -1320,7 +1320,7 @@ static int init_vid_filters( char *sequence, hnd_t *handle, video_info_t *info,
         return -1;
 
     char args[20];
-    sprintf( args, "bit_depth=%d", x264_bit_depth );
+    sprintf( args, "bit_depth=%d", X264_BIT_DEPTH );
 
     if( x264_init_vid_filter( "depth", handle, &filter, info, param, args ) )
         return -1;
diff --git a/x264.h b/x264.h
index 72ea253..d99c1e3 100644
--- a/x264.h
+++ b/x264.h
@@ -58,6 +58,14 @@ extern "C" {
 #define X264_API
 #endif
 
+#ifdef __GNUC__
+#    define X264_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER)
+#    define X264_DEPRECATED __declspec(deprecated)
+#else
+#    define X264_DEPRECATED
+#endif
+
 /* x264_t:
  *      opaque handler for encoder */
 typedef struct x264_t x264_t;
@@ -673,13 +681,9 @@ int     x264_param_apply_profile( x264_param_t *, const char *profile );
  ****************************************************************************/
 
 /* x264_bit_depth:
- *      Specifies the number of bits per pixel that x264 uses. This is also the
- *      bit depth that x264 encodes in. If this value is > 8, x264 will read
- *      two bytes of input data for each pixel sample, and expect the upper
- *      (16-x264_bit_depth) bits to be zero.
- *      Note: The flag X264_CSP_HIGH_DEPTH must be used to specify the
- *      colorspace depth as well. */
-X264_API extern const int x264_bit_depth;
+ *      Warning: this symbol is deprecated and always set to 8 for backward
+ *      compatibility. You may use i_bitdepth in x264_param_t as replacement. */
+X264_API X264_DEPRECATED extern const int x264_bit_depth;
 
 /* x264_chroma_format:
  *      Specifies the chroma formats that x264 supports encoding. When this
-- 
2.10.0



More information about the x264-devel mailing list