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