Commit a615f027 authored by Anton Mitrofanov's avatar Anton Mitrofanov

Mark explicitly DSO public API symbols and hide all other by -fvisibility=hidden

Removes need for -Bsymbolic during linking.
parent b5bc5d69
......@@ -266,6 +266,9 @@ checkasm10$(EXE): $(GENERATED) .depend $(OBJCHK) $(OBJCHK_10) $(LIBX264)
example$(EXE): $(GENERATED) .depend $(OBJEXAMPLE) $(LIBX264)
$(LD)$@ $(OBJEXAMPLE) $(LIBX264) $(LDFLAGS)
$(OBJS) $(OBJSO): CFLAGS += $(CFLAGSSO)
$(OBJCLI): CFLAGS += $(CFLAGSCLI)
$(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJCHK_8) $(OBJCHK_10) $(OBJEXAMPLE): .depend
%.o: %.c
......
......@@ -47,7 +47,6 @@
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "x264.h"
/****************************************************************************
* Macros
......@@ -256,23 +255,23 @@ static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvd
/****************************************************************************
* General functions
****************************************************************************/
void x264_reduce_fraction( uint32_t *n, uint32_t *d );
void x264_reduce_fraction64( uint64_t *n, uint64_t *d );
X264_API void x264_reduce_fraction( uint32_t *n, uint32_t *d );
X264_API void x264_reduce_fraction64( uint64_t *n, uint64_t *d );
void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg );
void x264_log_internal( int i_level, const char *psz_fmt, ... );
X264_API void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg );
X264_API void x264_log_internal( int i_level, const char *psz_fmt, ... );
/* x264_malloc : will do or emulate a memalign
* you have to use x264_free for buffers allocated with x264_malloc */
void *x264_malloc( int );
void x264_free( void * );
X264_API void *x264_malloc( int );
X264_API void x264_free( void * );
/* x264_slurp_file: malloc space for the whole file and read it */
char *x264_slurp_file( const char *filename );
X264_API char *x264_slurp_file( const char *filename );
/* x264_param2string: return a (malloced) string containing most of
* the encoding options */
char *x264_param2string( x264_param_t *p, int b_res );
X264_API char *x264_param2string( x264_param_t *p, int b_res );
/****************************************************************************
* Macros
......
......@@ -26,8 +26,8 @@
#ifndef X264_CPU_H
#define X264_CPU_H
uint32_t x264_cpu_detect( void );
int x264_cpu_num_processors( void );
X264_API uint32_t x264_cpu_detect( void );
X264_API int x264_cpu_num_processors( void );
void x264_cpu_emms( void );
void x264_cpu_sfence( void );
#if HAVE_MMX
......@@ -51,6 +51,6 @@ typedef struct
const char *name;
uint32_t flags;
} x264_cpu_name_t;
extern const x264_cpu_name_t x264_cpu_names[];
X264_API extern const x264_cpu_name_t x264_cpu_names[];
#endif
......@@ -261,13 +261,14 @@ void x264_threadslice_cond_broadcast( x264_t *h, int pass );
void x264_threadslice_cond_wait( x264_t *h, int pass );
#define x264_frame_push x264_template(frame_push)
void x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
X264_API void x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
#define x264_frame_pop x264_template(frame_pop)
x264_frame_t *x264_frame_pop( x264_frame_t **list );
X264_API x264_frame_t *x264_frame_pop( x264_frame_t **list );
#define x264_frame_unshift x264_template(frame_unshift)
void x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
X264_API void x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
#define x264_frame_shift x264_template(frame_shift)
x264_frame_t *x264_frame_shift( x264_frame_t **list );
X264_API x264_frame_t *x264_frame_shift( x264_frame_t **list );
#define x264_frame_push_unused x264_template(frame_push_unused)
void x264_frame_push_unused( x264_t *h, x264_frame_t *frame );
#define x264_frame_push_blank_unused x264_template(frame_push_blank_unused)
......
......@@ -43,6 +43,8 @@
#include <math.h>
#endif
#include "x264.h"
#if !HAVE_LOG2F
#define log2f(x) (logf(x)/0.693147180559945f)
#define log2(x) (log(x)/0.693147180559945)
......@@ -55,8 +57,8 @@
#define strtok_r strtok_s
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
#if _MSC_VER < 1900
int x264_snprintf( char *s, size_t n, const char *fmt, ... );
int x264_vsnprintf( char *s, size_t n, const char *fmt, va_list arg );
X264_API int x264_snprintf( char *s, size_t n, const char *fmt, ... );
X264_API int x264_vsnprintf( char *s, size_t n, const char *fmt, va_list arg );
#define snprintf x264_snprintf
#define vsnprintf x264_vsnprintf
#endif
......@@ -79,11 +81,11 @@ int x264_vsnprintf( char *s, size_t n, const char *fmt, va_list arg );
#ifdef _WIN32
#define utf8_to_utf16( utf8, utf16 )\
MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, utf8, -1, utf16, sizeof(utf16)/sizeof(wchar_t) )
FILE *x264_fopen( const char *filename, const char *mode );
int x264_rename( const char *oldname, const char *newname );
X264_API FILE *x264_fopen( const char *filename, const char *mode );
X264_API int x264_rename( const char *oldname, const char *newname );
#define x264_struct_stat struct _stati64
#define x264_fstat _fstati64
int x264_stat( const char *path, x264_struct_stat *buf );
X264_API int x264_stat( const char *path, x264_struct_stat *buf );
#else
#define x264_fopen fopen
#define x264_rename rename
......@@ -93,11 +95,11 @@ int x264_stat( const char *path, x264_struct_stat *buf );
#endif
/* mdate: return the current date in microsecond */
int64_t x264_mdate( void );
X264_API int64_t x264_mdate( void );
#if defined(_WIN32) && !HAVE_WINRT
int x264_vfprintf( FILE *stream, const char *format, va_list arg );
int x264_is_pipe( const char *path );
X264_API int x264_vfprintf( FILE *stream, const char *format, va_list arg );
X264_API int x264_is_pipe( const char *path );
#else
#define x264_vfprintf vfprintf
#define x264_is_pipe(x) 0
......@@ -253,7 +255,7 @@ static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(vo
#endif
#if HAVE_WIN32THREAD || PTW32_STATIC_LIB
int x264_threading_init( void );
X264_API int x264_threading_init( void );
#else
#define x264_threading_init() 0
#endif
......
......@@ -33,7 +33,7 @@ typedef struct
uint8_t i_size;
} vlc_t;
extern const x264_level_t x264_levels[];
X264_API extern const x264_level_t x264_levels[];
extern const uint8_t x264_exp2_lut[64];
extern const float x264_log2_lut[128];
......
......@@ -30,14 +30,14 @@ typedef struct x264_threadpool_t x264_threadpool_t;
#if HAVE_THREAD
#define x264_threadpool_init x264_template(threadpool_init)
int x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
void (*init_func)(void *), void *init_arg );
X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
void (*init_func)(void *), void *init_arg );
#define x264_threadpool_run x264_template(threadpool_run)
void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg );
X264_API void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg );
#define x264_threadpool_wait x264_template(threadpool_wait)
void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg );
X264_API void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg );
#define x264_threadpool_delete x264_template(threadpool_delete)
void x264_threadpool_delete( x264_threadpool_t *pool );
X264_API void x264_threadpool_delete( x264_threadpool_t *pool );
#else
#define x264_threadpool_init(p,t,f,a) -1
#define x264_threadpool_run(p,f,a)
......
......@@ -151,9 +151,9 @@ cc_check() {
done
echo "int main (void) { $3 return 0; }" >> conftest.c
if [ $compiler_style = MS ]; then
cc_cmd="$CC conftest.c $(cc_cflags $CFLAGS $CHECK_CFLAGS $2) -link $(cl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
cc_cmd="$CC conftest.c $(cc_cflags $CFLAGS $CFLAGSCLI $CHECK_CFLAGS $2) -link $(cl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
else
cc_cmd="$CC conftest.c $CFLAGS $CHECK_CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
cc_cmd="$CC conftest.c $CFLAGS $CFLAGSCLI $CHECK_CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
fi
if $cc_cmd >conftest.log 2>&1; then
res=$?
......@@ -380,6 +380,8 @@ opencl="yes"
vsx="auto"
CFLAGS="$CFLAGS -Wall -I. -I\$(SRCPATH)"
CFLAGSSO="$CFLAGSSO -DX264_API_EXPORTS"
CFLAGSCLI="$CFLAGSCLI"
LDFLAGS="$LDFLAGS"
LDFLAGSCLI="$LDFLAGSCLI"
ASFLAGS="$ASFLAGS -I. -I\$(SRCPATH)"
......@@ -1007,6 +1009,7 @@ if [ "$cli_libx264" = "system" -a "$shared" != "yes" ] ; then
[ "$static" = "yes" ] && die "Option --system-libx264 can not be used together with --enable-static"
if pkg_check x264 ; then
X264_LIBS="$($PKGCONFIG --libs x264)"
X264_CFLAGS="$($PKGCONFIG --cflags x264)"
X264_INCLUDE_DIR="${X264_INCLUDE_DIR-$($PKGCONFIG --variable=includedir x264)}"
configure_system_override "$X264_INCLUDE_DIR" || die "Detection of system libx264 configuration failed"
else
......@@ -1308,6 +1311,10 @@ if cc_check '' -Wmaybe-uninitialized ; then
CFLAGS="-Wno-maybe-uninitialized $CFLAGS"
fi
if [ $compiler = GNU ] && cc_check '' -fvisibility=hidden ; then
CFLAGS="$CFLAGS -fvisibility=hidden"
fi
if [ $compiler = ICC -o $compiler = ICL ] ; then
if cc_check 'extras/intel_dispatcher.h' '' 'x264_intel_dispatcher_override();' ; then
define HAVE_INTEL_DISPATCHER
......@@ -1368,9 +1375,11 @@ ${SRCPATH}/version.sh >> x264_config.h
if [ "$cli_libx264" = "system" ] ; then
if [ "$shared" = "yes" ]; then
CLI_LIBX264='$(SONAME)'
CFLAGSCLI="$CFLAGSCLI -DX264_API_IMPORTS"
else
CLI_LIBX264=
LDFLAGSCLI="$X264_LIBS $LDFLAGSCLI"
CFLAGSCLI="$CFLAGSCLI $X264_CFLAGS"
cc_check 'stdint.h x264.h' '' 'x264_encoder_open(0);' || die "System libx264 can't be used for compilation of this version"
fi
else
......@@ -1409,7 +1418,11 @@ else # gcc/icc
LIBX264=libx264.a
[ -n "$RC" ] && RCFLAGS="$RCFLAGS -I. -o "
fi
[ $compiler != GNU ] && CFLAGS="$(cc_cflags $CFLAGS)"
if [ $compiler != GNU ]; then
CFLAGS="$(cc_cflags $CFLAGS)"
CFLAGSSO="$(cc_cflags $CFLAGSSO)"
CFLAGSCLI="$(cc_cflags $CFLAGSCLI)"
fi
if [ $compiler = ICC -o $compiler = ICL ]; then
# icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
[ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
......@@ -1448,13 +1461,17 @@ SYS_ARCH=$ARCH
SYS=$SYS
CC=$CC
CFLAGS=$CFLAGS
CFLAGSSO=$CFLAGSSO
CFLAGSCLI=$CFLAGSCLI
COMPILER=$compiler
COMPILER_STYLE=$compiler_style
DEPMM=$DEPMM
DEPMT=$DEPMT
LD=$LD
LDFLAGS=$LDFLAGS
LDFLAGSCLI=$LDFLAGSCLI
LIBX264=$LIBX264
CLI_LIBX264=$CLI_LIBX264
AR=$AR
RANLIB=$RANLIB
STRIP=$STRIP
......@@ -1490,14 +1507,7 @@ if [ "$shared" = "yes" ]; then
echo "SONAME=libx264-$API.dll" >> config.mak
if [ $compiler_style = MS ]; then
echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
# GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
# MSVC link does not act similarly, so it is required to make an export definition out of x264.h and use it at link time
echo "SOFLAGS=-dll -def:x264.def -implib:\$(IMPLIBNAME) $SOFLAGS" >> config.mak
echo "EXPORTS" > x264.def
# export API functions
grep "^\(int\|void\|x264_t\).*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264.*\)(.*/\1/;s/open/open_$API/g" >> x264.def
# export API variables/data. must be flagged with the DATA keyword
grep "extern.*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264\w*\)\W.*/\1 DATA/;" >> x264.def
echo "SOFLAGS=-dll -implib:\$(IMPLIBNAME) $SOFLAGS" >> config.mak
else
echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) $SOFLAGS" >> config.mak
......@@ -1524,9 +1534,6 @@ if [ "$static" = "yes" ]; then
echo 'install: install-lib-static' >> config.mak
fi
echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
cat > x264.pc << EOF
prefix=$prefix
exec_prefix=$exec_prefix
......@@ -1538,7 +1545,7 @@ Description: H.264 (MPEG4 AVC) encoder library
Version: $(grep POINTVER < x264_config.h | sed -e 's/.* "//; s/".*//; s/ .*//')
Libs: -L$libdir -lx264 $([ "$shared" = "yes" ] || echo $libpthread $libm $libdl)
Libs.private: $([ "$shared" = "yes" ] && echo $libpthread $libm $libdl)
Cflags: -I$includedir
Cflags: -I$includedir $([ "$shared" = "yes" ] && echo "-DX264_API_IMPORTS")
EOF
filters="crop select_every"
......
......@@ -45,7 +45,20 @@ extern "C" {
#include "x264_config.h"
#define X264_BUILD 157
#define X264_BUILD 158
#ifdef _WIN32
# define X264_DLL_IMPORT __declspec(dllimport)
# define X264_DLL_EXPORT __declspec(dllexport)
#else
# if defined(__GNUC__) && (__GNUC__ >= 4)
# define X264_DLL_IMPORT
# define X264_DLL_EXPORT __attribute__((visibility("default")))
# else
# define X264_DLL_IMPORT
# define X264_DLL_EXPORT
# endif
#endif
/* Application developers planning to link against a shared library version of
* libx264 from a Microsoft Visual Studio or similar development environment
......@@ -53,9 +66,13 @@ extern "C" {
* This clause does not apply to MinGW, similar development environments, or non
* Windows platforms. */
#ifdef X264_API_IMPORTS
#define X264_API __declspec(dllimport)
# define X264_API X264_DLL_IMPORT
#else
#define X264_API
# ifdef X264_API_EXPORTS
# define X264_API X264_DLL_EXPORT
# else
# define X264_API
# endif
#endif
/* x264_t:
......@@ -568,7 +585,7 @@ typedef struct x264_param_t
void (*nalu_process)( x264_t *h, x264_nal_t *nal, void *opaque );
} x264_param_t;
void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
X264_API void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
/****************************************************************************
* H.264 level restriction information
......@@ -600,7 +617,7 @@ X264_API extern const x264_level_t x264_levels[];
/* x264_param_default:
* fill x264_param_t with default values and do CPU detection */
void x264_param_default( x264_param_t * );
X264_API void x264_param_default( x264_param_t * );
/* x264_param_parse:
* set one parameter by name.
......@@ -611,7 +628,7 @@ void x264_param_default( x264_param_t * );
* value=NULL means "true" for boolean options, but is a BAD_VALUE for non-booleans. */
#define X264_PARAM_BAD_NAME (-1)
#define X264_PARAM_BAD_VALUE (-2)
int x264_param_parse( x264_param_t *, const char *name, const char *value );
X264_API int x264_param_parse( x264_param_t *, const char *name, const char *value );
/****************************************************************************
* Advanced parameter handling functions
......@@ -655,13 +672,13 @@ static const char * const x264_tune_names[] = { "film", "animation", "grain", "s
* film, animation, grain, stillimage, psnr, and ssim are psy tunings.
*
* returns 0 on success, negative on failure (e.g. invalid preset/tune name). */
int x264_param_default_preset( x264_param_t *, const char *preset, const char *tune );
X264_API int x264_param_default_preset( x264_param_t *, const char *preset, const char *tune );
/* x264_param_apply_fastfirstpass:
* If first-pass mode is set (rc.b_stat_read == 0, rc.b_stat_write == 1),
* modify the encoder settings to disable options generally not useful on
* the first pass. */
void x264_param_apply_fastfirstpass( x264_param_t * );
X264_API void x264_param_apply_fastfirstpass( x264_param_t * );
/* x264_param_apply_profile:
* Applies the restrictions of the given profile.
......@@ -676,7 +693,7 @@ static const char * const x264_profile_names[] = { "baseline", "main", "high", "
* decrease them.
*
* returns 0 on success, negative on failure (e.g. invalid profile name). */
int x264_param_apply_profile( x264_param_t *, const char *profile );
X264_API int x264_param_apply_profile( x264_param_t *, const char *profile );
/****************************************************************************
* Picture structures and functions
......@@ -846,17 +863,17 @@ typedef struct x264_picture_t
/* x264_picture_init:
* initialize an x264_picture_t. Needs to be done if the calling application
* allocates its own x264_picture_t as opposed to using x264_picture_alloc. */
void x264_picture_init( x264_picture_t *pic );
X264_API void x264_picture_init( x264_picture_t *pic );
/* x264_picture_alloc:
* alloc data for a picture. You must call x264_picture_clean on it.
* returns 0 on success, or -1 on malloc failure or invalid colorspace. */
int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height );
X264_API int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height );
/* x264_picture_clean:
* free associated resource for a x264_picture_t allocated with
* x264_picture_alloc ONLY */
void x264_picture_clean( x264_picture_t *pic );
X264_API void x264_picture_clean( x264_picture_t *pic );
/****************************************************************************
* Encoder functions
......@@ -871,7 +888,7 @@ void x264_picture_clean( x264_picture_t *pic );
/* x264_encoder_open:
* create a new encoder handler, all parameters from x264_param_t are copied */
x264_t *x264_encoder_open( x264_param_t * );
X264_API x264_t *x264_encoder_open( x264_param_t * );
/* x264_encoder_reconfig:
* various parameters from x264_param_t are copied.
......@@ -886,7 +903,7 @@ x264_t *x264_encoder_open( x264_param_t * );
* more so than for other presets, many of the speed shortcuts used in ultrafast cannot be
* switched out of; using reconfig to switch between ultrafast and other presets is not
* recommended without a more fine-grained breakdown of parameters to take this into account. */
int x264_encoder_reconfig( x264_t *, x264_param_t * );
X264_API int x264_encoder_reconfig( x264_t *, x264_param_t * );
/* x264_encoder_parameters:
* copies the current internal set of parameters to the pointer provided
* by the caller. useful when the calling application needs to know
......@@ -894,32 +911,32 @@ int x264_encoder_reconfig( x264_t *, x264_param_t * );
* of the encoder after multiple x264_encoder_reconfig calls.
* note that the data accessible through pointers in the returned param struct
* (e.g. filenames) should not be modified by the calling application. */
void x264_encoder_parameters( x264_t *, x264_param_t * );
X264_API void x264_encoder_parameters( x264_t *, x264_param_t * );
/* x264_encoder_headers:
* return the SPS and PPS that will be used for the whole stream.
* *pi_nal is the number of NAL units outputted in pp_nal.
* returns the number of bytes in the returned NALs.
* returns negative on error.
* the payloads of all output NALs are guaranteed to be sequential in memory. */
int x264_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
X264_API int x264_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
/* x264_encoder_encode:
* encode one picture.
* *pi_nal is the number of NAL units outputted in pp_nal.
* returns the number of bytes in the returned NALs.
* returns negative on error and zero if no NAL units returned.
* the payloads of all output NALs are guaranteed to be sequential in memory. */
int x264_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
X264_API int x264_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
/* x264_encoder_close:
* close an encoder handler */
void x264_encoder_close( x264_t * );
X264_API void x264_encoder_close( x264_t * );
/* x264_encoder_delayed_frames:
* return the number of currently delayed (buffered) frames
* this should be used at the end of the stream, to know when you have all the encoded frames. */
int x264_encoder_delayed_frames( x264_t * );
X264_API int x264_encoder_delayed_frames( x264_t * );
/* x264_encoder_maximum_delayed_frames( x264_t * ):
* return the maximum number of delayed (buffered) frames that can occur with the current
* parameters. */
int x264_encoder_maximum_delayed_frames( x264_t * );
X264_API int x264_encoder_maximum_delayed_frames( x264_t * );
/* x264_encoder_intra_refresh:
* If an intra refresh is not in progress, begin one with the next P-frame.
* If an intra refresh is in progress, begin one as soon as the current one finishes.
......@@ -933,7 +950,7 @@ int x264_encoder_maximum_delayed_frames( x264_t * );
* behavior is undefined.
*
* Should not be called during an x264_encoder_encode. */
void x264_encoder_intra_refresh( x264_t * );
X264_API void x264_encoder_intra_refresh( x264_t * );
/* x264_encoder_invalidate_reference:
* An interactive error resilience tool, designed for use in a low-latency one-encoder-few-clients
* system. When the client has packet loss or otherwise incorrectly decodes a frame, the encoder
......@@ -956,7 +973,7 @@ void x264_encoder_intra_refresh( x264_t * );
* Should not be called during an x264_encoder_encode, but multiple calls can be made simultaneously.
*
* Returns 0 on success, negative on failure. */
int x264_encoder_invalidate_reference( x264_t *, int64_t pts );
X264_API int x264_encoder_invalidate_reference( x264_t *, int64_t pts );
#ifdef __cplusplus
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment