<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 8, 2013 at 2:50 AM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Steve Borho <<a href="mailto:steve@borho.org">steve@borho.org</a>><br>
# Date 1381194546 18000<br>
# Mon Oct 07 20:09:06 2013 -0500<br>
# Node ID 6b457a8c52376af24ddcad014ad1793209574e74<br>
# Parent 9b3a427a1009d1853bbdc30abe1fd891864e6b38<br>
cmake: use cmake 2.8 OBJECT target type to manage static and share libs<br></blockquote><div><br></div><div>This seems like the correct approach to deal with needing to create a static lib and shared lib from the same source base that spans several directories; and it works perfectly with MinGW/GCC and MSVC.<br>
<br></div><div>However on Linux x64 I get this inexplicable error about -fPIC when clearly everything is getting built with -fPIC (gcc) or -DPIC (yasm):<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
With the OBJECT target type, the common and encoder folders are compiled to<br>
object files but not linked until main static or shared library is built. This<br>
removes the need for mergestatic.cmake and cleans up a lot of messy problems -<br>
at the cost of requiring a somewhat recent cmake.<br>
<br>
For MSVC (and presumably Xcode) we must keep the assembly as a static lib since<br>
it uses custom build commands which do not work with OBJECT target types. This<br>
static lib is then linked with the main x265.lib or x265.dll<br>
<br>
The X265_EXPORT macro is no longer necessary since we are generating both the<br>
static library and shared library from one compile we are forced to use an<br>
x265.def file to define DLL exports. x265.exe must link with the static library<br>
because on Windows the static lib will be empty if no EXE links with it.<br>
<br>
x265_mdate() was moved into the CLI x265.cpp so the CLI could link with the<br>
shared library if necessary (x265_mdate is not exported)<br>
<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/CMakeLists.txt Mon Oct 07 20:09:06 2013 -0500<br>
@@ -6,7 +6,7 @@<br>
endif()<br>
<br>
project (x265)<br>
-cmake_minimum_required (VERSION 2.6)<br>
+cmake_minimum_required (VERSION 2.8)<br>
<br>
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")<br>
<br>
@@ -140,31 +140,18 @@<br>
endif(WINXP_SUPPORT)<br>
endif()<br>
<br>
-option(ENABLE_SHARED "Build shared x265 library (.dll/.so)" OFF)<br>
-if(ENABLE_SHARED)<br>
- add_definitions(-Dx265_EXPORTS)<br>
-endif()<br>
-<br>
include_directories(. Lib common encoder)<br>
add_subdirectory(common)<br>
add_subdirectory(encoder)<br>
<br>
-if(ENABLE_PRIMITIVES_VEC)<br>
- set(LIBS ${LIBS} PrimitivesVec)<br>
-endif(ENABLE_PRIMITIVES_VEC)<br>
-<br>
-if(ENABLE_PRIMITIVES_ASM)<br>
- set(LIBS ${LIBS} PrimitivesASM)<br>
-endif(ENABLE_PRIMITIVES_ASM)<br>
-set(LIBS ${LIBS} encoder common)<br>
-<br>
-if(ENABLE_SHARED)<br>
- add_library(x265 SHARED dllmain.cpp)<br>
- target_link_libraries(x265 ${LIBS})<br>
-elseif(NOT XCODE)<br>
- include(mergestaticlibs)<br>
- merge_static_libs(x265 ${LIBS})<br>
+add_library(x265-shared SHARED dllmain.cpp x265.def $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common>)<br>
+add_library(x265-static STATIC $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common>)<br>
+if(MSVC OR XCODE)<br>
+ target_link_libraries(x265-shared assembly)<br>
+ target_link_libraries(x265-static assembly)<br>
endif()<br>
+set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265)<br>
+set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265)<br>
<br>
# Main CLI application<br>
option(ENABLE_CLI "Build standalone CLI application" ON)<br>
@@ -184,13 +171,8 @@<br>
add_executable(cli ../COPYING ${InputFiles} ${OutputFiles}<br>
x265.cpp x265opts.h x265.h<br>
compat/msvc/getopt.c compat/msvc/getopt.h)<br>
- if(XCODE OR MSVC)<br>
- target_link_libraries(cli ${LIBS})<br>
- else()<br>
- target_link_libraries(cli x265)<br>
- endif()<br>
- target_link_libraries(cli ${PLATFORM_LIBS})<br>
- SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME x265)<br>
+ target_link_libraries(cli x265-static ${PLATFORM_LIBS})<br>
+ set_target_properties(cli PROPERTIES OUTPUT_NAME x265)<br>
endif(ENABLE_CLI)<br>
<br>
# Test applications<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/cmake/mergestaticlibs.cmake<br>
--- a/source/cmake/mergestaticlibs.cmake Tue Oct 08 11:12:12 2013 +0530<br>
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000<br>
@@ -1,124 +0,0 @@<br>
-# Copyright (C) 2012 Modelon AB<br>
-<br>
-# This program is free software: you can redistribute it and/or modify<br>
-# it under the terms of the BSD style license.<br>
-<br>
-# This program is distributed in the hope that it will be useful,<br>
-# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
-# FMILIB_License.txt file for more details.<br>
-<br>
-# You should have received a copy of the FMILIB_License.txt file<br>
-# along with this program. If not, contact Modelon AB <<a href="http://www.modelon.com" target="_blank">http://www.modelon.com</a>>.<br>
-<br>
-# Merge_static_libs(outlib lib1 lib2 ... libn) merges a number of static<br>
-# libs into a single static library<br>
-function(merge_static_libs outlib )<br>
- set(libs ${ARGV})<br>
- list(REMOVE_AT libs 0)<br>
- # Create a dummy file that the target will depend on<br>
- set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c)<br>
- file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";")<br>
-<br>
- add_library(${outlib} STATIC ${dummyfile})<br>
-<br>
- if("${CMAKE_CFG_INTDIR}" STREQUAL ".")<br>
- set(multiconfig FALSE)<br>
- else()<br>
- set(multiconfig TRUE)<br>
- endif()<br>
-<br>
- # First get the file names of the libraries to be merged<br>
- foreach(lib ${libs})<br>
- get_target_property(libtype ${lib} TYPE)<br>
- if(NOT libtype STREQUAL "STATIC_LIBRARY")<br>
- message(FATAL_ERROR "Merge_static_libs can only process static libraries")<br>
- endif()<br>
- if(multiconfig)<br>
- foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})<br>
- get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}")<br>
- list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}})<br>
- endforeach()<br>
- else()<br>
- get_target_property(libfile ${lib} LOCATION)<br>
- list(APPEND libfiles "${libfile}")<br>
- endif(multiconfig)<br>
- endforeach()<br>
- message(STATUS "will be merging ${libfiles}")<br>
- # Just to be sure: cleanup from duplicates<br>
- if(multiconfig)<br>
- foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})<br>
- list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE})<br>
- set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}})<br>
- endforeach()<br>
- endif()<br>
- list(REMOVE_DUPLICATES libfiles)<br>
-<br>
- # Now the easy part for MSVC and for MAC<br>
- if(MSVC)<br>
- # lib.exe does the merging of libraries just need to conver the list into string<br>
- foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})<br>
- set(flags "")<br>
- foreach(lib ${libfiles_${CONFIG_TYPE}})<br>
- set(flags "${flags} ${lib}")<br>
- endforeach()<br>
- string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME)<br>
- set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}")<br>
- endforeach()<br>
-<br>
- elseif(APPLE)<br>
- # Use OSX's libtool to merge archives<br>
- if(multiconfig)<br>
- message(FATAL_ERROR "Multiple configurations are not supported")<br>
- endif()<br>
- get_target_property(outfile ${outlib} LOCATION)<br>
- add_custom_command(TARGET ${outlib} POST_BUILD<br>
- COMMAND rm ${outfile}<br>
- COMMAND /usr/bin/libtool -static -o ${outfile}<br>
- ${libfiles})<br>
- else()<br>
- # general UNIX - need to "ar -x" and then "ar -ru"<br>
- if(multiconfig)<br>
- message(FATAL_ERROR "Multiple configurations are not supported")<br>
- endif()<br>
- get_target_property(outfile ${outlib} LOCATION)<br>
- message(STATUS "outfile location is ${outfile}")<br>
- foreach(lib ${libfiles})<br>
- # objlistfile will contain the list of object files for the library<br>
- set(objlistfile ${lib}.objlist)<br>
- set(objdir ${lib}.objdir)<br>
- set(objlistcmake ${objlistfile}.cmake)<br>
- # we only need to extract files once<br>
- if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake})<br>
- file(WRITE ${objlistcmake}<br>
-"# Extract object files from the library<br>
-message(STATUS \"Extracting object files from ${lib}\")<br>
-<br>
- execute_process(COMMAND ${CMAKE_AR} -x ${lib}<br>
- WORKING_DIRECTORY ${objdir})<br>
- # save the list of object files<br>
- execute_process(COMMAND ls .<br>
- OUTPUT_FILE ${objlistfile}<br>
- WORKING_DIRECTORY ${objdir})")<br>
- file(MAKE_DIRECTORY ${objdir})<br>
- add_custom_command(<br>
- OUTPUT ${objlistfile}<br>
- COMMAND ${CMAKE_COMMAND} -P ${objlistcmake}<br>
- DEPENDS ${lib})<br>
- endif()<br>
- list(APPEND extrafiles "${objlistfile}")<br>
- add_custom_command(TARGET ${outlib} POST_BUILD<br>
- COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} \\$$\\(cat ${objlistfile}\\)"<br>
- COMMAND ${CMAKE_AR} ru "${outfile}" $$\(cat "${objlistfile}"\)<br>
- WORKING_DIRECTORY ${objdir})<br>
- endforeach()<br>
- add_custom_command(TARGET ${outlib} POST_BUILD<br>
- COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}"<br>
- COMMAND ${CMAKE_RANLIB} ${outfile})<br>
- endif()<br>
- file(WRITE ${dummyfile}.base "const char* ${outlib}_sublibs=\"${libs}\";")<br>
- add_custom_command(<br>
- OUTPUT ${dummyfile}<br>
- COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile}<br>
- DEPENDS ${libs} ${extrafiles})<br>
-endfunction()<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/CMakeLists.txt<br>
--- a/source/common/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/common/CMakeLists.txt Mon Oct 07 20:09:06 2013 -0500<br>
@@ -81,8 +81,141 @@<br>
endif()<br>
endif(MSVC)<br>
<br>
-add_library(common STATIC ../../COPYING<br>
+if(ENABLE_PRIMITIVES_VEC)<br>
+ if (MSVC)<br>
+ add_definitions(/wd4127) # conditional expression is constant<br>
+ add_definitions(/wd4244) # 'argument' : conversion from 'int' to 'char', possible loss of data<br>
+ if ("$ENV{CXX}" STREQUAL "icl")<br>
+ add_definitions(/Qwd111) # statement is unreachable<br>
+ add_definitions(/Qwd128) # loop is unreachable<br>
+ add_definitions(/Qwd177) # declared function is unused<br>
+ add_definitions(/Qwd185) # dynamic initialization in unreachable code<br>
+ add_definitions(/Qwd280) # conditional expression is constant<br>
+ add_definitions(/Qwd13200) # function using MMX does not call EMMS<br>
+ endif()<br>
+ set(PRIMITIVES vec/blockcopy-sse3.cpp<br>
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp<br>
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp<br>
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp<br>
+ vec/intra-sse3.cpp vec/intra-sse41.cpp)<br>
+ if (NOT X64)<br>
+ # x64 implies SSE4, so this flag would have no effect (and it issues a warning)<br>
+ set_source_files_properties(vec/blockcopy-sse3.cpp<br>
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp<br>
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp<br>
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp<br>
+ vec/intra-sse3.cpp vec/intra-sse41.cpp<br>
+ PROPERTIES COMPILE_FLAGS /arch:SSE2)<br>
+ endif()<br>
+ if (MSVC_VERSION EQUAL 1700 OR "$ENV{CXX}" STREQUAL "icl")<br>
+ set(PRIMITIVES ${PRIMITIVES} vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp)<br>
+ set_source_files_properties(vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp<br>
+ PROPERTIES COMPILE_FLAGS /arch:AVX)<br>
+ endif()<br>
+ endif()<br>
+ if(GCC)<br>
+ if ("$ENV{CXX}" STREQUAL "icpc")<br>
+ add_definitions(-wd13200) # function using MMX does not call EMMS<br>
+ endif()<br>
+ if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.3)<br>
+ set(PRIMITIVES vec/blockcopy-sse3.cpp<br>
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp<br>
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp<br>
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp<br>
+ vec/intra-sse3.cpp vec/intra-sse41.cpp)<br>
+ set_source_files_properties(<br>
+ vec/blockcopy-sse3.cpp vec/pixel-sse3.cpp vec/dct-sse3.cpp vec/intra-sse3.cpp<br>
+ PROPERTIES COMPILE_FLAGS "-msse3")<br>
+ set_source_files_properties(<br>
+ vec/ipfilter-ssse3.cpp vec/pixel-ssse3.cpp vec/dct-ssse3.cpp<br>
+ PROPERTIES COMPILE_FLAGS "-mssse3")<br>
+ set_source_files_properties(<br>
+ vec/pixel-sse41.cpp vec/ipfilter-sse41.cpp vec/dct-sse41.cpp vec/intra-sse41.cpp<br>
+ PROPERTIES COMPILE_FLAGS "-msse4.1")<br>
+ endif()<br>
+ if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.7)<br>
+ set(PRIMITIVES ${PRIMITIVES}<br>
+ vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp)<br>
+ set_source_files_properties(<br>
+ vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp<br>
+ PROPERTIES COMPILE_FLAGS "-march=core-avx2")<br>
+ endif()<br>
+ endif(GCC)<br>
+<br>
+ set(VEC_PRIMITIVES vec/vec-primitives.cpp ${PRIMITIVES})<br>
+ source_group(Intrinsics FILES ${VEC_PRIMITIVES})<br>
+endif(ENABLE_PRIMITIVES_VEC)<br>
+<br>
+if(ENABLE_PRIMITIVES_ASM)<br>
+ if (GCC)<br>
+ add_definitions(-DHAVE_ALIGNED_STACK=1)<br>
+ add_definitions(-Wno-error=unused-parameter)<br>
+ else()<br>
+ add_definitions(-DHAVE_ALIGNED_STACK=0)<br>
+ endif()<br>
+<br>
+ set(ASMS pixel-a.asm const-a.asm cpu-a.asm sad-a.asm mc-a.asm mc-a2.asm ipfilter8.asm)<br>
+ if (X64)<br>
+ add_definitions(-DARCH_X86_64=1)<br>
+ else()<br>
+ add_definitions(-DARCH_X86_64=0)<br>
+ set(ASMS ${ASMS} pixel-32.asm)<br>
+ endif()<br>
+ foreach(ASM ${ASMS})<br>
+ set(FULLPATHASM ${FULLPATHASM} x86/${ASM})<br>
+ endforeach()<br>
+<br>
+ if(XCODE)<br>
+ if (X64)<br>
+ set(FLAGS -f macho64 -m amd64 -DPREFIX -DPIC -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=1)<br>
+ else()<br>
+ set(FLAGS -f macho -DPREFIX -DPIC -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=1)<br>
+ endif()<br>
+ if (HIGH_BIT_DEPTH)<br>
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)<br>
+ else()<br>
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)<br>
+ endif()<br>
+ foreach(ASM ${ASMS})<br>
+ set(OBJS ${OBJS} ${ASM}.o)<br>
+ add_custom_command(<br>
+ OUTPUT ${ASM}.o<br>
+ COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/x86/${ASM} -o ${ASM}.o<br>
+ DEPENDS ${ASM})<br>
+ endforeach()<br>
+ add_library(assembly STATIC x86/asm-primitives.cpp x86/pixel.h ${OBJS})<br>
+ elseif(MSVC)<br>
+ # this is horrible. ugly, and hacky, and it reproduces logic found<br>
+ # in the yasm CMake modules, but this is required because of this cmake bug<br>
+ # <a href="http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170" target="_blank">http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170</a><br>
+ if (X64)<br>
+ set(FLAGS -f win64 -m amd64 -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=0)<br>
+ else()<br>
+ set(FLAGS -f win32 -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=0 -DPREFIX)<br>
+ endif()<br>
+ if (HIGH_BIT_DEPTH)<br>
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)<br>
+ else()<br>
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)<br>
+ endif()<br>
+ foreach(ASM ${ASMS})<br>
+ set(OBJS ${OBJS} ${ASM}.obj)<br>
+ add_custom_command(<br>
+ OUTPUT ${ASM}.obj<br>
+ COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/x86/${ASM} -o ${ASM}.obj<br>
+ DEPENDS ${ASM})<br>
+ endforeach()<br>
+ add_library(assembly STATIC x86/asm-primitives.cpp x86/pixel.h ${FULLPATHASM} ${OBJS})<br>
+ else()<br>
+ enable_language(ASM_YASM)<br>
+ set(ASM_PRIMITIVES x86/asm-primitives.cpp x86/pixel.h ${FULLPATHASM})<br>
+ endif()<br>
+endif(ENABLE_PRIMITIVES_ASM)<br>
+<br>
+enable_language(ASM_YASM)<br>
+add_library(common OBJECT<br>
${LIBCOMMON_SRC} ${LIBCOMMON_HDR}<br>
+ ${ASM_PRIMITIVES} ${VEC_PRIMITIVES}<br>
primitives.cpp primitives.h<br>
pixel.cpp dct.cpp ipfilter.cpp intrapred.cpp<br>
../VectorClass/instrset_detect.cpp<br>
@@ -94,10 +227,3 @@<br>
reference.cpp reference.h<br>
common.cpp common.h<br>
lowres.cpp lowres.h)<br>
-<br>
-if(ENABLE_PRIMITIVES_VEC)<br>
- add_subdirectory(vec)<br>
-endif(ENABLE_PRIMITIVES_VEC)<br>
-if(ENABLE_PRIMITIVES_ASM)<br>
- add_subdirectory(x86)<br>
-endif(ENABLE_PRIMITIVES_ASM)<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/common.cpp<br>
--- a/source/common/common.cpp Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/common/common.cpp Mon Oct 07 20:09:06 2013 -0500<br>
@@ -32,14 +32,6 @@<br>
#include <string.h><br>
#include <stdarg.h><br>
<br>
-#if _WIN32<br>
-#include <sys/types.h><br>
-#include <sys/timeb.h><br>
-#else<br>
-#include <sys/time.h><br>
-#endif<br>
-#include <time.h><br>
-<br>
using namespace x265;<br>
<br>
#if HIGH_BIT_DEPTH<br>
@@ -117,7 +109,7 @@<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT void x265_param_default(x265_param_t *param)<br>
+void x265_param_default(x265_param_t *param)<br>
{<br>
memset(param, 0, sizeof(x265_param_t));<br>
<br>
@@ -184,14 +176,14 @@<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT void x265_picture_init(x265_param_t *param, x265_picture_t *pic)<br>
+void x265_picture_init(x265_param_t *param, x265_picture_t *pic)<br>
{<br>
memset(pic, 0, sizeof(x265_picture_t));<br>
pic->bitDepth = param->internalBitDepth;<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT int x265_param_apply_profile(x265_param_t *param, const char *profile)<br>
+int x265_param_apply_profile(x265_param_t *param, const char *profile)<br>
{<br>
if (!profile)<br>
return 0;<br>
@@ -429,16 +421,3 @@<br>
fprintf(stderr, "\n");<br>
fflush(stderr);<br>
}<br>
-<br>
-int64_t x265_mdate(void)<br>
-{<br>
-#if _WIN32<br>
- struct timeb tb;<br>
- ftime(&tb);<br>
- return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;<br>
-#else<br>
- struct timeval tv_date;<br>
- gettimeofday(&tv_date, NULL);<br>
- return (int64_t)tv_date.tv_sec * 1000000 + (int64_t)tv_date.tv_usec;<br>
-#endif<br>
-}<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/common.h<br>
--- a/source/common/common.h Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/common/common.h Mon Oct 07 20:09:06 2013 -0500<br>
@@ -139,9 +139,5 @@<br>
int x265_check_params(x265_param_t *param);<br>
void x265_print_params(x265_param_t *param);<br>
int x265_set_globals(x265_param_t *param);<br>
-int64_t x265_mdate(void);<br>
-<br>
-/* defined in primitives.cpp */<br>
-void x265_setup_primitives(x265_param_t *param, int cpuid = 0);<br>
<br>
#endif // ifndef X265_COMMON_H<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/primitives.cpp<br>
--- a/source/common/primitives.cpp Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/common/primitives.cpp Mon Oct 07 20:09:06 2013 -0500<br>
@@ -90,7 +90,7 @@<br>
* cpuid > 0 - force CPU type<br>
* cpuid < 0 - auto-detect if uninitialized */<br>
extern "C"<br>
-X265_EXPORT void x265_setup_primitives(x265_param_t *param, int cpuid)<br>
+void x265_setup_primitives(x265_param_t *param, int cpuid)<br>
{<br>
// initialize global variables<br>
initROM();<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/vec/CMakeLists.txt<br>
--- a/source/common/vec/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000<br>
@@ -1,67 +0,0 @@<br>
-if (MSVC)<br>
- add_definitions(/wd4127) # conditional expression is constant<br>
- add_definitions(/wd4244) # 'argument' : conversion from 'int' to 'char', possible loss of data<br>
- if ("$ENV{CXX}" STREQUAL "icl")<br>
- add_definitions(/Qwd111) # statement is unreachable<br>
- add_definitions(/Qwd128) # loop is unreachable<br>
- add_definitions(/Qwd177) # declared function is unused<br>
- add_definitions(/Qwd185) # dynamic initialization in unreachable code<br>
- add_definitions(/Qwd280) # conditional expression is constant<br>
- add_definitions(/Qwd13200) # function using MMX does not call EMMS<br>
- endif()<br>
- set(PRIMITIVES blockcopy-sse3.cpp<br>
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp<br>
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp<br>
- ipfilter-ssse3.cpp ipfilter-sse41.cpp<br>
- intra-sse3.cpp intra-sse41.cpp)<br>
- if (NOT X64)<br>
- # x64 implies SSE4, so this flag would have no effect (and it issues a warning)<br>
- set_source_files_properties(blockcopy-sse3.cpp<br>
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp<br>
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp<br>
- ipfilter-ssse3.cpp ipfilter-sse41.cpp<br>
- intra-sse3.cpp intra-sse41.cpp<br>
- PROPERTIES COMPILE_FLAGS /arch:SSE2)<br>
- endif()<br>
- if (MSVC_VERSION EQUAL 1700 OR "$ENV{CXX}" STREQUAL "icl")<br>
- set(PRIMITIVES ${PRIMITIVES} blockcopy-avx2.cpp pixel-avx2.cpp)<br>
- set_source_files_properties( blockcopy-avx2.cpp pixel-avx2.cpp<br>
- PROPERTIES COMPILE_FLAGS /arch:AVX)<br>
- endif()<br>
-endif()<br>
-if(GCC)<br>
- if ("$ENV{CXX}" STREQUAL "icpc")<br>
- add_definitions(-wd13200) # function using MMX does not call EMMS<br>
- endif()<br>
- if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.3)<br>
- set(PRIMITIVES blockcopy-sse3.cpp<br>
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp<br>
- ipfilter-ssse3.cpp ipfilter-sse41.cpp<br>
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp<br>
- intra-sse3.cpp intra-sse41.cpp)<br>
- set_source_files_properties(<br>
- blockcopy-sse3.cpp pixel-sse3.cpp dct-sse3.cpp intra-sse3.cpp<br>
- PROPERTIES COMPILE_FLAGS "-msse3")<br>
- set_source_files_properties(<br>
- ipfilter-ssse3.cpp pixel-ssse3.cpp dct-ssse3.cpp<br>
- PROPERTIES COMPILE_FLAGS "-mssse3")<br>
- set_source_files_properties(<br>
- pixel-sse41.cpp ipfilter-sse41.cpp dct-sse41.cpp intra-sse41.cpp<br>
- PROPERTIES COMPILE_FLAGS "-msse4.1")<br>
- endif()<br>
- if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.7)<br>
- set(PRIMITIVES ${PRIMITIVES}<br>
- blockcopy-avx2.cpp pixel-avx2.cpp)<br>
- set_source_files_properties(<br>
- blockcopy-avx2.cpp pixel-avx2.cpp<br>
- PROPERTIES COMPILE_FLAGS "-march=core-avx2")<br>
- endif()<br>
-endif(GCC)<br>
-<br>
-file(GLOB VECTORCLASS ../../VectorClass/*.h ../../VectorClass/special/*.h)<br>
-source_group(VectorClass FILES ${VECTORCLASS})<br>
-<br>
-add_library(PrimitivesVec STATIC vec-primitives.cpp ${PRIMITIVES} ${VECTORCLASS}<br>
- # *.inc files listed here show up in Visual Studio, but are not built<br>
- # it is simply a convenience to make them easy to edit<br>
- pixel.inc pixel8.inc pixel16.inc sse.inc)<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/common/x86/CMakeLists.txt<br>
--- a/source/common/x86/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000<br>
@@ -1,60 +0,0 @@<br>
-if (GCC)<br>
- add_definitions(-DHAVE_ALIGNED_STACK=1)<br>
- add_definitions(-Wno-error=unused-parameter)<br>
-else()<br>
- add_definitions(-DHAVE_ALIGNED_STACK=0)<br>
-endif()<br>
-<br>
-set(ASMS pixel-a.asm const-a.asm cpu-a.asm sad-a.asm mc-a.asm mc-a2.asm ipfilter8.asm)<br>
-if (X64)<br>
- add_definitions(-DARCH_X86_64=1)<br>
-else()<br>
- add_definitions(-DARCH_X86_64=0)<br>
- set(ASMS ${ASMS} pixel-32.asm)<br>
-endif()<br>
-<br>
-if(XCODE)<br>
- if (X64)<br>
- set(FLAGS -f macho64 -m amd64 -DPREFIX -DPIC -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=1)<br>
- else()<br>
- set(FLAGS -f macho -DPREFIX -DPIC -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=1)<br>
- endif()<br>
- if (HIGH_BIT_DEPTH)<br>
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)<br>
- else()<br>
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)<br>
- endif()<br>
- foreach(ASM ${ASMS})<br>
- set(OBJS ${OBJS} ${ASM}.o)<br>
- add_custom_command(<br>
- OUTPUT ${ASM}.o<br>
- COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${ASM} -o ${ASM}.o<br>
- DEPENDS ${ASM})<br>
- endforeach()<br>
- add_library(PrimitivesASM asm-primitives.cpp pixel.h ${OBJS})<br>
-elseif(MSVC)<br>
- # this is horrible. ugly, and hacky, and it reproduces logic found<br>
- # in the yasm CMake modules, but this is required because of this cmake bug<br>
- # <a href="http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170" target="_blank">http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170</a><br>
- if (X64)<br>
- set(FLAGS -f win64 -m amd64 -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=0)<br>
- else()<br>
- set(FLAGS -f win32 -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=0 -DPREFIX)<br>
- endif()<br>
- if (HIGH_BIT_DEPTH)<br>
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)<br>
- else()<br>
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)<br>
- endif()<br>
- foreach(ASM ${ASMS})<br>
- set(OBJS ${OBJS} ${ASM}.obj)<br>
- add_custom_command(<br>
- OUTPUT ${ASM}.obj<br>
- COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${ASM} -o ${ASM}.obj<br>
- DEPENDS ${ASM})<br>
- endforeach()<br>
- add_library(PrimitivesASM STATIC asm-primitives.cpp pixel.h ${ASMS} ${OBJS})<br>
-else()<br>
- enable_language(ASM_YASM)<br>
- add_library(PrimitivesASM STATIC asm-primitives.cpp pixel.h ${ASMS})<br>
-endif()<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/encoder/CMakeLists.txt<br>
--- a/source/encoder/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/encoder/CMakeLists.txt Mon Oct 07 20:09:06 2013 -0500<br>
@@ -60,7 +60,7 @@<br>
"/wd4244 /wd4512 /wd4127 /wd4389 /wd4018 /wd4800")<br>
endif(MSVC)<br>
<br>
-add_library(encoder STATIC ../../COPYING ../x265.h<br>
+add_library(encoder OBJECT ../x265.h<br>
${LIBENCODER_SRC} ${LIBENCODER_HDR}<br>
bitcost.cpp bitcost.h<br>
motion.cpp motion.h<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/encoder/encoder.cpp Mon Oct 07 20:09:06 2013 -0500<br>
@@ -340,7 +340,7 @@<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT x265_t *x265_encoder_open(x265_param_t *param)<br>
+x265_t *x265_encoder_open(x265_param_t *param)<br>
{<br>
x265_setup_primitives(param, -1); // -1 means auto-detect if uninitialized<br>
<br>
@@ -369,7 +369,7 @@<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT int x265_encoder_headers(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal)<br>
+int x265_encoder_headers(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal)<br>
{<br>
if (!pp_nal)<br>
return 0;<br>
@@ -401,7 +401,7 @@<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT int x265_encoder_encode(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal, x265_picture_t *pic_in, x265_picture_t *pic_out)<br>
+int x265_encoder_encode(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal, x265_picture_t *pic_in, x265_picture_t *pic_out)<br>
{<br>
NALUnitEBSP *nalunits[MAX_NAL_UNITS] = {0, 0, 0, 0, 0};<br>
int numEncoded = encoder->encode(!pic_in, pic_in, pic_out, nalunits);<br>
@@ -429,13 +429,13 @@<br>
EXTERN_CYCLE_COUNTER(ME);<br>
<br>
extern "C"<br>
-X265_EXPORT void x265_encoder_get_stats(x265_t *encoder, x265_stats_t *outputStats)<br>
+void x265_encoder_get_stats(x265_t *encoder, x265_stats_t *outputStats)<br>
{<br>
encoder->fetchStats(outputStats);<br>
}<br>
<br>
extern "C"<br>
-X265_EXPORT void x265_encoder_close(x265_t *encoder, double *outPsnr)<br>
+void x265_encoder_close(x265_t *encoder, double *outPsnr)<br>
{<br>
double globalPsnr = encoder->printSummary();<br>
<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/test/CMakeLists.txt<br>
--- a/source/test/CMakeLists.txt Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/test/CMakeLists.txt Mon Oct 07 20:09:06 2013 -0500<br>
@@ -4,7 +4,7 @@<br>
mbdstharness.cpp mbdstharness.h<br>
ipfilterharness.cpp ipfilterharness.h<br>
intrapredharness.cpp intrapredharness.h)<br>
-target_link_libraries(TestBench x265 ${PLATFORM_LIBS})<br>
+target_link_libraries(TestBench x265-static ${PLATFORM_LIBS})<br>
<br>
add_executable(PoolTest testpool.cpp)<br>
-target_link_libraries(PoolTest x265 ${PLATFORM_LIBS})<br>
+target_link_libraries(PoolTest x265-static ${PLATFORM_LIBS})<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/x265.cpp<br>
--- a/source/x265.cpp Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/x265.cpp Mon Oct 07 20:09:06 2013 -0500<br>
@@ -36,6 +36,14 @@<br>
#endif<br>
#include "PPA/ppa.h"<br>
<br>
+#if _WIN32<br>
+#include <sys/types.h><br>
+#include <sys/timeb.h><br>
+#else<br>
+#include <sys/time.h><br>
+#endif<br>
+#include <time.h><br>
+<br>
#include <signal.h><br>
#include <errno.h><br>
#include <fcntl.h><br>
@@ -45,7 +53,6 @@<br>
#include <string.h><br>
#include <stdio.h><br>
#include <string><br>
-#include <time.h><br>
#include <list><br>
#include <ostream><br>
#include <fstream><br>
@@ -57,6 +64,19 @@<br>
#define SetConsoleTitle(t)<br>
#endif<br>
<br>
+static int64_t x265_mdate(void)<br>
+{<br>
+#if _WIN32<br>
+ struct timeb tb;<br>
+ ftime(&tb);<br>
+ return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;<br>
+#else<br>
+ struct timeval tv_date;<br>
+ gettimeofday(&tv_date, NULL);<br>
+ return (int64_t)tv_date.tv_sec * 1000000 + (int64_t)tv_date.tv_usec;<br>
+#endif<br>
+}<br>
+<br>
using namespace x265;<br>
using namespace std;<br>
<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/x265.def<br>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000<br>
+++ b/source/x265.def Mon Oct 07 20:09:06 2013 -0500<br>
@@ -0,0 +1,12 @@<br>
+EXPORTS<br>
+x265_setup_primitives<br>
+x265_param_default<br>
+x265_picture_init<br>
+x265_param_apply_profile<br>
+x265_max_bit_depth<br>
+x265_encoder_open<br>
+x265_encoder_headers<br>
+x265_encoder_encode<br>
+x265_encoder_get_stats<br>
+x265_encoder_close<br>
+x265_cleanup<br>
diff -r 9b3a427a1009 -r 6b457a8c5237 source/x265.h<br>
--- a/source/x265.h Tue Oct 08 11:12:12 2013 +0530<br>
+++ b/source/x265.h Mon Oct 07 20:09:06 2013 -0500<br>
@@ -30,12 +30,6 @@<br>
extern "C" {<br>
#endif<br>
<br>
-#if defined(WIN32) && defined(x265_EXPORTS)<br>
-#define X265_EXPORT __declspec(dllexport)<br>
-#else<br>
-#define X265_EXPORT<br>
-#endif<br>
-<br>
/* x265_t:<br>
* opaque handler for encoder */<br>
typedef struct x265_t x265_t;<br>
@@ -315,17 +309,17 @@<br>
/***<br>
* If not called, first encoder allocated will auto-detect the CPU and<br>
* initialize performance primitives, which are process global */<br>
-X265_EXPORT void x265_setup_primitives(x265_param_t *param, int cpulevel);<br>
+void x265_setup_primitives(x265_param_t *param, int cpulevel);<br>
<br>
/***<br>
* Initialize an x265_param_t structure to default values<br>
*/<br>
-X265_EXPORT void x265_param_default(x265_param_t *param);<br>
+void x265_param_default(x265_param_t *param);<br>
<br>
/***<br>
* Initialize an x265_picture_t structure to default values<br>
*/<br>
-X265_EXPORT void x265_picture_init(x265_param_t *param, x265_picture_t *pic);<br>
+void x265_picture_init(x265_param_t *param, x265_picture_t *pic);<br>
<br>
/* x265_param_apply_profile:<br>
* Applies the restrictions of the given profile. (one of below) */<br>
@@ -333,7 +327,7 @@<br>
<br>
/* (can be NULL, in which case the function will do nothing)<br>
* returns 0 on success, negative on failure (e.g. invalid profile name). */<br>
-X265_EXPORT int x265_param_apply_profile(x265_param_t *, const char *profile);<br>
+int x265_param_apply_profile(x265_param_t *, const char *profile);<br>
<br>
/* x265_max_bit_depth:<br>
* Specifies the maximum number of bits per pixel that x265 can input. This<br>
@@ -342,38 +336,38 @@<br>
* x265_max_bit_depth is 12, the internal and input bit depths can be<br>
* either 8, 10, or 12. Note that the internal bit depth must be the same<br>
* for all encoders allocated in the same process. */<br>
-X265_EXPORT extern const int x265_max_bit_depth;<br>
+extern const int x265_max_bit_depth;<br>
<br>
/* x265_encoder_open:<br>
* create a new encoder handler, all parameters from x265_param_t are copied */<br>
-X265_EXPORT x265_t* x265_encoder_open(x265_param_t *);<br>
+x265_t* x265_encoder_open(x265_param_t *);<br>
<br>
/* x265_encoder_headers:<br>
* return the SPS and PPS that will be used for the whole stream.<br>
* *pi_nal is the number of NAL units outputted in pp_nal.<br>
* returns negative on error.<br>
* the payloads of all output NALs are guaranteed to be sequential in memory. */<br>
-X265_EXPORT int x265_encoder_headers(x265_t *, x265_nal_t **pp_nal, int *pi_nal);<br>
+int x265_encoder_headers(x265_t *, x265_nal_t **pp_nal, int *pi_nal);<br>
<br>
/* x265_encoder_encode:<br>
* encode one picture.<br>
* *pi_nal is the number of NAL units outputted in pp_nal.<br>
* returns negative on error, zero if no NAL units returned.<br>
* the payloads of all output NALs are guaranteed to be sequential in memory. */<br>
-X265_EXPORT int x265_encoder_encode(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal, x265_picture_t *pic_in, x265_picture_t *pic_out);<br>
+int x265_encoder_encode(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal, x265_picture_t *pic_in, x265_picture_t *pic_out);<br>
<br>
/* x265_encoder_stats:<br>
* returns output stats from the encoder */<br>
-X265_EXPORT void x265_encoder_get_stats(x265_t *encoder, x265_stats_t *);<br>
+void x265_encoder_get_stats(x265_t *encoder, x265_stats_t *);<br>
<br>
/* x265_encoder_close:<br>
* close an encoder handler. Optionally return the global PSNR value (6 * psnrY + psnrU + psnrV) / 8 */<br>
-X265_EXPORT void x265_encoder_close(x265_t *, double *globalPsnr);<br>
+void x265_encoder_close(x265_t *, double *globalPsnr);<br>
<br>
/***<br>
* Release library static allocations<br>
*/<br>
-X265_EXPORT void x265_cleanup(void);<br>
+void x265_cleanup(void);<br>
<br>
#ifdef __cplusplus<br>
}<br>
</blockquote></div><br><br clear="all"><br>-- <br>Steve Borho
</div></div>